Backed out changeset 4eb7a0f560da (bug 867143)
authorEd Morley <emorley@mozilla.com>
Wed, 24 Jul 2013 13:32:16 +0100
changeset 152068 3352acd5e5504f305a52b64bef472619e1473eb3
parent 152067 206532bc78820d920b65754f7cc90a1011f54b3f
child 152069 8a3b8fe776426822278b565db53087b9ef731ba8
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs867143
milestone25.0a1
backs out4eb7a0f560da3c4272b4c14477752a961ee72239
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 4eb7a0f560da (bug 867143)
browser/components/sessionstore/test/Makefile.in
browser/components/sessionstore/test/browser_capabilities.js
browser/components/sessionstore/test/browser_sessionStorage.js
browser/components/sessionstore/test/head.js
--- a/browser/components/sessionstore/test/Makefile.in
+++ b/browser/components/sessionstore/test/Makefile.in
@@ -22,17 +22,16 @@ MOCHITEST_BROWSER_FILES = \
 	browser_dying_cache.js \
 	browser_form_restore_events.js \
 	browser_form_restore_events_sample.html \
 	browser_formdata_format.js \
 	browser_formdata_format_sample.html \
 	browser_input.js \
 	browser_input_sample.html \
 	browser_pageshow.js \
-	browser_sessionStorage.js \
         browser_upgrade_backup.js \
 	browser_windowRestore_perwindowpb.js \
 	browser_248970_b_perwindowpb.js \
 	browser_248970_b_sample.html \
 	browser_339445.js \
 	browser_339445_sample.html \
 	browser_345898.js \
 	browser_346337.js \
--- a/browser/components/sessionstore/test/browser_capabilities.js
+++ b/browser/components/sessionstore/test/browser_capabilities.js
@@ -25,21 +25,16 @@ function runTests() {
   let state = JSON.parse(ss.getTabState(tab));
   ok(!("disallow" in state), "everything allowed by default");
   ok(flags.every(f => docShell[f]), "all flags set to true");
 
   // Flip a couple of allow* flags.
   docShell.allowImages = false;
   docShell.allowMetaRedirects = false;
 
-  // Now reload the document to ensure that these capabilities
-  // are taken into account
-  browser.reload();
-  yield whenBrowserLoaded(browser);
-
   // Check that we correctly save disallowed features.
   let disallowedState = JSON.parse(ss.getTabState(tab));
   let disallow = new Set(disallowedState.disallow.split(","));
   ok(disallow.has("Images"), "images not allowed");
   ok(disallow.has("MetaRedirects"), "meta redirects not allowed");
   is(disallow.size, 2, "two capabilities disallowed");
 
   // Reuse the tab to restore a new, clean state into it.
@@ -52,17 +47,17 @@ function runTests() {
   ok(flags.every(f => docShell[f]), "all flags set to true");
 
   // Restore the state with disallowed features.
   ss.setTabState(tab, JSON.stringify(disallowedState));
   yield waitForLoad(browser);
 
   // Check that docShell flags are set.
   ok(!docShell.allowImages, "images not allowed");
-  ok(!docShell.allowMetaRedirects, "meta redirects not allowed");
+  ok(!docShell.allowMetaRedirects, "meta redirects not allowed")
 
   // Check that we correctly restored features as disabled.
   state = JSON.parse(ss.getTabState(tab));
   disallow = new Set(state.disallow.split(","));
   ok(disallow.has("Images"), "images not allowed anymore");
   ok(disallow.has("MetaRedirects"), "meta redirects not allowed anymore");
   is(disallow.size, 2, "two capabilities disallowed");
 
deleted file mode 100644
--- a/browser/components/sessionstore/test/browser_sessionStorage.js
+++ /dev/null
@@ -1,91 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-let Scope = {};
-Cu.import("resource://gre/modules/Task.jsm", Scope);
-Cu.import("resource://gre/modules/Promise.jsm", Scope);
-let {Task, Promise} = Scope;
-
-function promiseBrowserLoaded(aBrowser) {
-  let deferred = Promise.defer();
-  whenBrowserLoaded(aBrowser, () => deferred.resolve());
-  return deferred.promise;
-}
-
-function forceWriteState() {
-  let deferred = Promise.defer();
-  const PREF = "browser.sessionstore.interval";
-  const TOPIC = "sessionstore-state-write";
-
-  Services.obs.addObserver(function observe() {
-    Services.obs.removeObserver(observe, TOPIC);
-    Services.prefs.clearUserPref(PREF);
-    deferred.resolve();
-  }, TOPIC, false);
-
-  Services.prefs.setIntPref(PREF, 0);
-  return deferred.promise;
-}
-
-function waitForStorageChange(aTab) {
-  let deferred = Promise.defer();
-  waitForContentMessage(aTab.linkedBrowser,
-    "SessionStore:MozStorageChanged",
-    1000,
-    deferred.resolve);
-  return deferred.promise;
-}
-
-function test() {
-
-  waitForExplicitFinish();
-
-  let tab;
-  Task.spawn(function() {
-    try {
-      tab = gBrowser.addTab("http://example.com");
-      // about:home supports sessionStorage and localStorage
-
-      let win = tab.linkedBrowser.contentWindow;
-
-      // Flush loading and next save, call getBrowserState()
-      // a few times to ensure that everything is cached.
-      yield promiseBrowserLoaded(tab.linkedBrowser);
-      yield forceWriteState();
-      info("Calling getBrowserState() to populate cache");
-      ss.getBrowserState();
-
-      info("Change sessionStorage, ensure that state is saved");
-      win.sessionStorage["SESSION_STORAGE_KEY"] = "SESSION_STORAGE_VALUE";
-      let storageChanged = yield waitForStorageChange(tab);
-      ok(storageChanged, "Changing sessionStorage triggered the right message");
-      yield forceWriteState();
-
-      let state = ss.getBrowserState();
-      ok(state.indexOf("SESSION_STORAGE_KEY") != -1, "Key appears in state");
-      ok(state.indexOf("SESSION_STORAGE_VALUE") != -1, "Value appears in state");
-
-
-      info("Change localStorage, ensure that state is not saved");
-      win.localStorage["LOCAL_STORAGE_KEY"] = "LOCAL_STORAGE_VALUE";
-      storageChanged = yield waitForStorageChange(tab);
-      ok(!storageChanged, "Changing localStorage did not trigger a message");
-      yield forceWriteState();
-
-      state = ss.getBrowserState();
-      ok(state.indexOf("LOCAL_STORAGE_KEY") == -1, "Key does not appear in state");
-      ok(state.indexOf("LOCAL_STORAGE_VALUE") == -1, "Value does not appear in state");
-    } catch (ex) {
-      ok(false, ex);
-      info(ex.stack);
-    } finally {
-      // clean up
-      if (tab) {
-        gBrowser.removeTab(tab);
-      }
-
-      executeSoon(finish);
-    }
-  });
-}
--- a/browser/components/sessionstore/test/head.js
+++ b/browser/components/sessionstore/test/head.js
@@ -151,100 +151,53 @@ function waitForTabState(aTab, aState, a
   registerCleanupFunction(function() {
     if (listening) {
       aTab.removeEventListener("SSTabRestored", onSSTabRestored, false);
     }
   });
   ss.setTabState(aTab, JSON.stringify(aState));
 }
 
-/**
- * Wait for a content -> chrome message.
- */
-function waitForContentMessage(aBrowser, aTopic, aTimeout, aCallback) {
-  let mm = aBrowser.messageManager;
+// waitForSaveState waits for a state write but not necessarily for the state to
+// turn dirty.
+function waitForSaveState(aSaveStateCallback) {
   let observing = false;
+  let topic = "sessionstore-state-write";
+
+  let sessionSaveTimeout = 1000 +
+    Services.prefs.getIntPref("browser.sessionstore.interval");
+
   function removeObserver() {
     if (!observing)
       return;
-    mm.removeMessageListener(aTopic, observer);
+    Services.obs.removeObserver(observer, topic);
     observing = false;
   }
 
   let timeout = setTimeout(function () {
     removeObserver();
-    aCallback(false);
-  }, aTimeout);
+    aSaveStateCallback();
+  }, sessionSaveTimeout);
 
   function observer(aSubject, aTopic, aData) {
     removeObserver();
     timeout = clearTimeout(timeout);
-    executeSoon(() => aCallback(true));
+    executeSoon(aSaveStateCallback);
   }
 
   registerCleanupFunction(function() {
     removeObserver();
     if (timeout) {
       clearTimeout(timeout);
     }
   });
 
   observing = true;
-  mm.addMessageListener(aTopic, observer);
-}
-
-function waitForTopic(aTopic, aTimeout, aCallback) {
-  let observing = false;
-  function removeObserver() {
-    if (!observing)
-      return;
-    Services.obs.removeObserver(observer, aTopic);
-    observing = false;
-  }
-
-  let timeout = setTimeout(function () {
-    removeObserver();
-    aCallback(false);
-  }, aTimeout);
-
-  function observer(aSubject, aTopic, aData) {
-    removeObserver();
-    timeout = clearTimeout(timeout);
-    executeSoon(() => aCallback(true));
-  }
-
-  registerCleanupFunction(function() {
-    removeObserver();
-    if (timeout) {
-      clearTimeout(timeout);
-    }
-  });
-
-  observing = true;
-  Services.obs.addObserver(observer, aTopic, false);
-}
-
-/**
- * Wait until session restore has finished collecting its data and is
- * getting ready to write that data ("sessionstore-state-write").
- *
- * This function is meant to be called immediately after the code
- * that will trigger the saving.
- *
- * Note that this does not wait for the disk write to be complete.
- *
- * @param {function} aCallback If sessionstore-state-write is sent
- * within buffering interval + 100 ms, the callback is passed |true|,
- * otherwise, it is passed |false|.
- */
-function waitForSaveState(aCallback) {
-  let timeout = 100 +
-    Services.prefs.getIntPref("browser.sessionstore.interval");
-  return waitForTopic("sessionstore-state-write", timeout, aCallback);
-}
+  Services.obs.addObserver(observer, topic, false);
+};
 
 function whenBrowserLoaded(aBrowser, aCallback = next) {
   aBrowser.addEventListener("load", function onLoad() {
     aBrowser.removeEventListener("load", onLoad, true);
     executeSoon(aCallback);
   }, true);
 }