Bug 923315 - Ensure that sessionstore.js writes don't interfere with browser_upgrade_backup.js. r=yoric, a=test-only
authorTim Taubert <ttaubert@mozilla.com>
Wed, 04 Jun 2014 08:33:13 +0200
changeset 200480 1009c320a2b6fa1648a7ddc96f4061b78b7d3f13
parent 200479 fc83bcd4ed6d243c4b1e65ad1800d78dc6b47965
child 200481 082d356f509ce70dfcdc7f1cd3d2d85fec4002df
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoric, test-only
bugs923315
milestone31.0a2
Bug 923315 - Ensure that sessionstore.js writes don't interfere with browser_upgrade_backup.js. r=yoric, a=test-only
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();
     }
   });
 }