summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/unit/head.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/sessionstore/test/unit/head.js')
-rw-r--r--browser/components/sessionstore/test/unit/head.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/unit/head.js b/browser/components/sessionstore/test/unit/head.js
new file mode 100644
index 0000000000..ad8427d5bd
--- /dev/null
+++ b/browser/components/sessionstore/test/unit/head.js
@@ -0,0 +1,40 @@
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
+ChromeUtils.defineModuleGetter(
+ this,
+ "SessionStartup",
+ "resource:///modules/sessionstore/SessionStartup.jsm"
+);
+
+// Call a function once initialization of SessionStartup is complete
+function afterSessionStartupInitialization(cb) {
+ info("Waiting for session startup initialization");
+ let observer = function() {
+ try {
+ info("Session startup initialization observed");
+ Services.obs.removeObserver(observer, "sessionstore-state-finalized");
+ cb();
+ } catch (ex) {
+ do_throw(ex);
+ }
+ };
+ Services.obs.addObserver(observer, "sessionstore-state-finalized");
+
+ // We need the Crash Monitor initialized for sessionstartup to run
+ // successfully.
+ const { CrashMonitor } = ChromeUtils.import(
+ "resource://gre/modules/CrashMonitor.jsm"
+ );
+ CrashMonitor.init();
+
+ // Start sessionstartup initialization.
+ SessionStartup.init();
+}
+
+// Compress the source file using lz4 and put the result to destination file.
+// After that, source file is deleted.
+async function writeCompressedFile(source, destination) {
+ let s = await OS.File.read(source);
+ await OS.File.writeAtomic(destination, s, { compression: "lz4" });
+ await OS.File.remove(source);
+}