|
|
|
@ -24,6 +24,15 @@ const newApp = () => { |
|
|
|
|
</head> |
|
|
|
|
</html">`); |
|
|
|
|
}); |
|
|
|
|
app.get('/reload', (req, res) => { |
|
|
|
|
res.status(200).send(` |
|
|
|
|
<html lang="en"> |
|
|
|
|
<head> |
|
|
|
|
<script>window.location.hash = Date.now()</script> |
|
|
|
|
</head> |
|
|
|
|
<body style="width:10000px; height:10000px"></body> |
|
|
|
|
</html">`); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
app.get('/*', (req, res) => { |
|
|
|
|
res.send(`<!DOCTYPEhtml>
|
|
|
|
@ -192,6 +201,59 @@ describe("zoom test", () => { |
|
|
|
|
assert.equal(tabs[1].active, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should reload current tab by r', async () => { |
|
|
|
|
await session.navigateTo(`http://127.0.0.1:${port}/reload`); |
|
|
|
|
await session.executeScript(() => window.scrollTo(500, 500)); |
|
|
|
|
let before |
|
|
|
|
await eventually(async() => { |
|
|
|
|
let tab = (await browser.tabs.query({}))[0]; |
|
|
|
|
before = Number(new URL(tab.url).hash.split('#')[1]); |
|
|
|
|
assert(before > 0); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let body = await session.findElementByCSS('body'); |
|
|
|
|
await body.sendKeys('r'); |
|
|
|
|
|
|
|
|
|
let after |
|
|
|
|
await eventually(async() => { |
|
|
|
|
let tab = (await browser.tabs.query({}))[0]; |
|
|
|
|
after = Number(new URL(tab.url).hash.split('#')[1]); |
|
|
|
|
assert(after > before); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await eventually(async() => { |
|
|
|
|
let pageYOffset = await session.executeScript(() => window.pageYOffset); |
|
|
|
|
assert.equal(pageYOffset, 500); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should reload current tab without cache by R', async () => { |
|
|
|
|
await session.navigateTo(`http://127.0.0.1:${port}/reload`); |
|
|
|
|
await session.executeScript(() => window.scrollTo(500, 500)); |
|
|
|
|
let before |
|
|
|
|
await eventually(async() => { |
|
|
|
|
let tab = (await browser.tabs.query({}))[0]; |
|
|
|
|
before = Number(new URL(tab.url).hash.split('#')[1]); |
|
|
|
|
assert(before > 0); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let body = await session.findElementByCSS('body'); |
|
|
|
|
await body.sendKeys(Key.Shift, 'R'); |
|
|
|
|
|
|
|
|
|
let after |
|
|
|
|
await eventually(async() => { |
|
|
|
|
let tab = (await browser.tabs.query({}))[0]; |
|
|
|
|
after = Number(new URL(tab.url).hash.split('#')[1]); |
|
|
|
|
assert(after > before); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// assert that the page offset is reset to 0, and 'eventually' is timed-out.
|
|
|
|
|
await assert.rejects(async () => { |
|
|
|
|
await eventually(async() => { |
|
|
|
|
let pageYOffset = await session.executeScript(() => window.pageYOffset); |
|
|
|
|
assert.equal(pageYOffset, 500); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|