feat(webkit): add page back/forward commands (#144)
This commit is contained in:
parent
b5af3cac11
commit
25af050bd4
|
|
@ -267,6 +267,24 @@ export class Page extends EventEmitter {
|
||||||
return response;
|
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> {
|
async waitForNavigation(): Promise<network.Response | null> {
|
||||||
return await this._frameManager.mainFrame().waitForNavigation();
|
return await this._frameManager.mainFrame().waitForNavigation();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -466,7 +466,7 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
|
||||||
response = await page.goForward();
|
response = await page.goForward();
|
||||||
expect(response).toBe(null);
|
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.goto(server.EMPTY_PAGE);
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
history.pushState({}, '', '/first.html');
|
history.pushState({}, '', '/first.html');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue