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): fix screencast in first window on mac headful (#3826)

Yury Semikhatskyd64d0025a421
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER
index 425c0e77e0..7986d28c50 100644
--- a/browser_patches/firefox/BUILD_NUMBER
+++ b/browser_patches/firefox/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1171
-Changed: [email protected] Wed Sep 9 09:33:56 PDT 2020
+1172
+Changed: [email protected] Wed Sep 9 23:06:13 PDT 2020
diff --git a/browser_patches/firefox/juggler/TargetRegistry.js b/browser_patches/firefox/juggler/TargetRegistry.js
index 620da981c6..d0b06334d9 100644
--- a/browser_patches/firefox/juggler/TargetRegistry.js
+++ b/browser_patches/firefox/juggler/TargetRegistry.js
@@ -196,6 +196,11 @@ class TargetRegistry {
const browserContext = this._userContextIdToBrowserContext.get(userContextId);
if (browserContext && browserContext.defaultViewportSize)
setViewportSizeForBrowser(browserContext.defaultViewportSize, tab.linkedBrowser, window);
+
+ const linkedBrowser = tab.linkedBrowser;
+ const target = this._browserToTarget.get(linkedBrowser);
+ if (target)
+ target._pageWindowReadyCallback();
};
const onTabCloseListener = event => {
@@ -320,6 +325,7 @@ class TargetRegistry {
});
if (browserContext && browserContext.defaultViewportSize)
setViewportSizeForBrowser(browserContext.defaultViewportSize, browser, window);
+ target._pageWindowReadyCallback();
browser.focus();
if (browserContext.settings.timezoneId) {
if (await target.hasFailedToOverrideTimezone())
@@ -376,6 +382,7 @@ class PageTarget {
browserContext._firstPageCallback();
this._registry._browserToTarget.set(this._linkedBrowser, this);
this._registry._browserBrowsingContextToTarget.set(this._linkedBrowser.browsingContext, this);
+ this._pageWindowReady = new Promise(r => this._pageWindowReadyCallback = r);
}
linkedBrowser() {
diff --git a/browser_patches/firefox/juggler/protocol/PageHandler.js b/browser_patches/firefox/juggler/protocol/PageHandler.js
index 78d0a057b9..816ffc2630 100644
--- a/browser_patches/firefox/juggler/protocol/PageHandler.js
+++ b/browser_patches/firefox/juggler/protocol/PageHandler.js
@@ -137,6 +137,10 @@ class PageHandler {
const options = this._pageTarget.browserContext().screencastOptions;
if (options) {
const file = OS.Path.join(options.dir, helper.generateId() + '.webm');
+ // On Mac the window may not yet be visible when TargetCreated and its
+ // NSWindow.windowNumber may be -1, so we wait until the window is known
+ // to be initialized and visible.
+ await this._pageTarget._pageWindowReady;
await this.startVideoRecording(Object.assign({file}, options));
}
}