feat(webkit): add page back/forward commands (#144)

This commit is contained in:
Yury Semikhatsky 2019-12-05 09:32:52 -07:00 committed by Dmitry Gozman
parent b5af3cac11
commit 25af050bd4
2 changed files with 19 additions and 1 deletions

View File

@ -267,6 +267,24 @@ export class Page extends EventEmitter {
return response;
}
async goBack(): Promise<network.Response | null> {
return await this._go('Page.goBack');
}
async goForward(): Promise<network.Response | null> {
return await this._go('Page.goForward');
}
async _go<T extends keyof Protocol.CommandParameters>(command: T): Promise<network.Response | null> {
const [response, error] = await Promise.all([
this.waitForNavigation(),
this._session.send(command).then(() => null).catch(e => e),
]);
if (error)
return null;
return response;
}
async waitForNavigation(): Promise<network.Response | null> {
return await this._frameManager.mainFrame().waitForNavigation();
}

View File

@ -466,7 +466,7 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
response = await page.goForward();
expect(response).toBe(null);
});
it.skip(WEBKIT)('should work with HistoryAPI', async({page, server}) => {
it('should work with HistoryAPI', async({page, server}) => {
await page.goto(server.EMPTY_PAGE);
await page.evaluate(() => {
history.pushState({}, '', '/first.html');