summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_423132.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /browser/components/sessionstore/test/browser_423132.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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_423132.js')
-rw-r--r--browser/components/sessionstore/test/browser_423132.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_423132.js b/browser/components/sessionstore/test/browser_423132.js
new file mode 100644
index 000000000..584002cff
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_423132.js
@@ -0,0 +1,59 @@
+"use strict";
+
+/**
+ * Tests that cookies are stored and restored correctly
+ * by sessionstore (bug 423132).
+ */
+add_task(function*() {
+ const testURL = "http://mochi.test:8888/browser/" +
+ "browser/components/sessionstore/test/browser_423132_sample.html";
+
+ Services.cookies.removeAll();
+ // make sure that sessionstore.js can be forced to be created by setting
+ // the interval pref to 0
+ yield SpecialPowers.pushPrefEnv({
+ set: [["browser.sessionstore.interval", 0]]
+ });
+
+ let win = yield BrowserTestUtils.openNewBrowserWindow();
+ let browser = win.gBrowser.selectedBrowser;
+ browser.loadURI(testURL);
+ yield BrowserTestUtils.browserLoaded(browser);
+
+ yield TabStateFlusher.flush(browser);
+
+ // get the sessionstore state for the window
+ let state = ss.getWindowState(win);
+
+ // verify our cookie got set during pageload
+ let enumerator = Services.cookies.enumerator;
+ let cookie;
+ let i = 0;
+ while (enumerator.hasMoreElements()) {
+ cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
+ i++;
+ }
+ Assert.equal(i, 1, "expected one cookie");
+
+ // remove the cookie
+ Services.cookies.removeAll();
+
+ // restore the window state
+ ss.setWindowState(win, state, true);
+
+ // at this point, the cookie should be restored...
+ enumerator = Services.cookies.enumerator;
+ let cookie2;
+ while (enumerator.hasMoreElements()) {
+ cookie2 = enumerator.getNext().QueryInterface(Ci.nsICookie);
+ if (cookie.name == cookie2.name)
+ break;
+ }
+ is(cookie.name, cookie2.name, "cookie name successfully restored");
+ is(cookie.value, cookie2.value, "cookie value successfully restored");
+ is(cookie.path, cookie2.path, "cookie path successfully restored");
+
+ // clean up
+ Services.cookies.removeAll();
+ yield BrowserTestUtils.closeWindow(win);
+});