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.js32
1 files changed, 32 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 000000000..b62856012
--- /dev/null
+++ b/browser/components/sessionstore/test/unit/head.js
@@ -0,0 +1,32 @@
+var Cu = Components.utils;
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+// Call a function once initialization of SessionStartup is complete
+function afterSessionStartupInitialization(cb) {
+ do_print("Waiting for session startup initialization");
+ let observer = function() {
+ try {
+ do_print("Session startup initialization observed");
+ Services.obs.removeObserver(observer, "sessionstore-state-finalized");
+ cb();
+ } catch (ex) {
+ do_throw(ex);
+ }
+ };
+
+ // We need the Crash Monitor initialized for sessionstartup to run
+ // successfully.
+ Components.utils.import("resource://gre/modules/CrashMonitor.jsm");
+ CrashMonitor.init();
+
+ // Start sessionstartup initialization.
+ let startup = Cc["@mozilla.org/browser/sessionstartup;1"].
+ getService(Ci.nsIObserver);
+ Services.obs.addObserver(startup, "final-ui-startup", false);
+ Services.obs.addObserver(startup, "quit-application", false);
+ Services.obs.notifyObservers(null, "final-ui-startup", "");
+ Services.obs.addObserver(observer, "sessionstore-state-finalized", false);
+};