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_394759_perwindowpb.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_394759_perwindowpb.js')
-rw-r--r-- | browser/components/sessionstore/test/browser_394759_perwindowpb.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_394759_perwindowpb.js b/browser/components/sessionstore/test/browser_394759_perwindowpb.js new file mode 100644 index 000000000..83eec3070 --- /dev/null +++ b/browser/components/sessionstore/test/browser_394759_perwindowpb.js @@ -0,0 +1,55 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const TESTS = [ + { url: "about:config", + key: "bug 394759 Non-PB", + value: "uniq" + r() }, + { url: "about:mozilla", + key: "bug 394759 PB", + value: "uniq" + r() }, +]; + +function promiseTestOpenCloseWindow(aIsPrivate, aTest) { + return Task.spawn(function*() { + let win = yield BrowserTestUtils.openNewBrowserWindow({ "private": aIsPrivate }); + win.gBrowser.selectedBrowser.loadURI(aTest.url); + yield promiseBrowserLoaded(win.gBrowser.selectedBrowser); + yield Promise.resolve(); + // Mark the window with some unique data to be restored later on. + ss.setWindowValue(win, aTest.key, aTest.value); + yield TabStateFlusher.flushWindow(win); + // Close. + yield BrowserTestUtils.closeWindow(win); + }); +} + +function promiseTestOnWindow(aIsPrivate, aValue) { + return Task.spawn(function*() { + let win = yield BrowserTestUtils.openNewBrowserWindow({ "private": aIsPrivate }); + yield TabStateFlusher.flushWindow(win); + let data = JSON.parse(ss.getClosedWindowData())[0]; + is(ss.getClosedWindowCount(), 1, "Check that the closed window count hasn't changed"); + ok(JSON.stringify(data).indexOf(aValue) > -1, + "Check the closed window data was stored correctly"); + registerCleanupFunction(() => BrowserTestUtils.closeWindow(win)); + }); +} + +add_task(function* init() { + forgetClosedWindows(); + while (ss.getClosedTabCount(window) > 0) { + ss.forgetClosedTab(window, 0); + } +}); + +add_task(function* main() { + yield promiseTestOpenCloseWindow(false, TESTS[0]); + yield promiseTestOpenCloseWindow(true, TESTS[1]); + yield promiseTestOnWindow(false, TESTS[0].value); + yield promiseTestOnWindow(true, TESTS[0].value); +}); + |