fix: promise resolved to early when browser initiated in-page navigation (#39260)
This commit is contained in:
parent
d9329042e2
commit
a0effaf9b8
3 changed files with 32 additions and 2 deletions
|
@ -375,6 +375,16 @@ describe('webContents module', () => {
|
|||
await expect(w.loadURL(w.getURL() + '#foo')).to.eventually.be.fulfilled();
|
||||
});
|
||||
|
||||
it('resolves after browser initiated navigation', async () => {
|
||||
let finishedLoading = false;
|
||||
w.webContents.on('did-finish-load', function () {
|
||||
finishedLoading = true;
|
||||
});
|
||||
|
||||
await w.loadFile(path.join(fixturesPath, 'pages', 'navigate_in_page_and_wait.html'));
|
||||
expect(finishedLoading).to.be.true();
|
||||
});
|
||||
|
||||
it('rejects when failing to load a file URL', async () => {
|
||||
await expect(w.loadURL('file:non-existent')).to.eventually.be.rejected()
|
||||
.and.have.property('code', 'ERR_FILE_NOT_FOUND');
|
||||
|
|
13
spec/fixtures/pages/navigate_in_page_and_wait.html
vendored
Normal file
13
spec/fixtures/pages/navigate_in_page_and_wait.html
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
<html>
|
||||
<header>
|
||||
<script type="text/javascript">
|
||||
window.history.replaceState(window.location.href, "Sample Title", window.location.href);
|
||||
// Simulate that we load web page.
|
||||
for (let i = 0; i < 10000; i++) {
|
||||
console.log('wait : ' + i);
|
||||
}
|
||||
</script>
|
||||
</header>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue