diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index 0c1cb11d9e5f..8f0f53aa2ba7 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -446,7 +446,6 @@ WebContents.prototype.loadURL = function (url, options) { }; let navigationStarted = false; - let browserInitiatedInPageNavigation = false; const navigationListener = (event: Electron.Event, url: string, isSameDocument: boolean, isMainFrame: boolean) => { if (isMainFrame) { if (navigationStarted && !isSameDocument) { @@ -461,7 +460,6 @@ WebContents.prototype.loadURL = function (url, options) { // as the routing does not leave the document return rejectAndCleanup(-3, 'ERR_ABORTED', url); } - browserInitiatedInPageNavigation = navigationStarted && isSameDocument; navigationStarted = true; } }; @@ -476,22 +474,17 @@ WebContents.prototype.loadURL = function (url, options) { // would be more appropriate. rejectAndCleanup(-2, 'ERR_FAILED', url); }; - const finishListenerWhenUserInitiatedNavigation = () => { - if (!browserInitiatedInPageNavigation) { - finishListener(); - } - }; const removeListeners = () => { this.removeListener('did-finish-load', finishListener); this.removeListener('did-fail-load', failListener); - this.removeListener('did-navigate-in-page', finishListenerWhenUserInitiatedNavigation); + this.removeListener('did-navigate-in-page', finishListener); this.removeListener('did-start-navigation', navigationListener); this.removeListener('did-stop-loading', stopLoadingListener); this.removeListener('destroyed', stopLoadingListener); }; this.on('did-finish-load', finishListener); this.on('did-fail-load', failListener); - this.on('did-navigate-in-page', finishListenerWhenUserInitiatedNavigation); + this.on('did-navigate-in-page', finishListener); this.on('did-start-navigation', navigationListener); this.on('did-stop-loading', stopLoadingListener); this.on('destroyed', stopLoadingListener); diff --git a/spec/api-web-contents-spec.ts b/spec/api-web-contents-spec.ts index 0be6172bb90b..aeb2a1134988 100644 --- a/spec/api-web-contents-spec.ts +++ b/spec/api-web-contents-spec.ts @@ -375,16 +375,6 @@ 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'); diff --git a/spec/fixtures/pages/navigate_in_page_and_wait.html b/spec/fixtures/pages/navigate_in_page_and_wait.html deleted file mode 100644 index 40b12b738522..000000000000 --- a/spec/fixtures/pages/navigate_in_page_and_wait.html +++ /dev/null @@ -1,13 +0,0 @@ - -
- -
- - -