Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/issue_2206_ie8_localStorage_redu…
Browse files Browse the repository at this point in the history
…x' into train-2012.07.30
  • Loading branch information
lloyd committed Aug 9, 2012
2 parents 8229af4 + 535aa8a commit 38a4460
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions resources/static/common/js/storage.js
Expand Up @@ -32,6 +32,10 @@ BrowserID.Storage = (function() {
ONE_DAY_IN_MS = (1000 * 60 * 60 * 24),
storage = BrowserID.getStorage();

// Set default values immediately so that IE8 localStorage synchronization
// issues do not become a factor. See issue #2206
setDefaultValues();

// temporary, replace with helpers.log if storage uses elog long term...
function elog (msg) {
if (window.console && console.error) console.error(msg);
Expand All @@ -45,6 +49,12 @@ BrowserID.Storage = (function() {
storage.removeItem("emails");
storage.removeItem("siteInfo");
storage.removeItem("managePage");
// Ensure there are default values after they are removed. This is
// necessary so that IE8's localStorage synchronization issues do not
// surface. In IE8, if the dialog page is open when the verification page
// loads and emails does not have a default value, the dialog cannot read
// or write to localStorage. The dialog See issues #1637 and #2206
setDefaultValues();
}

// initialize all localStorage values to default if they are unset.
Expand Down
9 changes: 8 additions & 1 deletion resources/static/test/cases/common/js/storage.js
Expand Up @@ -71,12 +71,19 @@
});


test("clear", function() {
test("clear - there should be default values", function() {
storage.addEmail("testuser@testuser.com", {priv: "key"});
storage.clear();

var emails = storage.getEmails();
equal(_.size(emails), 0, "object should have no items");

// all fields *MUST* have default values or else synchronization of
// localStorage in IE8 across multiple browsing contexts becomes a problem.
// See issue #2206 and #1637
notEqual(typeof localStorage.emails, "undefined", "emails is defined");
notEqual(typeof localStorage.siteInfo, "undefined", "siteInfo is defined");
notEqual(typeof localStorage.managePage, "undefined", "managePage is defined");
});

test("invalidateEmail with valid email address", function() {
Expand Down

0 comments on commit 38a4460

Please sign in to comment.