feat(goto): better navigation error message (#23609)

While this log message is only a sanity check, it is still beneficial to
have a message that can better inform what is happening when this
occurs.
This commit is contained in:
Ben Hofferber 2023-06-21 14:10:35 -04:00 committed by GitHub
parent a658c4fd05
commit 752176fd23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -682,7 +682,7 @@ export class Frame extends SdkObject {
if (event.newDocument!.documentId !== navigateResult.newDocumentId) { if (event.newDocument!.documentId !== navigateResult.newDocumentId) {
// This is just a sanity check. In practice, new navigation should // This is just a sanity check. In practice, new navigation should
// cancel the previous one and report "request cancelled"-like error. // cancel the previous one and report "request cancelled"-like error.
throw new NavigationAbortedError(navigateResult.newDocumentId, 'Navigation interrupted by another one'); throw new NavigationAbortedError(navigateResult.newDocumentId, `Navigation to "${url}" is interrupted by another navigation to "${event.url}"`);
} }
if (event.error) if (event.error)
throw event.error; throw event.error;

View file

@ -410,10 +410,10 @@ it('should fail when replaced by another navigation', async ({ page, server, bro
if (browserName === 'chromium') { if (browserName === 'chromium') {
expect(error.message).toContain('net::ERR_ABORTED'); expect(error.message).toContain('net::ERR_ABORTED');
} else if (browserName === 'webkit') { } else if (browserName === 'webkit') {
expect(error.message).toContain('Navigation interrupted by another one'); expect(error.message).toContain(`page.goto: Navigation to "${server.PREFIX + '/empty.html'}" is interrupted by another navigation to "${server.PREFIX + '/one-style.html'}"`);
} else if (browserName === 'firefox') { } else if (browserName === 'firefox') {
// Firefox might yield either NS_BINDING_ABORTED or 'navigation interrupted by another one' // Firefox might yield either NS_BINDING_ABORTED or 'navigation interrupted by another one'
expect(error.message.includes('Navigation interrupted by another one') || error.message.includes('NS_BINDING_ABORTED')).toBe(true); expect(error.message.includes(`page.goto: Navigation to "${server.PREFIX + '/empty.html'}" is interrupted by another navigation to "${server.PREFIX + '/one-style.html'}"`) || error.message.includes('NS_BINDING_ABORTED')).toBe(true);
} }
}); });
@ -460,7 +460,7 @@ it('js redirect overrides url bar navigation ', async ({ page, server, browserNa
expect(error).toBeFalsy(); expect(error).toBeFalsy();
await expect(page).toHaveURL(server.PREFIX + '/b'); await expect(page).toHaveURL(server.PREFIX + '/b');
} else if (browserName === 'webkit') { } else if (browserName === 'webkit') {
expect(error.message).toContain('Navigation interrupted by another one'); expect(error.message).toContain(`page.goto: Navigation to "${server.PREFIX + '/b'}" is interrupted by another navigation to "${server.PREFIX + '/c'}"`);
await expect(page).toHaveURL(server.PREFIX + '/c'); await expect(page).toHaveURL(server.PREFIX + '/c');
} else if (browserName === 'firefox') { } else if (browserName === 'firefox') {
expect(error.message).toContain('NS_BINDING_ABORTED'); expect(error.message).toContain('NS_BINDING_ABORTED');