Skip to content

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

browser(firefox): implement Page.bringToFront (#3051)

Pavel Feldman726f636b5c40
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER
index 0b2b587ca7..a2b7490c26 100644
--- a/browser_patches/firefox/BUILD_NUMBER
+++ b/browser_patches/firefox/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1133
-Changed: [email protected] Mon Jul 20 14:11:12 PDT 2020
+1134
+Changed: [email protected] Mon Jul 20 15:11:16 PDT 2020
diff --git a/browser_patches/firefox/juggler/protocol/PageHandler.js b/browser_patches/firefox/juggler/protocol/PageHandler.js
index 872d324b3e..4deb05fba6 100644
--- a/browser_patches/firefox/juggler/protocol/PageHandler.js
+++ b/browser_patches/firefox/juggler/protocol/PageHandler.js
@@ -179,6 +179,10 @@ class PageHandler {
return await this._contentPage.send('setEmulatedMedia', options);
}
+ async bringToFront(options) {
+ this._pageTarget._window.focus();
+ }
+
async setCacheDisabled(options) {
return await this._contentPage.send('setCacheDisabled', options);
}
diff --git a/browser_patches/firefox/juggler/protocol/Protocol.js b/browser_patches/firefox/juggler/protocol/Protocol.js
index 792f28598d..23e47e7340 100644
--- a/browser_patches/firefox/juggler/protocol/Protocol.js
+++ b/browser_patches/firefox/juggler/protocol/Protocol.js
@@ -654,6 +654,10 @@ const Page = {
viewportSize: t.Nullable(pageTypes.Size),
},
},
+ 'bringToFront': {
+ params: {
+ },
+ },
'setEmulatedMedia': {
params: {
type: t.Optional(t.Enum(['screen', 'print', ''])),
diff --git a/browser_patches/firefox/patches/bootstrap.diff b/browser_patches/firefox/patches/bootstrap.diff
index b1f7e7b8ec..26f9a4e895 100644
--- a/browser_patches/firefox/patches/bootstrap.diff
+++ b/browser_patches/firefox/patches/bootstrap.diff
@@ -651,6 +651,21 @@ index e268e2bbe8add1b43f6e4d6507cc7810d707a344..a34a7a292a02ea8d94042475a43ae3a0
dom::MediaCapabilities* MediaCapabilities();
dom::MediaSession* MediaSession();
+diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp
+index 7fd3b0069dfd8159818c0f80d0c1cee901ce074a..77f08fb399145302677d36003884e9d775cc4e44 100644
+--- a/dom/base/nsFocusManager.cpp
++++ b/dom/base/nsFocusManager.cpp
+@@ -2649,7 +2649,9 @@ void nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow,
+ }
+ }
+
+- if (sTestMode) {
++ // In Playwright, we still want to execte the embedder functions
++ // to actually show / focus windows.
++ if (false && sTestMode) {
+ // In test mode, emulate raising the window. WindowRaised takes
+ // care of lowering the present active window. This happens in
+ // a separate runnable to avoid touching multiple windows in
diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp
index da9d56e843a2c762dc7d5527712cdd3d30418f7f..aa3d2d6022b60ac3a263c2d1df4eb12714d8e728 100644
--- a/dom/base/nsGlobalWindowOuter.cpp