fix: promise resolved to early when browser initiated in-page navigation v2 (#39679)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Tomasz Malinowski <tomasz@openfin.co>
This commit is contained in:
trop[bot]
2023-08-31 10:40:28 -04:00
committed by GitHub
parent 81bd81667c
commit 3f1fee72b4
3 changed files with 34 additions and 2 deletions

View File

@@ -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');

View File

@@ -0,0 +1,15 @@
<html>
<header>
<script type="text/javascript">
window.history.replaceState(window.location.href, "Sample Title", window.location.href);
// Simulate that we load web page.
let d = new Date();
const endTime = new Date(d.getTime() + (10 * 1000));
while(d.getTime() < endTime) {
d = new Date();
}
</script>
</header>
<body>
</body>
</html>