Backed out changeset 720b3adb1df5 (bug 1137681) since this need to be out too on a CLOSED TREE
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 02 Dec 2015 11:50:27 +0100
changeset 309204 596f292fe07f07ea313b8f9483e94e21967aeac0
parent 309203 3cd5acd350fbf6aa9b4516f3620a47047dcd0862
child 309205 a0897ec629f90951e685f42eefecea8437481ecb
child 309334 4f1b680a573826f7639dcd53ba0b258b3672152a
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1137681
milestone45.0a1
backs out720b3adb1df5ecef27433c6236936bafb9a8751a
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
Backed out changeset 720b3adb1df5 (bug 1137681) since this need to be out too on a CLOSED TREE
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsIDocShell.idl
docshell/test/browser/browser.ini
docshell/test/browser/browser_ua_emulation.js
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/webidl/Navigator.webidl
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -23,17 +23,16 @@
 #include "mozilla/dom/workers/ServiceWorkerManager.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/StartupTimeline.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/unused.h"
-#include "Navigator.h"
 #include "URIUtils.h"
 
 #include "nsIContent.h"
 #include "nsIContentInlines.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 
@@ -3124,48 +3123,16 @@ NS_IMETHODIMP
 nsDocShell::NameEquals(const char16_t* aName, bool* aResult)
 {
   NS_ENSURE_ARG_POINTER(aName);
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = mName.Equals(aName);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsDocShell::GetCustomUserAgent(nsAString& aCustomUserAgent)
-{
-  aCustomUserAgent = mCustomUserAgent;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDocShell::SetCustomUserAgent(const nsAString& aCustomUserAgent)
-{
-  mCustomUserAgent = aCustomUserAgent;
-  RefPtr<nsGlobalWindow> win = mScriptGlobal ?
-    mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
-  if (win) {
-    ErrorResult ignored;
-    Navigator* navigator = win->GetNavigator(ignored);
-    ignored.SuppressException();
-    if (navigator) {
-      navigator->ClearUserAgentCache();
-    }
-  }
-
-  uint32_t childCount = mChildList.Length();
-  for (uint32_t i = 0; i < childCount; ++i) {
-    nsCOMPtr<nsIDocShell> childShell = do_QueryInterface(ChildAt(i));
-    if (childShell) {
-      childShell->SetCustomUserAgent(aCustomUserAgent);
-    }
-  }
-  return NS_OK;
-}
-
 /* virtual */ int32_t
 nsDocShell::ItemType()
 {
   return mItemType;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetItemType(int32_t* aItemType)
@@ -3283,17 +3250,16 @@ nsDocShell::SetDocLoaderParent(nsDocLoad
   }
 
   // Curse ambiguous nsISupports inheritance!
   nsISupports* parent = GetAsSupports(aParent);
 
   // If parent is another docshell, we inherit all their flags for
   // allowing plugins, scripting etc.
   bool value;
-  nsString customUserAgent;
   nsCOMPtr<nsIDocShell> parentAsDocShell(do_QueryInterface(parent));
   if (parentAsDocShell) {
     if (mAllowPlugins && NS_SUCCEEDED(parentAsDocShell->GetAllowPlugins(&value))) {
       SetAllowPlugins(value);
     }
     if (mAllowJavascript && NS_SUCCEEDED(parentAsDocShell->GetAllowJavascript(&value))) {
       SetAllowJavascript(value);
     }
@@ -3313,20 +3279,16 @@ nsDocShell::SetDocLoaderParent(nsDocLoad
     SetAllowContentRetargeting(mAllowContentRetargeting &&
       parentAsDocShell->GetAllowContentRetargetingOnChildren());
     if (NS_SUCCEEDED(parentAsDocShell->GetIsActive(&value))) {
       SetIsActive(value);
     }
     if (parentAsDocShell->GetIsPrerendered()) {
       SetIsPrerendered(true);
     }
-    if (NS_SUCCEEDED(parentAsDocShell->GetCustomUserAgent(customUserAgent)) &&
-        !customUserAgent.IsEmpty()) {
-      SetCustomUserAgent(customUserAgent);
-    }
     if (NS_FAILED(parentAsDocShell->GetAllowDNSPrefetch(&value))) {
       value = false;
     }
     SetAllowDNSPrefetch(mAllowDNSPrefetch && value);
     value = parentAsDocShell->GetAffectPrivateSessionLifetime();
     SetAffectPrivateSessionLifetime(value);
     uint32_t flags;
     if (NS_SUCCEEDED(parentAsDocShell->GetDefaultLoadFlags(&flags))) {
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -782,17 +782,16 @@ protected:
   FrameType GetInheritedFrameType();
 
   bool HasUnloadedParent();
 
   // Dimensions of the docshell
   nsIntRect mBounds;
   nsString mName;
   nsString mTitle;
-  nsString mCustomUserAgent;
 
   /**
    * Content-Type Hint of the most-recently initiated load. Used for
    * session history entries.
    */
   nsCString mContentTypeHint;
   nsIntPoint mDefaultScrollbarPref; // persistent across doc loads
 
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -38,17 +38,17 @@ interface nsIPrincipal;
 interface nsIWebBrowserPrint;
 interface nsIPrivacyTransitionObserver;
 interface nsIReflowObserver;
 interface nsIScrollObserver;
 interface nsITabParent;
 
 typedef unsigned long nsLoadFlags;
 
-[scriptable, builtinclass, uuid(bc3524bd-023c-4fc8-ace1-472bc999fb12)]
+[scriptable, builtinclass, uuid(63adb599-6dc9-4746-972e-c22e9018020b)]
 interface nsIDocShell : nsIDocShellTreeItem
 {
   /**
    * Loads a given URI.  This will give priority to loading the requested URI
    * in the object implementing	this interface.  If it can't be loaded here
    * however, the URL dispatcher will go through its normal process of content
    * loading.
    *
@@ -233,34 +233,29 @@ interface nsIDocShell : nsIDocShellTreeI
 
   /**
    * This attribute allows chrome to tie in to handle DOM events that may
    * be of interest to chrome.
    */
   attribute nsIDOMEventTarget chromeEventHandler;
 
   /**
-    * This allows chrome to set a custom User agent on a specific docshell
-    */
-  attribute DOMString customUserAgent;
-
-  /**
    * Whether to allow plugin execution
    */
   attribute boolean allowPlugins;
 
   /**
    * Whether to allow Javascript execution
    */
   attribute boolean allowJavascript;
 
   /**
    * Attribute stating if refresh based redirects can be allowed
    */
-  attribute boolean allowMetaRedirects;
+  attribute  boolean allowMetaRedirects;
 
   /**
    * Attribute stating if it should allow subframes (framesets/iframes) or not
    */
   attribute boolean allowSubframes;
 
   /**
    * Attribute stating whether or not images should be loaded.
--- a/docshell/test/browser/browser.ini
+++ b/docshell/test/browser/browser.ini
@@ -79,14 +79,13 @@ skip-if = e10s # Bug 1220927 - Test trie
 [browser_bug852909.js]
 [browser_bug92473.js]
 [browser_uriFixupIntegration.js]
 [browser_loadDisallowInherit.js]
 [browser_loadURI.js]
 [browser_multiple_pushState.js]
 [browser_onbeforeunload_navigation.js]
 [browser_search_notification.js]
-[browser_ua_emulation.js]
 [browser_timelineMarkers-01.js]
 [browser_timelineMarkers-02.js]
 [browser_timelineMarkers-03.js]
 [browser_timelineMarkers-04.js]
 [browser_timelineMarkers-05.js]
deleted file mode 100644
--- a/docshell/test/browser/browser_ua_emulation.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-waitForExplicitFinish();
-
-// Test that the docShell UA emulation works
-var test = Task.async(function*() {
-  yield openUrl("data:text/html;charset=utf-8,<iframe id='test-iframe'></iframe>");
-
-  let docshell = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIWebNavigation)
-                        .QueryInterface(Ci.nsIDocShell);
-  is(docshell.customUserAgent, "", "There should initially be no customUserAgent");
-
-  docshell.customUserAgent = "foo";
-  is(content.navigator.userAgent, "foo", "The user agent should be changed to foo");
-
-  let frameWin = content.document.querySelector("#test-iframe").contentWindow;
-  is(frameWin.navigator.userAgent, "foo", "The UA should be passed on to frames.");
-
-  let newFrame = content.document.createElement("iframe");
-  content.document.body.appendChild(newFrame);
-
-  let newFrameWin = newFrame.contentWindow;
-  is(newFrameWin.navigator.userAgent, "foo", "Newly created frames should use the new UA");
-
-  newFrameWin.location.reload();
-  newFrameWin.addEventListener("load", () => {
-    is(newFrameWin.navigator.userAgent, "foo", "New UA should persist across reloads");
-    gBrowser.removeCurrentTab();
-    finish();
-  });
-});
-
-function openUrl(url) {
-  return new Promise(function(resolve, reject) {
-    window.focus();
-
-    let tab = window.gBrowser.selectedTab = window.gBrowser.addTab(url);
-    let linkedBrowser = tab.linkedBrowser;
-
-    linkedBrowser.addEventListener("load", function onload() {
-      linkedBrowser.removeEventListener("load", onload, true);
-      resolve(tab);
-    }, true);
-  });
-}
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -2770,40 +2770,23 @@ Navigator::AppName(nsAString& aAppName, 
       aAppName = override;
       return;
     }
   }
 
   aAppName.AssignLiteral("Netscape");
 }
 
-void
-Navigator::ClearUserAgentCache()
-{
-  NavigatorBinding::ClearCachedUserAgentValue(this);
-}
-
 nsresult
 Navigator::GetUserAgent(nsPIDOMWindow* aWindow, nsIURI* aURI,
                         bool aIsCallerChrome,
                         nsAString& aUserAgent)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  nsIDocShell* docshell = aWindow->GetDocShell();
-  nsString customUserAgent;
-  if (docshell) {
-    docshell->GetCustomUserAgent(customUserAgent);
-  }
-
-  if (!customUserAgent.IsEmpty()) {
-    aUserAgent = customUserAgent;
-    return NS_OK;
-  }
-
   if (!aIsCallerChrome) {
     const nsAdoptingString& override =
       mozilla::Preferences::GetString("general.useragent.override");
 
     if (override) {
       aUserAgent = override;
       return NS_OK;
     }
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -177,20 +177,16 @@ public:
   static nsresult GetAppVersion(nsAString& aAppVersion,
                                 bool aUsePrefOverriddenValue);
 
   static nsresult GetUserAgent(nsPIDOMWindow* aWindow,
                                nsIURI* aURI,
                                bool aIsCallerChrome,
                                nsAString& aUserAgent);
 
-  // Clears the user agent cache by calling:
-  // NavigatorBinding::ClearCachedUserAgentValue(this);
-  void ClearUserAgentCache();
-
   already_AddRefed<Promise> GetDataStores(const nsAString& aName,
                                           const nsAString& aOwner,
                                           ErrorResult& aRv);
 
   // Feature Detection API
   already_AddRefed<Promise> GetFeature(const nsAString& aName,
                                        ErrorResult& aRv);
 
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -36,17 +36,17 @@ interface NavigatorID {
   [Constant, Cached]
   readonly attribute DOMString appCodeName; // constant "Mozilla"
   [Constant, Cached]
   readonly attribute DOMString appName;
   [Constant, Cached]
   readonly attribute DOMString appVersion;
   [Constant, Cached]
   readonly attribute DOMString platform;
-  [Pure, Cached, Throws=Workers]
+  [Constant, Cached, Throws=Workers]
   readonly attribute DOMString userAgent;
   [Constant, Cached]
   readonly attribute DOMString product; // constant "Gecko"
 
   // Everyone but WebKit/Blink supports this.  See bug 679971.
   [Exposed=Window]
   boolean taintEnabled(); // constant false
 };