mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 13:21:28 +00:00
Bug 568091 - DOM Storage cannot store data for about: pages. r=honzab
This commit is contained in:
parent
ae3e280802
commit
08afd68fed
@ -306,11 +306,22 @@ nsDOMStorageDBWrapper::CreateDomainScopeDBKey(nsIURI* aUri, nsACString& aKey)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCAutoString host;
|
||||
rv = aUri->GetAsciiHost(host);
|
||||
nsCAutoString domainScope;
|
||||
rv = aUri->GetAsciiHost(domainScope);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = CreateDomainScopeDBKey(host, aKey);
|
||||
if (domainScope.IsEmpty()) {
|
||||
// About pages have an empty host but a valid path. Since they are handled
|
||||
// internally by our own redirector, we can trust them and use path as key.
|
||||
PRBool isAboutUrl = PR_FALSE;
|
||||
if ((NS_SUCCEEDED(aUri->SchemeIs("about", &isAboutUrl)) && isAboutUrl) ||
|
||||
(NS_SUCCEEDED(aUri->SchemeIs("moz-safe-about", &isAboutUrl)) && isAboutUrl)) {
|
||||
rv = aUri->GetPath(domainScope);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
rv = CreateDomainScopeDBKey(domainScope, aKey);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
|
32
dom/tests/unit/test_domstorage_aboutpages.js
Normal file
32
dom/tests/unit/test_domstorage_aboutpages.js
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test()
|
||||
{
|
||||
// Needs a profile folder for the database.
|
||||
do_get_profile();
|
||||
testURI(Services.io.newURI("about:mozilla", null, null));
|
||||
testURI(Services.io.newURI("moz-safe-about:rights", null, null));
|
||||
}
|
||||
|
||||
function testURI(aURI) {
|
||||
print("Testing: " + aURI.spec);
|
||||
do_check_true(/about$/.test(aURI.scheme));
|
||||
let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"].
|
||||
getService(Components.interfaces.nsIScriptSecurityManager).
|
||||
getCodebasePrincipal(aURI);
|
||||
let dsm = Components.classes["@mozilla.org/dom/storagemanager;1"].
|
||||
getService(Components.interfaces.nsIDOMStorageManager);
|
||||
let storage = dsm.getLocalStorageForPrincipal(principal, "");
|
||||
storage.setItem("test-item", "test-value");
|
||||
print("Check that our value has been correctly stored.");
|
||||
do_check_eq(storage.getItem("test-item"), "test-value");
|
||||
storage.removeItem("test-item");
|
||||
print("Check that our value has been correctly removed.");
|
||||
do_check_eq(storage.getItem("test-item"), null);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user