forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 532150 - Test main thread fallback for session file. r=Felipe
- Loading branch information
David Rajchenbach-Teller
committed
Dec 20, 2012
1 parent
f3d3046
commit cb312ca
Showing
9 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
browser/components/sessionstore/test/unit/data/sessionstore_valid.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"windows": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
let Cu = Components.utils; | ||
let Cc = Components.classes; | ||
let Ci = Components.interfaces; | ||
|
||
Components.utils.import("resource://gre/modules/Services.jsm"); | ||
|
||
// Call a function once initialization of SessionStartup is complete | ||
let afterSessionStartupInitialization = | ||
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); | ||
} | ||
}; | ||
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); | ||
}; |
22 changes: 22 additions & 0 deletions
22
browser/components/sessionstore/test/unit/test_startup_nosession_async.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
|
||
// Test nsISessionStartup.sessionType in the following scenario: | ||
// - no sessionstore.js; | ||
// - the session store has been loaded, so no need to go | ||
// through the synchronous fallback | ||
|
||
function run_test() { | ||
do_get_profile(); | ||
// Initialize the profile (the session startup uses it) | ||
|
||
do_test_pending(); | ||
let startup = Cc["@mozilla.org/browser/sessionstartup;1"]. | ||
getService(Ci.nsISessionStartup); | ||
|
||
afterSessionStartupInitialization(function cb() { | ||
do_check_eq(startup.sessionType, Ci.nsISessionStartup.NO_SESSION); | ||
do_test_finished(); | ||
}); | ||
} |
15 changes: 15 additions & 0 deletions
15
browser/components/sessionstore/test/unit/test_startup_nosession_sync.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
|
||
// Test nsISessionStartup.sessionType in the following scenario: | ||
// - no sessionstore.js; | ||
// - the session store has not been loaded yet, so we have to trigger | ||
// synchronous fallback | ||
|
||
function run_test() { | ||
do_get_profile(); | ||
let startup = Cc["@mozilla.org/browser/sessionstartup;1"]. | ||
getService(Ci.nsISessionStartup); | ||
do_check_eq(startup.sessionType, Ci.nsISessionStartup.NO_SESSION); | ||
} |
23 changes: 23 additions & 0 deletions
23
browser/components/sessionstore/test/unit/test_startup_session_async.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
|
||
// Test nsISessionStartup.sessionType in the following scenario: | ||
// - valid sessionstore.js; | ||
// - the session store has been loaded, so no need to go | ||
// through the synchronous fallback | ||
|
||
function run_test() { | ||
let profd = do_get_profile(); | ||
let source = do_get_file("data/sessionstore_valid.js"); | ||
source.copyTo(profd, "sessionstore.js"); | ||
|
||
do_test_pending(); | ||
let startup = Cc["@mozilla.org/browser/sessionstartup;1"]. | ||
getService(Ci.nsISessionStartup); | ||
|
||
afterSessionStartupInitialization(function cb() { | ||
do_check_eq(startup.sessionType, Ci.nsISessionStartup.DEFER_SESSION); | ||
do_test_finished(); | ||
}); | ||
} |
17 changes: 17 additions & 0 deletions
17
browser/components/sessionstore/test/unit/test_startup_session_sync.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
|
||
// Test nsISessionStartup.sessionType in the following scenario: | ||
// - valid sessionstore.js; | ||
// - the session store has not been loaded yet, so we have to trigger | ||
// synchronous fallback | ||
|
||
function run_test() { | ||
let profd = do_get_profile(); | ||
let source = do_get_file("data/sessionstore_valid.js"); | ||
source.copyTo(profd, "sessionstore.js"); | ||
let startup = Cc["@mozilla.org/browser/sessionstartup;1"]. | ||
getService(Ci.nsISessionStartup); | ||
do_check_eq(startup.sessionType, Ci.nsISessionStartup.DEFER_SESSION); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[DEFAULT] | ||
head = head.js | ||
tail = | ||
|
||
[test_startup_nosession_sync.js] | ||
[test_startup_nosession_async.js] | ||
[test_startup_session_sync.js] | ||
[test_startup_session_async.js] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters