[wdspec] Add a test for browsingContext.setViewport timeouts when several contexts are created in parallel
Categories
(Remote Protocol :: WebDriver BiDi, task, P3)
Tracking
(Not tracked)
People
(Reporter: jdescottes, Unassigned)
References
(Blocks 1 open bug)
Details
(Whiteboard: [webdriver:backlog])
Attachments
(1 external file)
In Bug 2019511, we fixed an issue with setViewport which could timeout in the puppeteer test Screenshots Page.screenshot should run in parallel in multiple pages (screenshot.spec.js).
We tried to replicate the issue in a wdspec test but so far it doesn't reproduce the issue. We might still decide to land it.
| Reporter | ||
Comment 1•8 months ago
|
||
| Reporter | ||
Comment 2•8 months ago
|
||
Here is the full sequence of commands received during the test:
-> {"id":1,"method":"session.new","params":{"capabilities":{"alwaysMatch":{"acceptInsecureCerts":false,"unhandledPromptBehavior":{"default":"ignore"},"webSocketUrl":true,"goog:prerenderingDisabled":true,"goog:disableNetworkDurableMessages":true}}}}
-> {"id":2,"method":"browser.getUserContexts","params":{}}
-> {"id":3,"method":"browsingContext.getTree","params":{}}
-> {"id":4,"method":"session.subscribe","params":{"events":["browsingContext","network","log","script","input"]}}
-> {"id":7,"method":"browser.createUserContext","params":{}}
-> {"id":8,"method":"browsingContext.create","params":{"type":"tab","userContext":"460aebcc-1f17-4d5a-91c6-2619273b7f52"}}
-> {"id":9,"method":"browsingContext.setViewport","params":{"context":"0ed1ef30-7c18-4f2a-8c75-8149a0dcf6c1","viewport":{"width":800,"height":600},"devicePixelRatio":null}}
-> {"id":10,"method":"emulation.setScreenOrientationOverride","params":{"screenOrientation":{"natural":"portrait","type":"portrait-primary"},"contexts":["0ed1ef30-7c18-4f2a-8c75-8149a0dcf6c1"]}}
-> {"id":11,"method":"browsingContext.create","params":{"type":"tab","userContext":"460aebcc-1f17-4d5a-91c6-2619273b7f52"}}
-> {"id":12,"method":"browsingContext.create","params":{"type":"tab","userContext":"460aebcc-1f17-4d5a-91c6-2619273b7f52"}}
-> {"id":13,"method":"browsingContext.setViewport","params":{"context":"5e671319-9a24-4b29-97d8-31d333e2facc","viewport":{"width":800,"height":600},"devicePixelRatio":null}}
-> {"id":14,"method":"emulation.setScreenOrientationOverride","params":{"screenOrientation":{"natural":"portrait","type":"portrait-primary"},"contexts":["5e671319-9a24-4b29-97d8-31d333e2facc"]}}
-> {"id":15,"method":"browsingContext.navigate","params":{"context":"5e671319-9a24-4b29-97d8-31d333e2facc","url":"http://localhost:60307/grid.html","wait":"interactive"}}
-> {"id":16,"method":"browsingContext.setViewport","params":{"context":"708c3893-ee73-4914-a8f3-ea12a2cf7acb","viewport":{"width":800,"height":600},"devicePixelRatio":null}}
-> {"id":17,"method":"emulation.setScreenOrientationOverride","params":{"screenOrientation":{"natural":"portrait","type":"portrait-primary"},"contexts":["708c3893-ee73-4914-a8f3-ea12a2cf7acb"]}}
-> {"id":18,"method":"browsingContext.navigate","params":{"context":"708c3893-ee73-4914-a8f3-ea12a2cf7acb","url":"http://localhost:60307/grid.html","wait":"interactive"}}
-> {"id":19,"method":"browsingContext.captureScreenshot","params":{"context":"5e671319-9a24-4b29-97d8-31d333e2facc","origin":"document","format":{"type":"image/png"},"clip":{"type":"box","x":0,"y":0,"width":50,"height":50}}}
-> {"id":20,"method":"browsingContext.captureScreenshot","params":{"context":"708c3893-ee73-4914-a8f3-ea12a2cf7acb","origin":"document","format":{"type":"image/png"},"clip":{"type":"box","x":50,"y":0,"width":50,"height":50}}}
-> {"id":21,"method":"browsingContext.close","params":{"context":"5e671319-9a24-4b29-97d8-31d333e2facc"}}
-> {"id":22,"method":"browsingContext.close","params":{"context":"708c3893-ee73-4914-a8f3-ea12a2cf7acb"}}
-> {"id":23,"method":"browser.removeUserContext","params":{"userContext":"460aebcc-1f17-4d5a-91c6-2619273b7f52"}}
-> {"id":24,"method":"browser.close","params":{}}
Based on this I think my initial test was wrong because I was triggering setViewport after the pages were created. I thought set viewport was part of the screenshot command logic, but it's not in this case, it actually happens when puppeteer calls context.newPage which does the following:
const context = await this.userContext.createBrowsingContext(type, {
background: options?.background,
});
const page = this.#pages.get(context)!;
if (!page) {
throw new Error('Page is not found');
}
if (this.#defaultViewport) {
try {
await page.setViewport(this.#defaultViewport);
} catch {
// No support for setViewport in Firefox.
}
}
And puppeteer's setViewport does https://searchfox.org/firefox-main/rev/7095e662eec49a42856e0d99f2ff96c08130119c/remote/test/puppeteer/packages/puppeteer-core/src/bidi/Page.ts#450-458
await Promise.all([
this.#frame.browsingContext.setViewport({
viewport: viewportSize,
devicePixelRatio,
}),
this.#frame.browsingContext.setScreenOrientationOverride(
screenOrientation,
),
]);
I can try to adapt my existing test to match this closely.
| Reporter | ||
Updated•8 months ago
|
Description
•