mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 10:54:33 +00:00
Bug 901916 - Make browser_sessionStorage.js more robust. r=smacleod
This commit is contained in:
parent
f1338a02e2
commit
5eec1aefdb
@ -44,6 +44,11 @@ function test() {
|
||||
let tab;
|
||||
Task.spawn(function() {
|
||||
try {
|
||||
let SESSION_STORAGE_KEY = "SESSION_STORAGE_KEY " + Math.random();
|
||||
let SESSION_STORAGE_VALUE = "SESSION_STORAGE_VALUE " + Math.random();
|
||||
let LOCAL_STORAGE_KEY = "LOCAL_STORAGE_KEY " + Math.random();
|
||||
let LOCAL_STORAGE_VALUE = "LOCAL_STORAGE_VALUE " + Math.random();
|
||||
|
||||
tab = gBrowser.addTab("http://example.com");
|
||||
// about:home supports sessionStorage and localStorage
|
||||
|
||||
@ -57,25 +62,27 @@ function test() {
|
||||
ss.getBrowserState();
|
||||
|
||||
info("Change sessionStorage, ensure that state is saved");
|
||||
win.sessionStorage["SESSION_STORAGE_KEY"] = "SESSION_STORAGE_VALUE";
|
||||
let storageChanged = yield waitForStorageChange(tab);
|
||||
let storageChangedPromise = waitForStorageChange(tab);
|
||||
win.sessionStorage[SESSION_STORAGE_KEY] = SESSION_STORAGE_VALUE;
|
||||
let storageChanged = yield storageChangedPromise;
|
||||
ok(storageChanged, "Changing sessionStorage triggered the right message");
|
||||
yield forceWriteState();
|
||||
|
||||
let state = ss.getBrowserState();
|
||||
ok(state.indexOf("SESSION_STORAGE_KEY") != -1, "Key appears in state");
|
||||
ok(state.indexOf("SESSION_STORAGE_VALUE") != -1, "Value appears in state");
|
||||
ok(state.indexOf(SESSION_STORAGE_KEY) != -1, "Key appears in state");
|
||||
ok(state.indexOf(SESSION_STORAGE_VALUE) != -1, "Value appears in state");
|
||||
|
||||
|
||||
info("Change localStorage, ensure that state is not saved");
|
||||
win.localStorage["LOCAL_STORAGE_KEY"] = "LOCAL_STORAGE_VALUE";
|
||||
storageChanged = yield waitForStorageChange(tab);
|
||||
storageChangedPromise = waitForStorageChange(tab);
|
||||
win.localStorage[LOCAL_STORAGE_KEY] = LOCAL_STORAGE_VALUE;
|
||||
storageChanged = yield storageChangedPromise;
|
||||
ok(!storageChanged, "Changing localStorage did not trigger a message");
|
||||
yield forceWriteState();
|
||||
|
||||
state = ss.getBrowserState();
|
||||
ok(state.indexOf("LOCAL_STORAGE_KEY") == -1, "Key does not appear in state");
|
||||
ok(state.indexOf("LOCAL_STORAGE_VALUE") == -1, "Value does not appear in state");
|
||||
ok(state.indexOf(LOCAL_STORAGE_KEY) == -1, "Key does not appear in state");
|
||||
ok(state.indexOf(LOCAL_STORAGE_VALUE) == -1, "Value does not appear in state");
|
||||
} catch (ex) {
|
||||
ok(false, ex);
|
||||
info(ex.stack);
|
||||
|
Loading…
x
Reference in New Issue
Block a user