Bug 630405 - about pages DOMStorage should be case-insensitive. r=mayhemer a=blocking

This commit is contained in:
Marco Bonardo 2011-02-01 13:53:04 -08:00
parent 7c588b1957
commit d3ce42b39f
2 changed files with 28 additions and 0 deletions

View File

@ -359,6 +359,9 @@ nsDOMStorageDBWrapper::CreateDomainScopeDBKey(nsIURI* aUri, nsACString& aKey)
(NS_SUCCEEDED(aUri->SchemeIs("moz-safe-about", &isAboutUrl)) && isAboutUrl)) {
rv = aUri->GetPath(domainScope);
NS_ENSURE_SUCCESS(rv, rv);
// While the host is always canonicalized to lowercase, the path is not,
// thus need to force the casing.
ToLowerCase(domainScope);
}
}

View File

@ -33,6 +33,8 @@ function testURI(aURI)
testURIWithClearCookies(aURI);
testURIWithRejectCookies(aURI);
testURIWithCasing(aURI);
}
function testURIWithPrivateBrowsing(aURI) {
@ -109,6 +111,29 @@ function testURIWithRejectCookies(aURI) {
test_storage();
}
function testURIWithCasing(aURI) {
print("Testing: " + aURI.spec);
let storage = getStorageForURI(aURI);
storage.setItem("test-item", "test-value");
print("Check that our value has been correctly stored.");
do_check_eq(storage.length, 1);
do_check_eq(storage.key(0), "test-item");
do_check_eq(storage.getItem("test-item"), "test-value");
let ucSpec = aURI.spec.toUpperCase();
print("Testing: " + ucSpec);
let ucStorage = getStorageForURI(Services.io.newURI(ucSpec, null, null));
print("Check that our value is accessible in a case-insensitive way.");
do_check_eq(ucStorage.length, 1);
do_check_eq(ucStorage.key(0), "test-item");
do_check_eq(ucStorage.getItem("test-item"), "test-value");
print("Check that our value is correctly removed.");
storage.removeItem("test-item");
do_check_eq(storage.length, 0);
do_check_eq(storage.getItem("test-item"), null);
}
function getStorageForURI(aURI)
{
let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"].