author | Tim Nguyen <ntim.bugs@gmail.com> |
Wed, 23 Dec 2015 15:04:00 +0100 | |
changeset 277863 | f28fd9bd845c35867d9089ea73be03d10cf68cd8 |
parent 277862 | caa21d8e9e04b25a39df17139abf85366fd1cdf5 |
child 277864 | 075e39cc5f6e423d02aa4ba6613e06e94555f9d2 |
push id | 69628 |
push user | cbook@mozilla.com |
push date | Wed, 30 Dec 2015 11:16:09 +0000 |
treeherder | mozilla-inbound@b493cf33851f [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jryans |
bugs | 828008 |
milestone | 46.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/devtools/server/actors/webbrowser.js +++ b/devtools/server/actors/webbrowser.js @@ -1465,16 +1465,22 @@ TabActor.prototype = { if ((typeof options.serviceWorkersTestingEnabled !== "undefined") && (options.serviceWorkersTestingEnabled !== this._getServiceWorkersTestingEnabled())) { this._setServiceWorkersTestingEnabled( options.serviceWorkersTestingEnabled ); } + if ((typeof options.customUserAgent !== "undefined") && + options.customUserAgent !== this._getCustomUserAgent()) { + this._setCustomUserAgent(options.customUserAgent); + reload = true; + } + // Reload if: // - there's an explicit `performReload` flag and it's true // - there's no `performReload` flag, but it makes sense to do so let hasExplicitReloadFlag = "performReload" in options; if ((hasExplicitReloadFlag && options.performReload) || (!hasExplicitReloadFlag && reload)) { this.onReload(); } @@ -1483,16 +1489,17 @@ TabActor.prototype = { /** * Opposite of the _toggleDevToolsSettings method, that reset document state * when closing the toolbox. */ _restoreDocumentSettings: function () { this._restoreJavascript(); this._setCacheDisabled(false); this._setServiceWorkersTestingEnabled(false); + this._restoreUserAgent(); }, /** * Disable or enable the cache via docShell. */ _setCacheDisabled: function(disabled) { let enable = Ci.nsIRequest.LOAD_NORMAL; let disable = Ci.nsIRequest.LOAD_BYPASS_CACHE | @@ -1566,16 +1573,48 @@ TabActor.prototype = { return null; } let windowUtils = this.window.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindowUtils); return windowUtils.serviceWorkersTestingEnabled; }, + _previousCustomUserAgent: null, + + /** + * Return custom user agent. + */ + _getCustomUserAgent: function() { + if (!this.docShell) { + // The tab is already closed. + return null; + } + return this.docShell.customUserAgent; + }, + + /** + * Sets custom user agent for the current tab + */ + _setCustomUserAgent: function(userAgent) { + if (this._previousCustomUserAgent === null) { + this._previousCustomUserAgent = this.docShell.customUserAgent; + } + this.docShell.customUserAgent = userAgent; + }, + + /** + * Restore the user agent, before the actor modified it + */ + _restoreUserAgent: function() { + if (this._previousCustomUserAgent !== null) { + this.docShell.customUserAgent = this._previousCustomUserAgent; + } + }, + /** * Prepare to enter a nested event loop by disabling debuggee events. */ preNest: function BTA_preNest() { if (!this.window) { // The tab is already closed. return; }