diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/components/sessionstore/test/browser_637020.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/sessionstore/test/browser_637020.js')
-rw-r--r-- | browser/components/sessionstore/test/browser_637020.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_637020.js b/browser/components/sessionstore/test/browser_637020.js new file mode 100644 index 000000000..1c1f357d7 --- /dev/null +++ b/browser/components/sessionstore/test/browser_637020.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const TEST_URL = "http://mochi.test:8888/browser/browser/components/" + + "sessionstore/test/browser_637020_slow.sjs"; + +const TEST_STATE = { + windows: [{ + tabs: [ + { entries: [{ url: "about:mozilla" }] }, + { entries: [{ url: "about:robots" }] } + ] + }, { + tabs: [ + { entries: [{ url: TEST_URL }] }, + { entries: [{ url: TEST_URL }] } + ] + }] +}; + +/** + * This test ensures that windows that have just been restored will be marked + * as dirty, otherwise _getCurrentState() might ignore them when collecting + * state for the first time and we'd just save them as empty objects. + * + * The dirty state acts as a cache to not collect data from all windows all the + * time, so at the beginning, each window must be dirty so that we collect + * their state at least once. + */ + +add_task(function* test() { + // Wait until the new window has been opened. + let promiseWindow = new Promise(resolve => { + Services.obs.addObserver(function onOpened(subject) { + Services.obs.removeObserver(onOpened, "domwindowopened"); + resolve(subject); + }, "domwindowopened", false); + }); + + // Set the new browser state that will + // restore a window with two slowly loading tabs. + let backupState = SessionStore.getBrowserState(); + SessionStore.setBrowserState(JSON.stringify(TEST_STATE)); + let win = yield promiseWindow; + + // The window has now been opened. Check the state that is returned, + // this should come from the cache while the window isn't restored, yet. + info("the window has been opened"); + checkWindows(); + + // The history has now been restored and the tabs are loading. The data must + // now come from the window, if it's correctly been marked as dirty before. + yield new Promise(resolve => whenDelayedStartupFinished(win, resolve)); + info("the delayed startup has finished"); + checkWindows(); + + // Cleanup. + yield BrowserTestUtils.closeWindow(win); + yield promiseBrowserState(backupState); +}); + +function checkWindows() { + let state = JSON.parse(SessionStore.getBrowserState()); + is(state.windows[0].tabs.length, 2, "first window has two tabs"); + is(state.windows[1].tabs.length, 2, "second window has two tabs"); +} |