Bug 901916 - Make browser_sessionStorage.js more robust. r=smacleod
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Sat, 31 Aug 2013 10:15:57 -0400
changeset 145177 6e30a25722bbdbbf30bbae2bacbb51031ab17513
parent 145176 d6d5d6ef2a9439cee4b05d5af42ddf4a9d577068
child 145178 03a7188329b9ab09ee956bfc853b44a44d9ccfec
push id33179
push userryanvm@gmail.com
push dateSat, 31 Aug 2013 14:17:02 +0000
treeherdermozilla-inbound@914054e19b53 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod
bugs901916
milestone26.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
Bug 901916 - Make browser_sessionStorage.js more robust. r=smacleod
browser/components/sessionstore/test/browser_sessionStorage.js
--- a/browser/components/sessionstore/test/browser_sessionStorage.js
+++ b/browser/components/sessionstore/test/browser_sessionStorage.js
@@ -39,48 +39,55 @@ function waitForStorageChange(aTab) {
 
 function test() {
 
   waitForExplicitFinish();
 
   let tab;
   Task.spawn(function() {
     try {
+      let SESSION_STORAGE_KEY = "SESSION_STORAGE_KEY " + Math.random();
+      let SESSION_STORAGE_VALUE = "SESSION_STORAGE_VALUE " + Math.random();
+      let LOCAL_STORAGE_KEY = "LOCAL_STORAGE_KEY " + Math.random();
+      let LOCAL_STORAGE_VALUE = "LOCAL_STORAGE_VALUE " + Math.random();
+
       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);
+      let storageChangedPromise = waitForStorageChange(tab);
+      win.sessionStorage[SESSION_STORAGE_KEY] = SESSION_STORAGE_VALUE;
+      let storageChanged = yield storageChangedPromise;
       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");
+      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);
+      storageChangedPromise = waitForStorageChange(tab);
+      win.localStorage[LOCAL_STORAGE_KEY] = LOCAL_STORAGE_VALUE;
+      storageChanged = yield storageChangedPromise;
       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");
+      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);
       }