Backed out changeset fc9cae9a0f60 (bug 1180495) for browser_purgehistory_clears_sh.js failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 05 Aug 2015 14:54:49 -0400
changeset 288058 0f956bd768d7584f6fdee77936ec069b573ddfbe
parent 288057 e72e9e0222d830f7b0672b39fd749cfd1b5c55c9
child 288059 a26c0ec8e22062f8a2464781a17da75c09070831
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1180495
milestone42.0a1
backs outfc9cae9a0f604881f1e6157dc72c250870e13a01
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 fc9cae9a0f60 (bug 1180495) for browser_purgehistory_clears_sh.js failures. CLOSED TREE
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_purgehistory_clears_sh.js
toolkit/content/browser-content.js
toolkit/content/widgets/browser.xml
toolkit/content/widgets/remote-browser.xml
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -348,17 +348,16 @@ skip-if = buildapp == 'mulet'
 [browser_popup_blocker.js]
 skip-if = (os == 'linux') || (e10s && debug) # Frequent bug 1081925 and bug 1125520 failures
 [browser_printpreview.js]
 skip-if = buildapp == 'mulet' || e10s # Bug 1101973 - breaks the next test in e10s, and may be responsible for later timeout after logging "Error: Channel closing: too late to send/recv, messages will be lost"
 [browser_private_browsing_window.js]
 skip-if = buildapp == 'mulet'
 [browser_private_no_prompt.js]
 skip-if = buildapp == 'mulet'
-[browser_purgehistory_clears_sh.js]
 [browser_PageMetaData_pushstate.js]
 [browser_relatedTabs.js]
 [browser_remoteTroubleshoot.js]
 support-files =
   test_remoteTroubleshoot.html
 [browser_remoteWebNavigation_postdata.js]
 [browser_removeTabsToTheEnd.js]
 [browser_removeUnsafeProtocolsFromURLBarPaste.js]
deleted file mode 100644
--- a/browser/base/content/test/general/browser_purgehistory_clears_sh.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-const url = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
-
-add_task(function* purgeHistoryTest() {
-  let tab = yield BrowserTestUtils.withNewTab({
-    gBrowser,
-    url,
-  }, function* purgeHistoryTestInner(browser) {
-    let backButton = browser.ownerDocument.getElementById("Browser:Back");
-    let forwardButton = browser.ownerDocument.getElementById("Browser:Forward");
-
-    ok(!browser.webNavigation.canGoBack,
-       "Initial value for webNavigation.canGoBack");
-    ok(!browser.webNavigation.canGoForward,
-       "Initial value for webNavigation.canGoBack");
-    ok(backButton.hasAttribute("disabled"), "Back button is disabled");
-    ok(forwardButton.hasAttribute("disabled"), "Forward button is disabled");
-
-    let pushState = ContentTask.spawn(browser, null, function*() {
-      let startHistory = content.history.length;
-      content.history.pushState({}, "");
-      content.history.pushState({}, "");
-      content.history.back();
-      let newHistory = content.history.length;
-      return [startHistory, newHistory];
-    });
-
-    let [startHistory, newHistory] = yield pushState;
-
-    is(startHistory, 1, "Initial SHistory size");
-    is(newHistory, 3, "New SHistory size");
-
-    ok(browser.webNavigation.canGoBack, true,
-       "New value for webNavigation.canGoBack");
-    ok(browser.webNavigation.canGoForward, true,
-       "New value for webNavigation.canGoForward");
-    ok(!backButton.hasAttribute("disabled"), "Back button was enabled");
-    ok(!forwardButton.hasAttribute("disabled"), "Forward button was enabled");
-
-
-    let tmp = {};
-    Cc["@mozilla.org/moz/jssubscript-loader;1"]
-      .getService(Ci.mozIJSSubScriptLoader)
-      .loadSubScript("chrome://browser/content/sanitize.js", tmp);
-
-    let {Sanitizer} = tmp;
-    let sanitizer = new Sanitizer();
-
-    yield sanitizer.sanitize(["history"]);
-
-    let historyAfterPurge = yield ContentTask.spawn(browser, null, function*() {
-      return content.history.length;
-    });
-
-    is(historyAfterPurge, 1, "SHistory correctly cleared");
-
-    ok(!browser.webNavigation.canGoBack,
-       "webNavigation.canGoBack correctly cleared");
-    ok(!browser.webNavigation.canGoForward,
-       "webNavigation.canGoForward correctly cleared");
-    ok(backButton.hasAttribute("disabled"), "Back button was disabled");
-    ok(forwardButton.hasAttribute("disabled"), "Forward button was disabled");
-  });
-});
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -719,32 +719,8 @@ let AudioPlaybackListener = {
     if (msg.name == "AudioPlaybackMute") {
       let utils = global.content.QueryInterface(Ci.nsIInterfaceRequestor)
                                 .getInterface(Ci.nsIDOMWindowUtils);
       utils.audioMuted = msg.data.type === "mute";
     }
   },
 };
 AudioPlaybackListener.init();
