Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(firefox): roll to r1562 (#43446)

microsoft-playwright-automation[bot]ac22e99d9829
diff --git a/browser_patches/firefox/patches/bootstrap.diff b/browser_patches/firefox/patches/bootstrap.diff
index 9e3b16c757..562ad8ac95 100644
--- a/browser_patches/firefox/patches/bootstrap.diff
+++ b/browser_patches/firefox/patches/bootstrap.diff
@@ -205,7 +205,7 @@ index 7d9ac5fbccfd345498c5878019d4702bb27532bd..563c76e5df82a53aa201d7c358d02361
}
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
-index 48be2ce822c12f18f0b54daaef7009e549beb280..62182f1cb148a15879353a57a879a20ce0196d66 100644
+index 48be2ce822c12f18f0b54daaef7009e549beb280..2178ccc2523a7f9101742664a13da458c3178b05 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -356,6 +356,9 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
@@ -275,8 +275,8 @@ index 48be2ce822c12f18f0b54daaef7009e549beb280..62182f1cb148a15879353a57a879a20c
+ return NS_OK;
+}
+
-+bool nsDocShell::ShouldOverrideHasFocus() {
-+ return GetRootDocShell()->mOverrideHasFocus;
++bool nsDocShell::ShouldOverrideHasFocus() const {
++ return mOverrideHasFocus;
+}
+
+// =============== Juggler End =======================
@@ -342,14 +342,14 @@ index 48be2ce822c12f18f0b54daaef7009e549beb280..62182f1cb148a15879353a57a879a20c
aTriggeringPrincipal);
return result.isErr() ? result.unwrapErr() : NS_OK;
diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h
-index 0568cbf7f78bc3711275773037fd5ba254f083e7..ceba5ebbdf0c900ed0376dd4405f557841a03490 100644
+index 0568cbf7f78bc3711275773037fd5ba254f083e7..4c92ed2d83938507f94c04ed1a0f345d29fec364 100644
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -383,6 +383,10 @@ class nsDocShell final : public nsDocLoader,
void SetWillChangeProcess() { mWillChangeProcess = true; }
bool WillChangeProcess() { return mWillChangeProcess; }
-+ bool ShouldOverrideHasFocus();
++ bool ShouldOverrideHasFocus() const;
+
+ bool IsBypassCSPEnabled();
+
@@ -394,7 +394,7 @@ index 7cbed1af77c94e97f9f5bda8f6c63c54517300bc..5ec074932b2fcb018314df5530e187ce
* This attempts to save any applicable layout history state (like
* scroll position) in the nsISHEntry. This is normally done
diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp
-index 5e997a5de5592ab164f61d6ebeb37febd29bbff2..94912990696b922cbc12b56f61b905cb572044cb 100644
+index 5e997a5de5592ab164f61d6ebeb37febd29bbff2..060e707c7715db2a57ea721f58c41e2df7125d77 100644
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -3851,6 +3851,9 @@ void Document::SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages) {
@@ -407,28 +407,27 @@ index 5e997a5de5592ab164f61d6ebeb37febd29bbff2..94912990696b922cbc12b56f61b905cb
nsresult rv = NS_OK;
if (!aSpeculative) {
nsIContentSecurityPolicy* csp = PolicyContainer::GetCSP(mPolicyContainer);
-@@ -3948,6 +3951,11 @@ nsresult Document::InitCSP(nsIChannel* aChannel) {
- MOZ_ASSERT(mPolicyContainer,
- "Policy container must be initialized before CSP!");
+@@ -3987,6 +3990,14 @@ nsresult Document::InitCSP(nsIChannel* aChannel) {
+ return rv;
+ }
++ // Juggler: keep the empty CSP object, since callers rely on every document
++ // having one (e.g. PerformTrustedTypesPreNavigationCheck), but never apply
++ // any policies to it.
+ nsCOMPtr<nsIDocShell> shell(mDocumentContainer);
+ if (shell && nsDocShell::Cast(shell)->IsBypassCSPEnabled()) {
+ return NS_OK;
+ }
+
- // If this is a data document - no need to set CSP.
- if (mLoadedAsData) {
- return NS_OK;
-@@ -4930,6 +4938,14 @@ bool Document::HasFocus(ErrorResult& rv) const {
+ nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
+ if ((principal->IsSystemPrincipal() ||
+ (mDocumentURI && mDocumentURI->SchemeIs("chrome"))) &&
+@@ -4930,6 +4941,10 @@ bool Document::HasFocus(ErrorResult& rv) const {
return false;
}
+ if (IsActive() && mDocumentContainer->ShouldOverrideHasFocus()) {
-+ // Emulate the window being active, but keep reporting which frame has focus.
-+ if (bc->IsTop()) {
-+ return true;
-+ }
-+ return fm->IsSameOrAncestor(bc, fm->GetFocusedBrowsingContext());
++ return true;
+ }
+
if (!fm->IsInActiveWindow(bc)) {
diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.json
index 67277495fd..7ee6f477c2 100644
--- a/packages/playwright-core/browsers.json
+++ b/packages/playwright-core/browsers.json
@@ -17,7 +17,7 @@
},
{
"name": "firefox",
- "revision": "1560",
+ "revision": "1562",
"installByDefault": true,
"browserVersion": "157.0",
"title": "Firefox"