From 33441c21540e2af47b1e7fc8696c741ac5ac87f1 Mon Sep 17 00:00:00 2001 From: "honzab.moz@firemni.cz" Date: Wed, 27 May 2009 10:31:32 -0700 Subject: [PATCH] Bug 494543 - Can't add items to Dell.com shopping cart (r=dietrich and others) --- .../components/sessionstore/src/nsSessionStore.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index c82cfb4ffd2d..da7e09aef69a 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -1290,8 +1290,18 @@ SessionStoreService.prototype = { let storage, storageItemCount = 0; try { - storage = aDocShell.getSessionStorageForURI(uri); - storageItemCount = storage.length; + var principal = Cc["@mozilla.org/scriptsecuritymanager;1"]. + getService(Ci.nsIScriptSecurityManager). + getCodebasePrincipal(uri); + + // Using getSessionStorageForPrincipal instead of getSessionStorageForURI + // just to be able to pass aCreate = false, that avoids creation of the + // sessionStorage object for the page earlier than the page really + // requires it. It was causing problems while accessing a storage when + // a page later changed its domain. + storage = aDocShell.getSessionStorageForPrincipal(principal, false); + if (storage) + storageItemCount = storage.length; } catch (ex) { /* sessionStorage might throw if it's turned off, see bug 458954 */ } if (storageItemCount == 0)