Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat(firefox): roll to r1560 (#43369)
microsoft-playwright-automation[bot]ccd519ec3de6
diff --git a/browser_patches/firefox/juggler/TargetRegistry.js b/browser_patches/firefox/juggler/TargetRegistry.jsindex f77c9e56f8..262c2d73f5 100644--- a/browser_patches/firefox/juggler/TargetRegistry.js+++ b/browser_patches/firefox/juggler/TargetRegistry.js@@ -107,6 +107,81 @@ class DownloadInterceptor {const screencastService = Cc['@mozilla.org/juggler/screencast;1'].getService(Ci.nsIScreencastService);+const FILE_PICKER_CONTRACT_ID = '@mozilla.org/filepicker;1';++// Replaces the "@mozilla.org/filepicker;1" factory in the parent process, the same way+// WebDriver's FilePickerHandler and MockFilePicker do. Content processes always use+// nsFilePickerProxy, which asks the parent (FilePickerParent) to create the real picker,+// so a parent-side override covers all pages. Pages that intercept file choosers get a+// picker that cancels immediately; everything else is forwarded to the original picker.+class FilePickerOverride {+ constructor(registry) {+ this._registry = registry;+ this._registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);+ const originalCID = this._registrar.contractIDToCID(FILE_PICKER_CONTRACT_ID);+ this._originalFactory = Components.manager.getClassObject(originalCID, Ci.nsIFactory);+ this._cid = Services.uuid.generateUUID();+ this._factory = {+ createInstance: iid => this._createPicker().QueryInterface(iid),+ QueryInterface: ChromeUtils.generateQI(['nsIFactory']),+ };+ this._registrar.registerFactory(this._cid, 'Juggler file picker', FILE_PICKER_CONTRACT_ID, this._factory);+ }++ _createPicker() {+ let original = null;+ const state = {};+ const picker = {+ QueryInterface: ChromeUtils.generateQI(['nsIFilePicker']),+ init: (browsingContext, title, mode, global) => {+ const target = this._registry.targetForBrowserId(browsingContext.browserId);+ if (target && target.crossProcessCookie.interceptFileChooserDialog) {+ state.mode = mode;+ return;+ }+ original = this._originalFactory.createInstance(Ci.nsIFilePicker);+ original.init(browsingContext, title, mode, global);+ },+ open: callback => {+ if (original)+ original.open(callback);+ else+ callback.done(Ci.nsIFilePicker.returnCancel);+ },+ isModeSupported: mode => original ? original.isModeSupported(mode) : Promise.resolve(true),+ appendFilters: filterMask => original?.appendFilters(filterMask),+ appendFilter: (title, filter) => original?.appendFilter(title, filter),+ appendRawFilter: filter => original?.appendRawFilter(filter),++ get defaultString() { return original ? original.defaultString : state.defaultString; },+ set defaultString(value) { if (original) original.defaultString = value; else state.defaultString = value; },+ get defaultExtension() { return original ? original.defaultExtension : state.defaultExtension; },+ set defaultExtension(value) { if (original) original.defaultExtension = value; else state.defaultExtension = value; },+ get filterIndex() { return original ? original.filterIndex : state.filterIndex; },+ set filterIndex(value) { if (original) original.filterIndex = value; else state.filterIndex = value; },+ get displayDirectory() { return original ? original.displayDirectory : state.displayDirectory; },+ set displayDirectory(value) { if (original) original.displayDirectory = value; else state.displayDirectory = value; },+ get displaySpecialDirectory() { return original ? original.displaySpecialDirectory : state.displaySpecialDirectory; },+ set displaySpecialDirectory(value) { if (original) original.displaySpecialDirectory = value; else state.displaySpecialDirectory = value; },+ get addToRecentDocs() { return original ? original.addToRecentDocs : state.addToRecentDocs; },+ set addToRecentDocs(value) { if (original) original.addToRecentDocs = value; else state.addToRecentDocs = value; },+ get okButtonLabel() { return original ? original.okButtonLabel : state.okButtonLabel; },+ set okButtonLabel(value) { if (original) original.okButtonLabel = value; else state.okButtonLabel = value; },+ get capture() { return original ? original.capture : state.capture; },+ set capture(value) { if (original) original.capture = value; else state.capture = value; },++ get mode() { return original ? original.mode : state.mode; },+ get file() { return original ? original.file : null; },+ get fileURL() { return original ? original.fileURL : null; },+ get files() { return original ? original.files : null; },+ get domFileOrDirectory() { return original ? original.domFileOrDirectory : null; },+ get domFileOrDirectoryEnumerator() { return original ? original.domFileOrDirectoryEnumerator : null; },+ get domFilesInWebKitDirectory() { return original ? original.domFilesInWebKitDirectory : null; },+ };+ return picker;+ }+}+export class TargetRegistry {static instance() {return TargetRegistry._instance || null;@@ -125,6 +200,7 @@ export class TargetRegistry {this._proxiesWithClashingAuthCacheKeys = new Set();this._browserProxy = null;+ this._filePickerOverride = new FilePickerOverride(this);// Cleanup containers from previous runs (if any)for (const identity of ContextualIdentityService.getPublicIdentities()) {diff --git a/browser_patches/firefox/juggler/content/PageAgent.js b/browser_patches/firefox/juggler/content/PageAgent.jsindex 5711240bf7..52ac805d52 100644--- a/browser_patches/firefox/juggler/content/PageAgent.js+++ b/browser_patches/firefox/juggler/content/PageAgent.js@@ -59,6 +59,7 @@ export class PageAgent {this._runtime = frameTree.runtime();this._workerData = new Map();+ this._interceptFileChooserDialog = false;const docShell = frameTree.mainFrame().docShell();this._docShell = docShell;@@ -97,7 +98,7 @@ export class PageAgent {this._eventListeners = [helper.addObserver(this._linkClicked.bind(this, false), 'juggler-link-click'),helper.addObserver(this._linkClicked.bind(this, true), 'juggler-link-click-sync'),- helper.addObserver(this._filePickerShown.bind(this), 'juggler-file-picker-shown'),+ helper.addObserver(this._filePickerShown.bind(this), 'file-input-picker-opening'),helper.addObserver(this._onDocumentOpenLoad.bind(this), 'juggler-document-open-loaded'),helper.on(this._frameTree, 'frameattached', this._onFrameAttached.bind(this)),helper.on(this._frameTree, 'framedetached', this._onFrameDetached.bind(this)),@@ -222,7 +223,16 @@ export class PageAgent {this._browserPage.emit('pageLinkClicked', { phase: sync ? 'after' : 'before' });}+ setInterceptFileChooserDialog(enabled) {+ this._interceptFileChooserDialog = enabled;+ }+_filePickerShown(inputElement) {+ // Fired by HTMLInputElement::InitFilePicker right before the native picker is opened.+ // When intercepting, the parent process replaces the native picker with one that+ // cancels immediately (see FilePickerOverride in TargetRegistry.js).+ if (!this._interceptFileChooserDialog)+ return;const frame = this._findFrameForNode(inputElement);if (!frame)return;diff --git a/browser_patches/firefox/juggler/content/main.js b/browser_patches/firefox/juggler/content/main.jsindex 188d40d528..ebc1a15733 100644--- a/browser_patches/firefox/juggler/content/main.js+++ b/browser_patches/firefox/juggler/content/main.js@@ -62,7 +62,7 @@ export function initialize(browsingContext, docShell) {data.frameTree.setInitScripts([...contextCrossProcessCookie.initScripts, ...pageCrossProcessCookie.initScripts]);data.channel = new SimpleChannel('', 'process-' + Services.appinfo.processID + '-' + helper.generateId());data.pageAgent = new PageAgent(data.channel, data.frameTree);- docShell.fileInputInterceptionEnabled = !!pageCrossProcessCookie.interceptFileChooserDialog;+ data.pageAgent.setInterceptFileChooserDialog(!!pageCrossProcessCookie.interceptFileChooserDialog);data.channel.register('', {setInitScripts(scripts) {@@ -78,7 +78,7 @@ export function initialize(browsingContext, docShell) {},setInterceptFileChooserDialog(enabled) {- docShell.fileInputInterceptionEnabled = !!enabled;+ data.pageAgent.setInterceptFileChooserDialog(!!enabled);},ensurePermissions() {@@ -90,7 +90,11 @@ export function initialize(browsingContext, docShell) {const listeners = [];const check = () => {helper.removeListeners(listeners);- if (docShell.domWindow.innerWidth === width && docShell.domWindow.innerHeight === height) {+ // Note: innerWidth/innerHeight are not rounded for system callers (Firefox 156+),+ // and the actual size may be fractional, e.g. with a fractional device scale factor.+ // Web content observes the rounded values, so wait for approximately the same size.+ const { innerWidth, innerHeight } = docShell.domWindow;+ if (Math.abs(innerWidth - width) < 1 && Math.abs(innerHeight - height) < 1) {resolve();return;}diff --git a/browser_patches/firefox/patches/bootstrap.diff b/browser_patches/firefox/patches/bootstrap.diffindex cf54560da1..9e3b16c757 100644--- a/browser_patches/firefox/patches/bootstrap.diff+++ b/browser_patches/firefox/patches/bootstrap.diff@@ -164,22 +164,34 @@ index e910da61612ded9b45d85baa00dfe34e4fec9332..aae5b2a016e053fb7ad2bfa96c1c0cffvoid WalkPresContexts(Callback&&);void PresContextAffectingFieldChanged();diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp-index 7d9ac5fbccfd345498c5878019d4702bb27532bd..731929432af47d79dc8ad31a0658922ca9f0bb48 100644+index 7d9ac5fbccfd345498c5878019d4702bb27532bd..563c76e5df82a53aa201d7c358d023613253891d 100644--- a/docshell/base/CanonicalBrowsingContext.cpp+++ b/docshell/base/CanonicalBrowsingContext.cpp-@@ -316,6 +316,11 @@ void CanonicalBrowsingContext::ReplacedBy(+@@ -316,6 +316,23 @@ void CanonicalBrowsingContext::ReplacedBy(txn.SetInnerSizeSpoofedForRFP(GetInnerSizeSpoofedForRFP());txn.SetIPAddressSpace(GetIPAddressSpace());txn.SetParentalControlsEnabled(GetParentalControlsEnabled());++ // Playwright: propagate emulation overrides to the replacement context,++ // e.g. on a cross-origin-opener-policy navigation. Touch events override++ // is tracked in https://bugzilla.mozilla.org/show_bug.cgi?id=2014330+ txn.SetPrefersReducedMotionOverride(GetPrefersReducedMotionOverride());+ txn.SetForcedColorsOverride(GetForcedColorsOverride());-+ // Playwright: make sure touch events override is propagated to the nested-+ // browsing context. See https://bugzilla.mozilla.org/show_bug.cgi?id=2014330++ txn.SetPrefersColorSchemeOverride(GetPrefersColorSchemeOverride());++ txn.SetPrefersContrastOverride(GetPrefersContrastOverride());++ txn.SetMediumOverride(GetMediumOverride());++ txn.SetOverrideDPPX(GetOverrideDPPX());+ txn.SetTouchEventsOverrideInternal(GetTouchEventsOverrideInternal());++ txn.SetInRDMPane(GetInRDMPane());++ txn.SetHasScreenAreaOverride(GetHasScreenAreaOverride());++ txn.SetScreenWidthOverride(GetScreenWidthOverride());++ txn.SetScreenHeightOverride(GetScreenHeightOverride());++ txn.SetHasOrientationOverride(GetHasOrientationOverride());++ txn.SetCurrentOrientationType(GetCurrentOrientationType());++ txn.SetCurrentOrientationAngle(GetCurrentOrientationAngle());if (!GetLanguageOverride().IsEmpty()) {// Reapply language override to update the corresponding realm.-@@ -1976,6 +1981,12 @@ void CanonicalBrowsingContext::LoadURI(nsIURI* aURI,+@@ -1976,6 +1993,12 @@ void CanonicalBrowsingContext::LoadURI(nsIURI* aURI,(void)SetIsCaptivePortalTab(true);}@@ -193,21 +205,20 @@ index 7d9ac5fbccfd345498c5878019d4702bb27532bd..731929432af47d79dc8ad31a0658922c}diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp-index 48be2ce822c12f18f0b54daaef7009e549beb280..809c1ca227ccc04826501107346be073546d77fa 100644+index 48be2ce822c12f18f0b54daaef7009e549beb280..62182f1cb148a15879353a57a879a20ce0196d66 100644--- a/docshell/base/nsDocShell.cpp+++ b/docshell/base/nsDocShell.cpp-@@ -356,6 +356,10 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,+@@ -356,6 +356,9 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,mAllowDNSPrefetch(true),mAllowWindowControl(true),mCSSErrorReportingEnabled(false),-+ mFileInputInterceptionEnabled(false),+ mOverrideHasFocus(false),+ mBypassCSPEnabled(false),+ mForceActiveState(false),mAllowAuth(mItemType == typeContent),mAllowKeywordFixup(false),mDisableMetaRefreshWhenInactive(false),-@@ -2981,6 +2985,89 @@ nsDocShell::GetMessageManager(ContentFrameMessageManager** aMessageManager) {+@@ -2981,6 +2984,65 @@ nsDocShell::GetMessageManager(ContentFrameMessageManager** aMessageManager) {return NS_OK;}@@ -268,36 +279,12 @@ index 48be2ce822c12f18f0b54daaef7009e549beb280..809c1ca227ccc04826501107346be073+ return GetRootDocShell()->mOverrideHasFocus;+}+-+NS_IMETHODIMP-+nsDocShell::GetFileInputInterceptionEnabled(bool* aEnabled) {-+ MOZ_ASSERT(aEnabled);-+ *aEnabled = GetRootDocShell()->mFileInputInterceptionEnabled;-+ return NS_OK;-+}-+-+NS_IMETHODIMP-+nsDocShell::SetFileInputInterceptionEnabled(bool aEnabled) {-+ mFileInputInterceptionEnabled = aEnabled;-+ return NS_OK;-+}-+-+bool nsDocShell::IsFileInputInterceptionEnabled() {-+ return GetRootDocShell()->mFileInputInterceptionEnabled;-+}-+-+void nsDocShell::FilePickerShown(mozilla::dom::Element* element) {-+ nsCOMPtr<nsIObserverService> observerService =-+ mozilla::services::GetObserverService();-+ observerService->NotifyObservers(-+ ToSupports(element), "juggler-file-picker-shown", nullptr);-+}-++// =============== Juggler End =======================+NS_IMETHODIMPnsDocShell::GetIsNavigating(bool* aOut) {*aOut = mIsNavigating;-@@ -4720,7 +4807,7 @@ nsDocShell::GetVisibility(bool* aVisibility) {+@@ -4720,7 +4782,7 @@ nsDocShell::GetVisibility(bool* aVisibility) {}void nsDocShell::ActivenessMaybeChanged() {@@ -306,7 +293,7 @@ index 48be2ce822c12f18f0b54daaef7009e549beb280..809c1ca227ccc04826501107346be073if (RefPtr<PresShell> presShell = GetPresShell()) {presShell->ActivenessMaybeChanged();}-@@ -9014,6 +9101,16 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,+@@ -9014,6 +9076,16 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,attrs.SetFirstPartyDomain(isTopLevelDoc, aLoadState->URI());nsCOMPtr<nsIRequest> req;@@ -323,7 +310,7 @@ index 48be2ce822c12f18f0b54daaef7009e549beb280..809c1ca227ccc04826501107346be073rv = DoURILoad(aLoadState, aCacheKey, getter_AddRefs(req));if (NS_SUCCEEDED(rv)) {-@@ -12139,6 +12236,9 @@ class OnLinkClickEvent : public CancelableRunnable, public SupportsWeakPtr {+@@ -12139,6 +12211,9 @@ class OnLinkClickEvent : public CancelableRunnable, public SupportsWeakPtr {mHandler->OnLinkClickSync(mContent, mLoadState, mNoOpenerImplied,mTriggeringPrincipal);}@@ -333,7 +320,7 @@ index 48be2ce822c12f18f0b54daaef7009e549beb280..809c1ca227ccc04826501107346be073return NS_OK;}-@@ -12210,6 +12310,11 @@ nsresult nsDocShell::OnFormSubmit(HTMLFormElement* aForm,+@@ -12210,6 +12285,11 @@ nsresult nsDocShell::OnFormSubmit(HTMLFormElement* aForm,return OnLinkClickSync(aForm, aLoadState, false, aForm->NodePrincipal());}@@ -345,7 +332,7 @@ index 48be2ce822c12f18f0b54daaef7009e549beb280..809c1ca227ccc04826501107346be073auto result = OnLinkClickWithLoadState(aForm, aLoadState, false,aForm->NodePrincipal());if (result.isErr()) {-@@ -12348,6 +12453,8 @@ nsresult nsDocShell::OnLinkClick(+@@ -12348,6 +12428,8 @@ nsresult nsDocShell::OnLinkClick(ownerDoc->GetScriptTrackingFlags());loadState->SetHistoryBehavior(NavigationHistoryBehavior::Auto);@@ -355,24 +342,13 @@ index 48be2ce822c12f18f0b54daaef7009e549beb280..809c1ca227ccc04826501107346be073aTriggeringPrincipal);return result.isErr() ? result.unwrapErr() : NS_OK;diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h-index 0568cbf7f78bc3711275773037fd5ba254f083e7..1140bddd23a988db4f2a403388423eb44f0ab217 100644+index 0568cbf7f78bc3711275773037fd5ba254f083e7..ceba5ebbdf0c900ed0376dd4405f557841a03490 100644--- a/docshell/base/nsDocShell.h+++ b/docshell/base/nsDocShell.h-@@ -16,6 +16,7 @@- #include "mozilla/dom/BrowsingContext.h"- #include "mozilla/dom/NavigationBinding.h"- #include "mozilla/dom/SessionHistoryEntry.h"-+#include "mozilla/dom/Element.h"- #include "mozilla/dom/WindowProxyHolder.h"- #include "nsCOMPtr.h"- #include "nsCharsetSource.h"-@@ -383,6 +384,13 @@ class nsDocShell final : public nsDocLoader,+@@ -383,6 +383,10 @@ class nsDocShell final : public nsDocLoader,void SetWillChangeProcess() { mWillChangeProcess = true; }bool WillChangeProcess() { return mWillChangeProcess; }-+ bool IsFileInputInterceptionEnabled();-+ void FilePickerShown(mozilla::dom::Element* element);-++ bool ShouldOverrideHasFocus();++ bool IsBypassCSPEnabled();@@ -380,7 +356,7 @@ index 0568cbf7f78bc3711275773037fd5ba254f083e7..1140bddd23a988db4f2a403388423eb4// Creates a real network channel (not a DocumentChannel) using the specified// parameters.// Used by nsDocShell when not using DocumentChannel, by DocumentLoadListener-@@ -1000,6 +1008,8 @@ class nsDocShell final : public nsDocLoader,+@@ -1000,6 +1004,8 @@ class nsDocShell final : public nsDocLoader,bool CSSErrorReportingEnabled() const { return mCSSErrorReportingEnabled; }@@ -389,11 +365,10 @@ index 0568cbf7f78bc3711275773037fd5ba254f083e7..1140bddd23a988db4f2a403388423eb4// Handles retrieval of subframe session history for nsDocShell::LoadURI. If a// load is requested in a subframe of the current DocShell, the subframe// loadType may need to reflect the loadType of the parent document, or in-@@ -1332,6 +1342,11 @@ class nsDocShell final : public nsDocLoader,+@@ -1332,6 +1338,10 @@ class nsDocShell final : public nsDocLoader,bool mAllowDNSPrefetch : 1;bool mAllowWindowControl : 1;bool mCSSErrorReportingEnabled : 1;-+ bool mFileInputInterceptionEnabled: 1;+ bool mOverrideHasFocus : 1;+ bool mBypassCSPEnabled : 1;+ bool mForceActiveState : 1;@@ -402,15 +377,13 @@ index 0568cbf7f78bc3711275773037fd5ba254f083e7..1140bddd23a988db4f2a403388423eb4bool mAllowKeywordFixup : 1;bool mDisableMetaRefreshWhenInactive : 1;diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl-index 7cbed1af77c94e97f9f5bda8f6c63c54517300bc..77ff86d6594864c2894d03abdc63378919eb53d8 100644+index 7cbed1af77c94e97f9f5bda8f6c63c54517300bc..5ec074932b2fcb018314df5530e187ce36225202 100644--- a/docshell/base/nsIDocShell.idl+++ b/docshell/base/nsIDocShell.idl-@@ -684,6 +684,14 @@ interface nsIDocShell : nsIDocShellTreeItem+@@ -684,6 +684,12 @@ interface nsIDocShell : nsIDocShellTreeItem*/void synchronizeLayoutHistoryState();-+ attribute boolean fileInputInterceptionEnabled;-++ attribute boolean overrideHasFocus;++ attribute boolean bypassCSPEnabled;@@ -780,32 +753,6 @@ index 51efcf97c062e106575b88232a14f1702470fddf..1c68b997e4efd8896ec182e962c9e085bool canUseCache = false;CachedPositionAndAccuracy lastPosition = gs->GetCachedPosition();if (lastPosition.position) {-diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp-index a516105b516c34eef58a6152c5303548fc64e5ce..5f7b15626a4e2d93a34507fe50f50785aa2c02a7 100644---- a/dom/html/HTMLInputElement.cpp-+++ b/dom/html/HTMLInputElement.cpp-@@ -61,6 +61,7 @@- #include "nsBaseCommandController.h"- #include "nsCRTGlue.h"- #include "nsColorControlFrame.h"-+#include "nsDocShell.h"- #include "nsError.h"- #include "nsFileControlFrame.h"- #include "nsFocusManager.h"-@@ -925,6 +926,13 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) {- return NS_ERROR_FAILURE;- }--+ nsCOMPtr<nsPIDOMWindowOuter> win = doc->GetWindow();-+ nsDocShell* docShell = win ? static_cast<nsDocShell*>(win->GetDocShell()) : nullptr;-+ if (docShell && docShell->IsFileInputInterceptionEnabled()) {-+ docShell->FilePickerShown(this);-+ return NS_OK;-+ }-+- if (IsPickerBlocked(doc)) {- return NS_OK;- }diff --git a/dom/media/systemservices/video_engine/desktop_capture_impl.cc b/dom/media/systemservices/video_engine/desktop_capture_impl.ccindex 9e1086527c293e95f92bd60b7f39de5e955a36ed..7b3b482cf10e87eb8e9f2423aef7b6ac7f8696bc 100644--- a/dom/media/systemservices/video_engine/desktop_capture_impl.ccdiff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.jsonindex f60f94a5cc..71b9e372ab 100644--- a/packages/playwright-core/browsers.json+++ b/packages/playwright-core/browsers.json@@ -17,7 +17,7 @@},{"name": "firefox",- "revision": "1559",+ "revision": "1560","installByDefault": true,"browserVersion": "157.0","title": "Firefox"