chore: add Page.reload for BiDi (#10274)

This commit is contained in:
Nikolay Vitkov 2023-05-31 13:13:34 +02:00 committed by GitHub
parent 3fdad21744
commit 6f8ea5764d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 17 deletions

16
package-lock.json generated
View File

@ -2733,9 +2733,9 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/chromium-bidi": { "node_modules/chromium-bidi": {
"version": "0.4.10", "version": "0.4.11",
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.10.tgz", "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.11.tgz",
"integrity": "sha512-ngdRIq/f5G3nIOz1M0MtCABCTezr79MBCrJ09K2xRk+hTZQGTH8JIeFbgQmVvNPBMQblh7ROfJnSzsE07YpFfg==", "integrity": "sha512-p03ajLhlQ5gebw3cmbDBFmBc2wnJM5dnXS8Phu6mblGn/KQd76yOVL5VwE0VAisa7oazNfKGTaXlIZ8Q5Bb9OA==",
"dependencies": { "dependencies": {
"mitt": "3.0.0" "mitt": "3.0.0"
}, },
@ -9845,7 +9845,7 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@puppeteer/browsers": "1.4.0", "@puppeteer/browsers": "1.4.0",
"chromium-bidi": "0.4.10", "chromium-bidi": "0.4.11",
"cross-fetch": "3.1.6", "cross-fetch": "3.1.6",
"debug": "4.3.4", "debug": "4.3.4",
"devtools-protocol": "0.0.1120988", "devtools-protocol": "0.0.1120988",
@ -11860,9 +11860,9 @@
"version": "1.1.4" "version": "1.1.4"
}, },
"chromium-bidi": { "chromium-bidi": {
"version": "0.4.10", "version": "0.4.11",
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.10.tgz", "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.11.tgz",
"integrity": "sha512-ngdRIq/f5G3nIOz1M0MtCABCTezr79MBCrJ09K2xRk+hTZQGTH8JIeFbgQmVvNPBMQblh7ROfJnSzsE07YpFfg==", "integrity": "sha512-p03ajLhlQ5gebw3cmbDBFmBc2wnJM5dnXS8Phu6mblGn/KQd76yOVL5VwE0VAisa7oazNfKGTaXlIZ8Q5Bb9OA==",
"requires": { "requires": {
"mitt": "3.0.0" "mitt": "3.0.0"
} }
@ -15174,7 +15174,7 @@
"version": "file:packages/puppeteer-core", "version": "file:packages/puppeteer-core",
"requires": { "requires": {
"@puppeteer/browsers": "1.4.0", "@puppeteer/browsers": "1.4.0",
"chromium-bidi": "0.4.10", "chromium-bidi": "0.4.11",
"cross-fetch": "3.1.6", "cross-fetch": "3.1.6",
"debug": "4.3.4", "debug": "4.3.4",
"devtools-protocol": "0.0.1120988", "devtools-protocol": "0.0.1120988",

View File

@ -30,6 +30,7 @@
"test:chrome:new-headless": "wireit", "test:chrome:new-headless": "wireit",
"test:chrome:headless": "wireit", "test:chrome:headless": "wireit",
"test:chrome:bidi": "wireit", "test:chrome:bidi": "wireit",
"test:chrome:bidi-local": "wireit",
"test:chrome": "wireit", "test:chrome": "wireit",
"test:firefox:bidi": "wireit", "test:firefox:bidi": "wireit",
"test:firefox:headful": "wireit", "test:firefox:headful": "wireit",
@ -81,6 +82,12 @@
"./test:build" "./test:build"
] ]
}, },
"test:chrome:bidi-local": {
"command": "PUPPETEER_EXECUTABLE_PATH=$(node tools/download_chrome_bidi.mjs ~/.cache/puppeteer/chrome-canary --shell) npm test -- --test-suite chrome-bidi",
"dependencies": [
"./test:build"
]
},
"test:firefox:headful": { "test:firefox:headful": {
"command": "npm test -- --test-suite firefox-headful", "command": "npm test -- --test-suite firefox-headful",
"dependencies": [ "dependencies": [

View File

@ -132,7 +132,7 @@
"author": "The Chromium Authors", "author": "The Chromium Authors",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"chromium-bidi": "0.4.10", "chromium-bidi": "0.4.11",
"cross-fetch": "3.1.6", "cross-fetch": "3.1.6",
"debug": "4.3.4", "debug": "4.3.4",
"devtools-protocol": "0.0.1120988", "devtools-protocol": "0.0.1120988",

View File

@ -1,6 +1,7 @@
import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js'; import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import ProtocolMapping from 'devtools-protocol/types/protocol-mapping.js'; import ProtocolMapping from 'devtools-protocol/types/protocol-mapping.js';
import {WaitForOptions} from '../../api/Page.js';
import {assert} from '../../util/assert.js'; import {assert} from '../../util/assert.js';
import {stringifyFunction} from '../../util/Function.js'; import {stringifyFunction} from '../../util/Function.js';
import {ProtocolError, TimeoutError} from '../Errors.js'; import {ProtocolError, TimeoutError} from '../Errors.js';
@ -116,6 +117,26 @@ export class BrowsingContext extends EventEmitter {
} }
} }
async reload(options: WaitForOptions = {}): Promise<void> {
const {
waitUntil = 'load',
timeout = this.#timeoutSettings.navigationTimeout(),
} = options;
const readinessState = lifeCycleToReadinessState.get(
getWaitUntilSingle(waitUntil)
) as Bidi.BrowsingContext.ReadinessState;
await waitWithTimeout(
this.connection.send('browsingContext.reload', {
context: this.#id,
wait: readinessState,
}),
'Navigation',
timeout
);
}
async evaluateHandle< async evaluateHandle<
Params extends unknown[], Params extends unknown[],
Func extends EvaluateFunc<Params> = EvaluateFunc<Params> Func extends EvaluateFunc<Params> = EvaluateFunc<Params>

View File

@ -59,6 +59,10 @@ interface Commands {
params: Bidi.BrowsingContext.NavigateParameters; params: Bidi.BrowsingContext.NavigateParameters;
returnType: Bidi.BrowsingContext.NavigateResult; returnType: Bidi.BrowsingContext.NavigateResult;
}; };
'browsingContext.reload': {
params: Bidi.BrowsingContext.ReloadParameters;
returnType: Bidi.Message.EmptyResult;
};
'browsingContext.print': { 'browsingContext.print': {
params: Bidi.BrowsingContext.PrintParameters; params: Bidi.BrowsingContext.PrintParameters;
returnType: Bidi.BrowsingContext.PrintResult; returnType: Bidi.BrowsingContext.PrintResult;

View File

@ -313,6 +313,22 @@ export class Page extends PageBase {
return this.mainFrame().goto(url, options); return this.mainFrame().goto(url, options);
} }
override async reload(
options?: WaitForOptions
): Promise<HTTPResponse | null> {
const [response] = await Promise.all([
this.waitForResponse(response => {
return (
response.request().isNavigationRequest() &&
response.url() === this.url()
);
}),
this.mainFrame().context().reload(options),
]);
return response;
}
override url(): string { override url(): string {
return this.mainFrame().url(); return this.mainFrame().url();
} }

View File

@ -461,12 +461,6 @@
"parameters": ["webDriverBiDi"], "parameters": ["webDriverBiDi"],
"expectations": ["FAIL"] "expectations": ["FAIL"]
}, },
{
"testIdPattern": "[navigation.spec] navigation Page.reload should work",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL", "TIMEOUT"]
},
{ {
"testIdPattern": "[network.spec] network Network Events Page.Events.RequestFinished", "testIdPattern": "[network.spec] network Network Events Page.Events.RequestFinished",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],
@ -530,7 +524,7 @@
{ {
"testIdPattern": "[network.spec] network Response.fromCache should work", "testIdPattern": "[network.spec] network Response.fromCache should work",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"], "parameters": ["firefox", "webDriverBiDi"],
"expectations": ["FAIL"] "expectations": ["FAIL"]
}, },
{ {
@ -1379,6 +1373,12 @@
"parameters": ["firefox", "webDriverBiDi"], "parameters": ["firefox", "webDriverBiDi"],
"expectations": ["FAIL"] "expectations": ["FAIL"]
}, },
{
"testIdPattern": "[navigation.spec] navigation Page.goto should return last response in redirect chain",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["FAIL"]
},
{ {
"testIdPattern": "[navigation.spec] navigation Page.goto should return response when page changes its URL after load", "testIdPattern": "[navigation.spec] navigation Page.goto should return response when page changes its URL after load",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],
@ -1457,6 +1457,12 @@
"parameters": ["cdp", "firefox"], "parameters": ["cdp", "firefox"],
"expectations": ["SKIP"] "expectations": ["SKIP"]
}, },
{
"testIdPattern": "[navigation.spec] navigation Page.reload should work",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["firefox", "webDriverBiDi"],
"expectations": ["FAIL"]
},
{ {
"testIdPattern": "[navigation.spec] navigation Page.waitForNavigation should work when subframe issues window.stop()", "testIdPattern": "[navigation.spec] navigation Page.waitForNavigation should work when subframe issues window.stop()",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],

View File

@ -51,7 +51,9 @@ try {
browser, browser,
buildId, buildId,
}); });
actions.setOutput('executablePath', executablePath); if (process.argv.indexOf('--shell') === -1) {
actions.setOutput('executablePath', executablePath);
}
console.log(executablePath); console.log(executablePath);
} catch (err) { } catch (err) {
actions.setFailed(`Failed to download the browser: ${err.message}`); actions.setFailed(`Failed to download the browser: ${err.message}`);