-
-addMessageListener("Browser:PurgeSessionHistory", function BrowserPurgeHistory() {
-  let sessionHistory = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
-  if (!sessionHistory) {
-    return;
-  }
-
-  // place the entry at current index at the end of the history list, so it won't get removed
-  if (sessionHistory.index < sessionHistory.count - 1) {
-    let indexEntry = sessionHistory.getEntryAtIndex(sessionHistory.index, false);
-    sessionHistory.QueryInterface(Components.interfaces.nsISHistoryInternal);
-    indexEntry.QueryInterface(Components.interfaces.nsISHEntry);
-    sessionHistory.addEntry(indexEntry, true);
-  }
-
-  let purge = sessionHistory.count;
-  if (global.content.location.href != "about:blank") {
-    --purge; // Don't remove the page the user's staring at from shistory
-  }
-
-  if (purge > 0) {
-    sessionHistory.PurgeHistory(purge);
-  }
-});
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -816,17 +816,17 @@
       <field name="mDestroyed">false</field>
 
       <constructor>
         <![CDATA[
           try {
             // |webNavigation.sessionHistory| will have been set by the frame
             // loader when creating the docShell as long as this xul:browser
             // doesn't have the 'disablehistory' attribute set.
-            if (!this.hasAttribute("disablehistory")) {
+            if (this.docShell && this.webNavigation.sessionHistory) {
               var os = Components.classes["@mozilla.org/observer-service;1"]
                                  .getService(Components.interfaces.nsIObserverService);
               os.addObserver(this, "browser:purge-session-history", false);
 
               // enable global history if we weren't told otherwise
               if (!this.hasAttribute("disableglobalhistory") && !this.isRemoteBrowser) {
                 try {
                   this.docShell.useGlobalHistory = true;
@@ -874,17 +874,17 @@
            we are removed from a tabbrowser. This will be explicitly called by tabbrowser -->
       <method name="destroy">
         <body>
           <![CDATA[
           if (this.mDestroyed)
             return;
           this.mDestroyed = true;
 
-          if (!this.hasAttribute("disablehistory")) {
+          if (this.docShell && this.webNavigation.sessionHistory) {
             var os = Components.classes["@mozilla.org/observer-service;1"]
                                .getService(Components.interfaces.nsIObserverService);
             try {
               os.removeObserver(this, "browser:purge-session-history");
             } catch (ex) {
               // It's not clear why this sometimes throws an exception.
             }
           }
@@ -964,28 +964,33 @@
       </method>
 
       <method name="observe">
         <parameter name="aSubject"/>
         <parameter name="aTopic"/>
         <parameter name="aState"/>
         <body>
           <![CDATA[
-            if (aTopic != "browser:purge-session-history")
+            if (aTopic != "browser:purge-session-history" || !this.sessionHistory)
               return;
 
-            this.purgeSessionHistory();
-          ]]>
-        </body>
-      </method>
+            // place the entry at current index at the end of the history list, so it won't get removed
+            if (this.sessionHistory.index < this.sessionHistory.count - 1) {
+              var indexEntry = this.sessionHistory.getEntryAtIndex(this.sessionHistory.index, false);
+              this.sessionHistory.QueryInterface(Components.interfaces.nsISHistoryInternal);
+              indexEntry.QueryInterface(Components.interfaces.nsISHEntry);
+              this.sessionHistory.addEntry(indexEntry, true);
+            }
 
-      <method name="purgeSessionHistory">
-        <body>
-          <![CDATA[
-            this.messageManager.sendAsyncMessage("Browser:PurgeSessionHistory");
+            var purge = this.sessionHistory.count;
+            if (this.currentURI != "about:blank")
+              --purge; // Don't remove the page the user's staring at from shistory
+
+            if (purge > 0)
+              this.sessionHistory.PurgeHistory(purge);
           ]]>
         </body>
       </method>
 
       <field name="_AUTOSCROLL_SNAP">10</field>
       <field name="_scrolling">false</field>
       <field name="_startX">null</field>
       <field name="_startY">null</field>
--- a/toolkit/content/widgets/remote-browser.xml
+++ b/toolkit/content/widgets/remote-browser.xml
@@ -384,22 +384,13 @@
           if (this._controller) {
             this._controller.enableDisableCommands(aAction,
                                                    aEnabledLength, aEnabledCommands,
                                                    aDisabledLength, aDisabledCommands);
           }
         </body>
       </method>
 
-      <method name="purgeSessionHistory">
-        <body>
-          <![CDATA[
-            this.messageManager.sendAsyncMessage("Browser:PurgeSessionHistory");
-            this.webNavigation.canGoBack = false;
-            this.webNavigation.canGoForward = false;
-          ]]>
-        </body>
-      </method>
     </implementation>
 
   </binding>
 
 </bindings>