mirror of
https://forge.fsky.io/oneflux/omegafox.git
synced 2026-04-11 09:12:05 -07:00
Allow Playwright's defaultViewportSize
This commit is contained in:
parent
e6beecb3a9
commit
1adc258fd8
2 changed files with 11 additions and 2 deletions
|
|
@ -1024,6 +1024,15 @@ class BrowserContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
async setDefaultViewport(viewport) {
|
async setDefaultViewport(viewport) {
|
||||||
|
// Camoufox: only override the set viewport if a new one was passed
|
||||||
|
if (
|
||||||
|
ChromeUtils.camouGetInt("window.innerWidth")
|
||||||
|
|| ChromeUtils.camouGetInt("window.innerHeight")
|
||||||
|
) {
|
||||||
|
if (viewport.viewportSize?.width == 1280 && viewport.viewportSize?.height == 720) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.defaultViewportSize = viewport ? viewport.viewportSize : undefined;
|
this.defaultViewportSize = viewport ? viewport.viewportSize : undefined;
|
||||||
this.deviceScaleFactor = viewport ? viewport.deviceScaleFactor : undefined;
|
this.deviceScaleFactor = viewport ? viewport.deviceScaleFactor : undefined;
|
||||||
await Promise.all(Array.from(this.pages).map(page => page.updateViewportSize()));
|
await Promise.all(Array.from(this.pages).map(page => page.updateViewportSize()));
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@ class PageHandler {
|
||||||
|
|
||||||
// Try to fetch the viewport size
|
// Try to fetch the viewport size
|
||||||
this._defaultCursorPos = {
|
this._defaultCursorPos = {
|
||||||
x: random_val(this._pageTarget._viewportSize.width),
|
x: random_val(this._pageTarget._viewportSize?.width || 1280),
|
||||||
y: random_val(this._pageTarget._viewportSize.height),
|
y: random_val(this._pageTarget._viewportSize?.height || 720),
|
||||||
};
|
};
|
||||||
this._lastMousePosition = { ...this._defaultCursorPos };
|
this._lastMousePosition = { ...this._defaultCursorPos };
|
||||||
this._lastTrackedPos = { ...this._defaultCursorPos };
|
this._lastTrackedPos = { ...this._defaultCursorPos };
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue