diff --git a/browser/components/sessionstore/SessionStorage.jsm b/browser/components/sessionstore/SessionStorage.jsm index 067a673e679..df3f00ef818 100644 --- a/browser/components/sessionstore/SessionStorage.jsm +++ b/browser/components/sessionstore/SessionStorage.jsm @@ -9,6 +9,7 @@ this.EXPORTED_SYMBOLS = ["SessionStorage"]; const Cu = Components.utils; const Ci = Components.interfaces; +Cu.import("resource://gre/modules/BrowserUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); @@ -72,9 +73,9 @@ let SessionStorageInternal = { return; } - // Get the root domain of the current history entry - // and use that as a key for the per-host storage data. - let origin = principal.jarPrefix + principal.originNoSuffix; + // Get the origin of the current history entry + // and use that as a key for the per-principal storage data. + let origin = principal.origin; if (visitedOrigins.has(origin)) { // Don't read a host twice. return; @@ -102,10 +103,9 @@ let SessionStorageInternal = { * {"example.com": {"key": "value", "my_number": 123}} */ restore: function (aDocShell, aStorageData) { - for (let host of Object.keys(aStorageData)) { - let data = aStorageData[host]; - let uri = Services.io.newURI(host, null, null); - let principal = Services.scriptSecurityManager.getDocShellCodebasePrincipal(uri, aDocShell); + for (let origin of Object.keys(aStorageData)) { + let data = aStorageData[origin]; + let principal = BrowserUtils.principalFromOrigin(origin); let storageManager = aDocShell.QueryInterface(Ci.nsIDOMStorageManager); let window = aDocShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);