Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions browser_patches/firefox/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1176
Changed: [email protected] Wed Sep 30 03:06:09 MDT 2020
1177
Changed: [email protected] Wed Sep 30 03:11:29 MDT 2020
12 changes: 12 additions & 0 deletions browser_patches/firefox/juggler/TargetRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class TargetRegistry {
if (!browserContext)
throw new Error(`Internal error: cannot find context for userContextId=${userContextId}`);
const target = new PageTarget(this, window, tab, browserContext, openerTarget);
target.updateUserAgent();
if (!hasExplicitSize)
target.updateViewportSize();
};
Expand Down Expand Up @@ -393,6 +394,10 @@ class PageTarget {
return this._browserContext;
}

updateUserAgent() {
this._linkedBrowser.browsingContext.customUserAgent = this._browserContext.defaultUserAgent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does null mean no override here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly

}

async updateViewportSize() {
// Viewport size is defined by three arguments:
// 1. default size. Could be explicit if set as part of `window.open` call, e.g.
Expand Down Expand Up @@ -513,6 +518,7 @@ class BrowserContext {
this.ignoreHTTPSErrors = undefined;
this.downloadOptions = undefined;
this.defaultViewportSize = undefined;
this.defaultUserAgent = null;
this.screencastOptions = undefined;
this.scriptsToEvaluateOnNewDocument = [];
this.bindings = [];
Expand Down Expand Up @@ -559,6 +565,12 @@ class BrowserContext {
}
}

async setDefaultUserAgent(userAgent) {
this.defaultUserAgent = userAgent;
for (const page of this.pages)
page.updateUserAgent();
}

async setDefaultViewport(viewport) {
this.defaultViewportSize = viewport ? viewport.viewportSize : undefined;
const promises = Array.from(this.pages).map(page => page.updateViewportSize());
Expand Down
4 changes: 0 additions & 4 deletions browser_patches/firefox/juggler/content/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ const applySetting = {
Ci.nsIDocShell.ONLINE_OVERRIDE_ONLINE : Ci.nsIDocShell.ONLINE_OVERRIDE_OFFLINE;
},

userAgent: (userAgent) => {
docShell.browsingContext.customUserAgent = userAgent;
},

bypassCSP: (bypassCSP) => {
docShell.bypassCSPEnabled = bypassCSP;
},
Expand Down
2 changes: 1 addition & 1 deletion browser_patches/firefox/juggler/protocol/BrowserHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class BrowserHandler {
}

async setUserAgentOverride({browserContextId, userAgent}) {
await this._targetRegistry.browserContextForId(browserContextId).applySetting('userAgent', nullToUndefined(userAgent));
await this._targetRegistry.browserContextForId(browserContextId).setDefaultUserAgent(userAgent);
}

async setBypassCSP({browserContextId, bypassCSP}) {
Expand Down