Bug 923315 - Ensure that sessionstore.js writes don't interfere with browser_upgrade_backup.js r=yoric
authorTim Taubert <ttaubert@mozilla.com>
Wed, 04 Jun 2014 08:33:13 +0200
changeset 205794 8a3065aa8100a9bd217eb797b373b9ea4e639577
parent 205793 c9db5a1356bca1660b9a7e4da5d01ee48ec0dc65
child 205795 e5306a36435b0c892aec93e46f41cd5390abe948
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoric
bugs923315
milestone32.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 923315 - Ensure that sessionstore.js writes don't interfere with browser_upgrade_backup.js r=yoric
browser/components/sessionstore/test/browser_upgrade_backup.js
--- a/browser/components/sessionstore/test/browser_upgrade_backup.js
+++ b/browser/components/sessionstore/test/browser_upgrade_backup.js
@@ -11,35 +11,39 @@ function test() {
   Task.spawn(function task() {
     try {
       // Wait until initialization is complete
       yield SessionStore.promiseInitialized;
 
       const PREF_UPGRADE = "browser.sessionstore.upgradeBackup.latestBuildID";
       let buildID = Services.appinfo.platformBuildID;
 
+      // Write state once before starting the test to
+      // ensure sessionstore.js writes won't happen in between.
+      yield forceSaveState();
+
       // Force backup to take place with a file decided by us
       Services.prefs.setCharPref(PREF_UPGRADE, "");
       let contents = "browser_upgrade_backup.js";
       let pathStore = OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.js");
       yield OS.File.writeAtomic(pathStore, contents, { tmpPath: pathStore + ".tmp" });
       yield SessionStore._internal._performUpgradeBackup();
       is(Services.prefs.getCharPref(PREF_UPGRADE), buildID, "upgrade backup should be set (again)");
 
       let pathBackup = OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.bak-" + Services.appinfo.platformBuildID);
       is((yield OS.File.exists(pathBackup)), true, "upgrade backup file has been created");
 
       let data = yield OS.File.read(pathBackup);
-      is(contents, (new TextDecoder()).decode(data), "upgrade backup contains the expected contents");
+      is(new TextDecoder().decode(data), contents, "upgrade backup contains the expected contents");
 
       // Ensure that we don't re-backup by accident
       yield OS.File.writeAtomic(pathStore, "something else entirely", { tmpPath: pathStore + ".tmp" });
       yield SessionStore._internal._performUpgradeBackup();
       data = yield OS.File.read(pathBackup);
-      is(contents, (new TextDecoder()).decode(data), "upgrade backup hasn't changed");
+      is(new TextDecoder().decode(data), contents, "upgrade backup hasn't changed");
 
     } catch (ex) {
       ok(false, "Uncaught error: " + ex + " at " + ex.stack);
     } finally {
       finish();
     }
   });
 }