Skip to content

Commit d64d002

Browse files
authored
browser(firefox): fix screencast in first window on mac headful (#3826)
* browser(firefox): fix screencast in first window on mac headful * Revert only
1 parent 559f30d commit d64d002

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1171
2-
Changed: [email protected] Wed Sep 9 09:33:56 PDT 2020
1+
1172
2+
Changed: [email protected] Wed Sep 9 23:06:13 PDT 2020

browser_patches/firefox/juggler/TargetRegistry.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ class TargetRegistry {
196196
const browserContext = this._userContextIdToBrowserContext.get(userContextId);
197197
if (browserContext && browserContext.defaultViewportSize)
198198
setViewportSizeForBrowser(browserContext.defaultViewportSize, tab.linkedBrowser, window);
199+
200+
const linkedBrowser = tab.linkedBrowser;
201+
const target = this._browserToTarget.get(linkedBrowser);
202+
if (target)
203+
target._pageWindowReadyCallback();
199204
};
200205

201206
const onTabCloseListener = event => {
@@ -320,6 +325,7 @@ class TargetRegistry {
320325
});
321326
if (browserContext && browserContext.defaultViewportSize)
322327
setViewportSizeForBrowser(browserContext.defaultViewportSize, browser, window);
328+
target._pageWindowReadyCallback();
323329
browser.focus();
324330
if (browserContext.settings.timezoneId) {
325331
if (await target.hasFailedToOverrideTimezone())
@@ -376,6 +382,7 @@ class PageTarget {
376382
browserContext._firstPageCallback();
377383
this._registry._browserToTarget.set(this._linkedBrowser, this);
378384
this._registry._browserBrowsingContextToTarget.set(this._linkedBrowser.browsingContext, this);
385+
this._pageWindowReady = new Promise(r => this._pageWindowReadyCallback = r);
379386
}
380387

381388
linkedBrowser() {

browser_patches/firefox/juggler/protocol/PageHandler.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ class PageHandler {
137137
const options = this._pageTarget.browserContext().screencastOptions;
138138
if (options) {
139139
const file = OS.Path.join(options.dir, helper.generateId() + '.webm');
140+
// On Mac the window may not yet be visible when TargetCreated and its
141+
// NSWindow.windowNumber may be -1, so we wait until the window is known
142+
// to be initialized and visible.
143+
await this._pageTarget._pageWindowReady;
140144
await this.startVideoRecording(Object.assign({file}, options));
141145
}
142146
}

0 commit comments

Comments
 (0)