mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(navigation): ensure that goBack/goForward work with file urls (#2792)
This commit is contained in:
parent
c15dc94f8e
commit
9d6eaadba7
@ -7,7 +7,7 @@
|
||||
},
|
||||
{
|
||||
"name": "firefox",
|
||||
"revision": "1116"
|
||||
"revision": "1117"
|
||||
},
|
||||
{
|
||||
"name": "webkit",
|
||||
|
@ -315,13 +315,13 @@ export class FFPage implements PageDelegate {
|
||||
}
|
||||
|
||||
async goBack(): Promise<boolean> {
|
||||
const { navigationId } = await this._session.send('Page.goBack', { frameId: this._page.mainFrame()._id });
|
||||
return navigationId !== null;
|
||||
const { success } = await this._session.send('Page.goBack', { frameId: this._page.mainFrame()._id });
|
||||
return success;
|
||||
}
|
||||
|
||||
async goForward(): Promise<boolean> {
|
||||
const { navigationId } = await this._session.send('Page.goForward', { frameId: this._page.mainFrame()._id });
|
||||
return navigationId !== null;
|
||||
const { success } = await this._session.send('Page.goForward', { frameId: this._page.mainFrame()._id });
|
||||
return success;
|
||||
}
|
||||
|
||||
async evaluateOnNewDocument(source: string): Promise<void> {
|
||||
|
@ -461,23 +461,18 @@ export module Protocol {
|
||||
frameId: string;
|
||||
};
|
||||
export type goBackReturnValue = {
|
||||
navigationId: string|null;
|
||||
navigationURL: string|null;
|
||||
success: boolean;
|
||||
};
|
||||
export type goForwardParameters = {
|
||||
frameId: string;
|
||||
};
|
||||
export type goForwardReturnValue = {
|
||||
navigationId: string|null;
|
||||
navigationURL: string|null;
|
||||
success: boolean;
|
||||
};
|
||||
export type reloadParameters = {
|
||||
frameId: string;
|
||||
};
|
||||
export type reloadReturnValue = {
|
||||
navigationId: string;
|
||||
navigationURL: string;
|
||||
};
|
||||
export type reloadReturnValue = void;
|
||||
export type getBoundingBoxParameters = {
|
||||
frameId: string;
|
||||
objectId: string;
|
||||
|
@ -18,7 +18,7 @@
|
||||
const utils = require('./utils');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN, CHANNEL} = utils.testOptions(browserType);
|
||||
const {FFOX, CHROMIUM, WEBKIT, ASSETS_DIR, MAC, WIN, CHANNEL} = utils.testOptions(browserType);
|
||||
|
||||
describe('Page.goto', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
@ -896,6 +896,32 @@ describe('Page.goBack', function() {
|
||||
await page.goForward();
|
||||
expect(page.url()).toBe(server.PREFIX + '/first.html');
|
||||
});
|
||||
it.fail(WEBKIT && MAC)('should work for file urls', async ({page, server}) => {
|
||||
// WebKit embedder fails to go back/forward to the file url.
|
||||
const url1 = WIN
|
||||
? 'file:///' + path.join(ASSETS_DIR, 'empty.html').replace(/\\/g, '/')
|
||||
: 'file://' + path.join(ASSETS_DIR, 'empty.html');
|
||||
const url2 = server.EMPTY_PAGE;
|
||||
await page.goto(url1);
|
||||
await page.setContent(`<a href='${url2}'>url2</a>`);
|
||||
expect(page.url().toLowerCase()).toBe(url1.toLowerCase());
|
||||
|
||||
await page.click('a');
|
||||
expect(page.url()).toBe(url2);
|
||||
|
||||
await page.goBack();
|
||||
expect(page.url().toLowerCase()).toBe(url1.toLowerCase());
|
||||
// Should be able to evaluate in the new context, and
|
||||
// not reach for the old cross-process one.
|
||||
expect(await page.evaluate(() => window.scrollX)).toBe(0);
|
||||
// Should be able to screenshot.
|
||||
await page.screenshot();
|
||||
|
||||
await page.goForward();
|
||||
expect(page.url()).toBe(url2);
|
||||
expect(await page.evaluate(() => window.scrollX)).toBe(0);
|
||||
await page.screenshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame.goto', function() {
|
||||
|
@ -190,6 +190,7 @@ const utils = module.exports = {
|
||||
testOptions(browserType) {
|
||||
const GOLDEN_DIR = path.join(__dirname, 'golden-' + browserType.name());
|
||||
const OUTPUT_DIR = path.join(__dirname, 'output-' + browserType.name());
|
||||
const ASSETS_DIR = path.join(__dirname, 'assets');
|
||||
return {
|
||||
FFOX: browserType.name() === 'firefox',
|
||||
WEBKIT: browserType.name() === 'webkit',
|
||||
@ -200,6 +201,7 @@ const utils = module.exports = {
|
||||
browserType,
|
||||
GOLDEN_DIR,
|
||||
OUTPUT_DIR,
|
||||
ASSETS_DIR,
|
||||
USES_HOOKS: !!process.env.PWCHANNEL,
|
||||
CHANNEL: !!process.env.PWCHANNEL,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user