Bug 1165277 - Use origin in SessionStorage.jsm. r=ttaubert

This commit is contained in:
Yoshi Huang 2015-08-04 17:14:57 +08:00
parent 96a294239c
commit a754b37e8d

View File

@ -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);