Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(webkit): make go back/forard return null on error (#171)

Yury Semikhatsky02e29219fdb5
diff --git a/src/webkit/Page.ts b/src/webkit/Page.ts
index 3766eb6bac..e12a5cb13b 100644
--- a/src/webkit/Page.ts
+++ b/src/webkit/Page.ts
@@ -266,12 +266,14 @@ export class Page extends EventEmitter {
}
async _go<T extends keyof Protocol.CommandParameters>(command: T): Promise<network.Response | null> {
- const [response, error] = await Promise.all([
+ const [response] = await Promise.all([
this.waitForNavigation(),
- this._session.send(command).then(() => null).catch(e => e),
- ]);
- if (error)
- return null;
+ this._session.send(command).then(() => null),
+ ]).catch(error => {
+ if (error instanceof Error && error.message.includes(`Protocol error (${command}): Failed to go`))
+ return [null];
+ throw error;
+ });
return response;
}
diff --git a/test/navigation.spec.js b/test/navigation.spec.js
index 44ee32d46c..8fd6ffe436 100644
--- a/test/navigation.spec.js
+++ b/test/navigation.spec.js
@@ -451,7 +451,7 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
});
describe('Page.goBack', function() {
- it.skip(WEBKIT)('should work', async({page, server}) => {
+ it('should work', async({page, server}) => {
await page.goto(server.EMPTY_PAGE);
await page.goto(server.PREFIX + '/grid.html');