Fix viewport hijacking beta.9

Fixes Playwright's setDefaultViewport overriding Camoufox viewport data.
This commit is contained in:
daijro 2024-09-30 00:38:47 -05:00
parent 110eb970c9
commit 752a36c9c2
2 changed files with 7 additions and 7 deletions

View file

@ -1,6 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js'); const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
const {SimpleChannel} = ChromeUtils.import('chrome://juggler/content/SimpleChannel.js'); const {SimpleChannel} = ChromeUtils.import('chrome://juggler/content/SimpleChannel.js');
@ -13,7 +13,7 @@ const Cr = Components.results;
const helper = new Helper(); const helper = new Helper();
const IDENTITY_NAME = 'JUGGLER '; const IDENTITY_NAME = 'Camoufox ';
const HUNDRED_YEARS = 60 * 60 * 24 * 365 * 100; const HUNDRED_YEARS = 60 * 60 * 24 * 365 * 100;
const ALL_PERMISSIONS = [ const ALL_PERMISSIONS = [
@ -571,10 +571,8 @@ class PageTarget {
// default viewport. // default viewport.
// Do not allow default viewport size if Camoufox set it first // Do not allow default viewport size if Camoufox set it first
const viewportSize = this._viewportSize || this._browserContext.defaultViewportSize;
if ( if (
!viewportSize && !this._viewportSize &&
this._browserContext.defaultViewportSize && ( this._browserContext.defaultViewportSize && (
ChromeUtils.camouGetConfig("window.outerWidth") || ChromeUtils.camouGetConfig("window.outerWidth") ||
ChromeUtils.camouGetConfig("window.outerHeight") || ChromeUtils.camouGetConfig("window.outerHeight") ||
@ -584,6 +582,8 @@ class PageTarget {
return; return;
} }
const viewportSize = this._viewportSize || this._browserContext.defaultViewportSize;
if (viewportSize) { if (viewportSize) {
const {width, height} = viewportSize; const {width, height} = viewportSize;
this._linkedBrowser.style.setProperty('width', width + 'px'); this._linkedBrowser.style.setProperty('width', width + 'px');

View file

@ -1,2 +1,2 @@
version=130.0.1 version=130.0.1
release=beta.8 release=beta.9