mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-07 11:56:51 +00:00
Bug 1302989 - Make storage inspector work with file:// when # is in the URL r=nchevobbe
Changes: - Added storage-listings-with-fragment.html and browser_storage-listings-with-fragment.js. The only difference between these and storage-listings.html and browser_storage-listings.js is that they contain url fragments wherever URLs are loaded e.g. #abc, #def etc. - When referencing cookies in tests we used to only use the hostname but a full URL was needed for other storage types. For consistency we now use the full URL for all storage types. - storage.js used to contain various getHostName() methods depending on which storage type was needed. This has been changed to a single method that acts according to which protocol is in use. Cookies are the only storage type that requires just a hostname for the http and https protocols so we strip them inside the cookies actor where required. null is returned when storage types are not available for a particular protocol e.g. data:// URLs. - browser_storage_dynamic_windows.js and browser_storage_listings.js now detect cookies that were previously missed. This is a result of the getHostName() improvements. MozReview-Commit-ID: 8ZzM1Xz5hwU --HG-- extra : rebase_source : 0495166129f6a8f5478063dbeacc1936ce44bd61
This commit is contained in:
parent
8b50e46e00
commit
beac6277d5
@ -9,6 +9,7 @@ support-files =
|
||||
storage-idb-delete-blocked.html
|
||||
storage-indexeddb-duplicate-names.html
|
||||
storage-listings.html
|
||||
storage-listings-with-fragment.html
|
||||
storage-localstorage.html
|
||||
storage-overflow.html
|
||||
storage-search.html
|
||||
@ -20,6 +21,7 @@ support-files =
|
||||
!/devtools/client/framework/test/shared-head.js
|
||||
|
||||
[browser_storage_basic.js]
|
||||
[browser_storage_basic_with_fragment.js]
|
||||
[browser_storage_cache_delete.js]
|
||||
[browser_storage_cache_error.js]
|
||||
[browser_storage_cookies_delete_all.js]
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
const testCases = [
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c1", "test1.example.org", "/browser"),
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
@ -33,7 +33,7 @@ const testCases = [
|
||||
]
|
||||
],
|
||||
[
|
||||
["cookies", "sectest1.example.org"],
|
||||
["cookies", "https://sectest1.example.org"],
|
||||
[
|
||||
getCookieId("uc1", ".example.org", "/"),
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
@ -86,8 +86,8 @@ const testCases = [
|
||||
*/
|
||||
function testTree() {
|
||||
let doc = gPanelWindow.document;
|
||||
for (let item of testCases) {
|
||||
ok(doc.querySelector("[data-id='" + JSON.stringify(item[0]) + "']"),
|
||||
for (let [item] of testCases) {
|
||||
ok(doc.querySelector("[data-id='" + JSON.stringify(item) + "']"),
|
||||
"Tree item " + item[0] + " should be present in the storage tree");
|
||||
}
|
||||
}
|
||||
@ -107,16 +107,16 @@ function* testTables() {
|
||||
}
|
||||
|
||||
// Click rest of the tree items and wait for the table to be updated
|
||||
for (let item of testCases.slice(1)) {
|
||||
yield selectTreeItem(item[0]);
|
||||
for (let [treeItem, items] of testCases.slice(1)) {
|
||||
yield selectTreeItem(treeItem);
|
||||
|
||||
// Check whether correct number of items are present in the table
|
||||
is(doc.querySelectorAll(
|
||||
".table-widget-wrapper:first-of-type .table-widget-cell"
|
||||
).length, item[1].length, "Number of items in table is correct");
|
||||
).length, items.length, "Number of items in table is correct");
|
||||
|
||||
// Check if all the desired items are present in the table
|
||||
for (let id of item[1]) {
|
||||
for (let id of items) {
|
||||
ok(doc.querySelector(".table-widget-cell[data-id='" + id + "']"),
|
||||
"Table item " + id + " should be present");
|
||||
}
|
||||
|
@ -0,0 +1,139 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* import-globals-from head.js */
|
||||
|
||||
// A second basic test to assert that the storage tree and table corresponding
|
||||
// to each item in the storage tree is correctly displayed.
|
||||
|
||||
// This test differs from browser_storage_basic.js because the URLs we load
|
||||
// include fragments e.g. http://example.com/test.js#abcdefg
|
||||
// ^^^^^^^^
|
||||
// fragment
|
||||
|
||||
// Entries that should be present in the tree for this test
|
||||
// Format for each entry in the array :
|
||||
// [
|
||||
// ["path", "to", "tree", "item"], - The path to the tree item to click formed
|
||||
// by id of each item
|
||||
// ["key_value1", "key_value2", ...] - The value of the first (unique) column
|
||||
// for each row in the table corresponding
|
||||
// to the tree item selected.
|
||||
// ]
|
||||
// These entries are formed by the cookies, local storage, session storage and
|
||||
// indexedDB entries created in storage-listings.html,
|
||||
// storage-secured-iframe.html and storage-unsecured-iframe.html
|
||||
|
||||
"use strict";
|
||||
|
||||
const testCases = [
|
||||
[
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c1", "test1.example.org", "/browser"),
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
getCookieId("c3", "test1.example.org", "/"),
|
||||
getCookieId("uc1", ".example.org", "/")
|
||||
]
|
||||
],
|
||||
[
|
||||
["cookies", "https://sectest1.example.org"],
|
||||
[
|
||||
getCookieId("uc1", ".example.org", "/"),
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
getCookieId("sc1", "sectest1.example.org", "/browser/devtools/client/storage/test/")
|
||||
]
|
||||
],
|
||||
[["localStorage", "http://test1.example.org"],
|
||||
["ls1", "ls2"]],
|
||||
[["localStorage", "http://sectest1.example.org"],
|
||||
["iframe-u-ls1"]],
|
||||
[["localStorage", "https://sectest1.example.org"],
|
||||
["iframe-s-ls1"]],
|
||||
[["sessionStorage", "http://test1.example.org"],
|
||||
["ss1"]],
|
||||
[["sessionStorage", "http://sectest1.example.org"],
|
||||
["iframe-u-ss1", "iframe-u-ss2"]],
|
||||
[["sessionStorage", "https://sectest1.example.org"],
|
||||
["iframe-s-ss1"]],
|
||||
[["indexedDB", "http://test1.example.org"],
|
||||
["idb1 (default)", "idb2 (default)"]],
|
||||
[["indexedDB", "http://test1.example.org", "idb1 (default)"],
|
||||
["obj1", "obj2"]],
|
||||
[["indexedDB", "http://test1.example.org", "idb2 (default)"],
|
||||
["obj3"]],
|
||||
[["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"],
|
||||
[1, 2, 3]],
|
||||
[["indexedDB", "http://test1.example.org", "idb1 (default)", "obj2"],
|
||||
[1]],
|
||||
[["indexedDB", "http://test1.example.org", "idb2 (default)", "obj3"],
|
||||
[]],
|
||||
[["indexedDB", "http://sectest1.example.org"],
|
||||
[]],
|
||||
[["indexedDB", "https://sectest1.example.org"],
|
||||
["idb-s1 (default)", "idb-s2 (default)"]],
|
||||
[["indexedDB", "https://sectest1.example.org", "idb-s1 (default)"],
|
||||
["obj-s1"]],
|
||||
[["indexedDB", "https://sectest1.example.org", "idb-s2 (default)"],
|
||||
["obj-s2"]],
|
||||
[["indexedDB", "https://sectest1.example.org", "idb-s1 (default)", "obj-s1"],
|
||||
[6, 7]],
|
||||
[["indexedDB", "https://sectest1.example.org", "idb-s2 (default)", "obj-s2"],
|
||||
[16]],
|
||||
[["Cache", "http://test1.example.org", "plop"],
|
||||
[MAIN_DOMAIN + "404_cached_file.js",
|
||||
MAIN_DOMAIN + "browser_storage_basic.js"]],
|
||||
];
|
||||
|
||||
/**
|
||||
* Test that the desired number of tree items are present
|
||||
*/
|
||||
function testTree() {
|
||||
let doc = gPanelWindow.document;
|
||||
for (let [item] of testCases) {
|
||||
ok(doc.querySelector("[data-id='" + JSON.stringify(item) + "']"),
|
||||
"Tree item " + item[0] + " should be present in the storage tree");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that correct table entries are shown for each of the tree item
|
||||
*/
|
||||
function* testTables() {
|
||||
let doc = gPanelWindow.document;
|
||||
// Expand all nodes so that the synthesized click event actually works
|
||||
gUI.tree.expandAll();
|
||||
|
||||
// First tree item is already selected so no clicking and waiting for update
|
||||
for (let id of testCases[0][1]) {
|
||||
ok(doc.querySelector(".table-widget-cell[data-id='" + id + "']"),
|
||||
"Table item " + id + " should be present");
|
||||
}
|
||||
|
||||
// Click rest of the tree items and wait for the table to be updated
|
||||
for (let [treeItem, items] of testCases.slice(1)) {
|
||||
yield selectTreeItem(treeItem);
|
||||
|
||||
// Check whether correct number of items are present in the table
|
||||
is(doc.querySelectorAll(
|
||||
".table-widget-wrapper:first-of-type .table-widget-cell"
|
||||
).length, items.length, "Number of items in table is correct");
|
||||
|
||||
// Check if all the desired items are present in the table
|
||||
for (let id of items) {
|
||||
ok(doc.querySelector(".table-widget-cell[data-id='" + id + "']"),
|
||||
"Table item " + id + " should be present");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_task(function* () {
|
||||
yield openTabAndSetupStorage(
|
||||
MAIN_DOMAIN + "storage-listings-with-fragment.html#abc");
|
||||
|
||||
testTree();
|
||||
yield testTables();
|
||||
|
||||
yield finishTests();
|
||||
});
|
@ -44,7 +44,7 @@ add_task(function* () {
|
||||
info("test state before delete");
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"], [
|
||||
["cookies", "http://test1.example.org"], [
|
||||
getCookieId("c1", "test1.example.org", "/browser"),
|
||||
getCookieId("c3", "test1.example.org", "/"),
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
@ -52,7 +52,7 @@ add_task(function* () {
|
||||
]
|
||||
],
|
||||
[
|
||||
["cookies", "sectest1.example.org"], [
|
||||
["cookies", "https://sectest1.example.org"], [
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
getCookieId("sc1", "sectest1.example.org",
|
||||
"/browser/devtools/client/storage/test/"),
|
||||
@ -64,20 +64,20 @@ add_task(function* () {
|
||||
info("delete all from domain");
|
||||
// delete only cookies that match the host exactly
|
||||
let id = getCookieId("c1", "test1.example.org", "/browser");
|
||||
yield performDelete(["cookies", "test1.example.org"], id, false);
|
||||
yield performDelete(["cookies", "http://test1.example.org"], id, false);
|
||||
|
||||
info("test state after delete all from domain");
|
||||
yield checkState([
|
||||
// Domain cookies (.example.org) must not be deleted.
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
getCookieId("uc1", ".example.org", "/")
|
||||
]
|
||||
],
|
||||
[
|
||||
["cookies", "sectest1.example.org"],
|
||||
["cookies", "https://sectest1.example.org"],
|
||||
[
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
getCookieId("uc1", ".example.org", "/"),
|
||||
@ -90,14 +90,14 @@ add_task(function* () {
|
||||
info("delete all");
|
||||
// delete all cookies for host, including domain cookies
|
||||
id = getCookieId("uc1", ".example.org", "/");
|
||||
yield performDelete(["cookies", "sectest1.example.org"], id, true);
|
||||
yield performDelete(["cookies", "http://sectest1.example.org"], id, true);
|
||||
|
||||
info("test state after delete all");
|
||||
yield checkState([
|
||||
// Domain cookies (.example.org) are deleted too, so deleting in sectest1
|
||||
// also removes stuff from test1.
|
||||
[["cookies", "test1.example.org"], []],
|
||||
[["cookies", "sectest1.example.org"], []],
|
||||
[["cookies", "http://test1.example.org"], []],
|
||||
[["cookies", "https://sectest1.example.org"], []],
|
||||
]);
|
||||
|
||||
yield finishTests();
|
||||
|
@ -14,7 +14,7 @@ add_task(function* () {
|
||||
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("test1", ".test1.example.org", "/browser"),
|
||||
getCookieId("test2", "test1.example.org", "/browser"),
|
||||
|
@ -14,7 +14,7 @@ const TEST_CASES = [
|
||||
[["sessionStorage", "http://test1.example.org"],
|
||||
"ss1", "name"],
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
getCookieId("c1", "test1.example.org", "/browser"), "name"
|
||||
],
|
||||
[["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"],
|
||||
|
@ -18,7 +18,7 @@ add_task(function* () {
|
||||
info("test state before delete");
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c1", "test1.example.org", "/browser"),
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
@ -35,7 +35,7 @@ add_task(function* () {
|
||||
|
||||
info("do the delete");
|
||||
const deleteHosts = [
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
["localStorage", "http://test1.example.org"],
|
||||
["sessionStorage", "http://test1.example.org"],
|
||||
["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"],
|
||||
@ -64,7 +64,7 @@ add_task(function* () {
|
||||
|
||||
info("test state after delete");
|
||||
yield checkState([
|
||||
[["cookies", "test1.example.org"], []],
|
||||
[["cookies", "http://test1.example.org"], []],
|
||||
[["localStorage", "http://test1.example.org"], []],
|
||||
[["sessionStorage", "http://test1.example.org"], []],
|
||||
[["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"], []],
|
||||
|
@ -43,7 +43,7 @@ add_task(function* () {
|
||||
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c1", "test1.example.org", "/browser"),
|
||||
getCookieId("c2", "test1.example.org", "/browser")
|
||||
@ -60,7 +60,7 @@ add_task(function* () {
|
||||
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c1", "test1.example.org", "/browser"),
|
||||
getCookieId("c2", "test1.example.org", "/browser")
|
||||
@ -78,7 +78,7 @@ add_task(function* () {
|
||||
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c1", "test1.example.org", "/browser"),
|
||||
getCookieId("c2", "test1.example.org", "/browser"),
|
||||
@ -100,7 +100,7 @@ add_task(function* () {
|
||||
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c1", "test1.example.org", "/browser"),
|
||||
getCookieId("c2", "test1.example.org", "/browser"),
|
||||
@ -122,7 +122,7 @@ add_task(function* () {
|
||||
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c2", "test1.example.org", "/browser"),
|
||||
getCookieId("c3", "test1.example.org",
|
||||
@ -145,7 +145,7 @@ add_task(function* () {
|
||||
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c2", "test1.example.org", "/browser"),
|
||||
getCookieId("c4", "test1.example.org",
|
||||
@ -163,7 +163,7 @@ add_task(function* () {
|
||||
|
||||
yield checkState([
|
||||
[
|
||||
["cookies", "test1.example.org"],
|
||||
["cookies", "http://test1.example.org"],
|
||||
[
|
||||
getCookieId("c4", "test1.example.org",
|
||||
"/browser/devtools/client/storage/test/")
|
||||
@ -179,7 +179,7 @@ add_task(function* () {
|
||||
yield gUI.once("store-objects-updated");
|
||||
|
||||
yield checkState([
|
||||
[["cookies", "test1.example.org"], [ ]],
|
||||
[["cookies", "http://test1.example.org"], [ ]],
|
||||
]);
|
||||
|
||||
ok(gUI.sidebar.hidden, "Sidebar is hidden when no rows");
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
const testCases = [
|
||||
{
|
||||
location: ["cookies", "sectest1.example.org"],
|
||||
location: ["cookies", "https://sectest1.example.org"],
|
||||
sidebarHidden: true
|
||||
},
|
||||
{
|
||||
|
134
devtools/client/storage/test/storage-listings-with-fragment.html
Normal file
134
devtools/client/storage/test/storage-listings-with-fragment.html
Normal file
@ -0,0 +1,134 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
This test differs from browser_storage_listings.html only because the URLs we load
|
||||
include fragments e.g. http://example.com/test.js#abcdefg
|
||||
^^^^^^^^
|
||||
fragment
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Storage inspector test for listing hosts and storages with URL fragments</title>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="http://sectest1.example.org/browser/devtools/client/storage/test/storage-unsecured-iframe.html#def"></iframe>
|
||||
<iframe src="https://sectest1.example.org:443/browser/devtools/client/storage/test/storage-secured-iframe.html#ghi"></iframe>
|
||||
<script type="application/javascript;version=1.7">
|
||||
"use strict";
|
||||
let partialHostname = location.hostname.match(/^[^.]+(\..*)$/)[1];
|
||||
let cookieExpiresTime1 = 2000000000000;
|
||||
let cookieExpiresTime2 = 2000000001000;
|
||||
// Setting up some cookies to eat.
|
||||
document.cookie = "c1=foobar; expires=" +
|
||||
new Date(cookieExpiresTime1).toGMTString() + "; path=/browser";
|
||||
document.cookie = "cs2=sessionCookie; path=/; domain=" + partialHostname;
|
||||
document.cookie = "c3=foobar-2; expires=" +
|
||||
new Date(cookieExpiresTime2).toGMTString() + "; path=/";
|
||||
// ... and some local storage items ..
|
||||
localStorage.setItem("ls1", "foobar");
|
||||
localStorage.setItem("ls2", "foobar-2");
|
||||
// ... and finally some session storage items too
|
||||
sessionStorage.setItem("ss1", "foobar-3");
|
||||
dump("added cookies and storage from main page\n");
|
||||
|
||||
let idbGenerator = async function() {
|
||||
let request = indexedDB.open("idb1", 1);
|
||||
request.onerror = function() {
|
||||
throw new Error("error opening db connection");
|
||||
};
|
||||
let db = await new Promise(done => {
|
||||
request.onupgradeneeded = event => {
|
||||
let db = event.target.result;
|
||||
let store1 = db.createObjectStore("obj1", { keyPath: "id" });
|
||||
store1.createIndex("name", "name", { unique: false });
|
||||
store1.createIndex("email", "email", { unique: true });
|
||||
let store2 = db.createObjectStore("obj2", { keyPath: "id2" });
|
||||
store1.transaction.oncomplete = () => {
|
||||
done(db);
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
// Prevents AbortError
|
||||
await new Promise(done => {
|
||||
request.onsuccess = done;
|
||||
});
|
||||
|
||||
let transaction = db.transaction(["obj1", "obj2"], "readwrite");
|
||||
let store1 = transaction.objectStore("obj1");
|
||||
let store2 = transaction.objectStore("obj2");
|
||||
store1.add({id: 1, name: "foo", email: "foo@bar.com"});
|
||||
store1.add({id: 2, name: "foo2", email: "foo2@bar.com"});
|
||||
store1.add({id: 3, name: "foo2", email: "foo3@bar.com"});
|
||||
store2.add({
|
||||
id2: 1,
|
||||
name: "foo",
|
||||
email: "foo@bar.com",
|
||||
extra: "baz"
|
||||
});
|
||||
// Prevents AbortError during close()
|
||||
await new Promise(success => {
|
||||
transaction.oncomplete = success;
|
||||
});
|
||||
|
||||
db.close();
|
||||
|
||||
request = indexedDB.open("idb2", 1);
|
||||
let db2 = await new Promise(done => {
|
||||
request.onupgradeneeded = event => {
|
||||
let db2 = event.target.result;
|
||||
let store3 = db2.createObjectStore("obj3", { keyPath: "id3" });
|
||||
store3.createIndex("name2", "name2", { unique: true });
|
||||
store3.transaction.oncomplete = () => {
|
||||
done(db2);
|
||||
}
|
||||
};
|
||||
});
|
||||
// Prevents AbortError during close()
|
||||
await new Promise(done => {
|
||||
request.onsuccess = done;
|
||||
});
|
||||
db2.close();
|
||||
|
||||
dump("added indexedDB from main page\n");
|
||||
};
|
||||
|
||||
function deleteDB(dbName) {
|
||||
return new Promise(resolve => {
|
||||
dump("removing database " + dbName + " from " + document.location + "\n");
|
||||
indexedDB.deleteDatabase(dbName).onsuccess = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchPut(cache, url) {
|
||||
let response = await fetch(url);
|
||||
await cache.put(url, response);
|
||||
}
|
||||
|
||||
let cacheGenerator = async function() {
|
||||
let cache = await caches.open("plop");
|
||||
await fetchPut(cache, "404_cached_file.js");
|
||||
await fetchPut(cache, "browser_storage_basic.js");
|
||||
};
|
||||
|
||||
window.setup = function*() {
|
||||
yield idbGenerator();
|
||||
|
||||
if (window.caches) {
|
||||
yield cacheGenerator();
|
||||
}
|
||||
};
|
||||
|
||||
window.clear = function*() {
|
||||
yield deleteDB("idb1");
|
||||
yield deleteDB("idb2");
|
||||
|
||||
if (window.caches) {
|
||||
yield caches.delete("plop");
|
||||
}
|
||||
|
||||
dump("removed indexedDB and cache data from " + document.location + "\n");
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Bug 970517 - Storage inspector front end - tests
|
||||
Storage inspector front end - tests
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -126,7 +126,11 @@ StorageActors.defaults = function (typeName, observationTopics) {
|
||||
get hosts() {
|
||||
let hosts = new Set();
|
||||
for (let {location} of this.storageActor.windows) {
|
||||
hosts.add(this.getHostName(location));
|
||||
let host = this.getHostName(location);
|
||||
|
||||
if (host) {
|
||||
hosts.add(host);
|
||||
}
|
||||
}
|
||||
return hosts;
|
||||
},
|
||||
@ -140,13 +144,35 @@ StorageActors.defaults = function (typeName, observationTopics) {
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts the window.location object into host.
|
||||
* Converts the window.location object into a URL (e.g. http://domain.com).
|
||||
*/
|
||||
getHostName(location) {
|
||||
if (location.protocol === "chrome:") {
|
||||
return location.href;
|
||||
if (!location) {
|
||||
// Debugging a legacy Firefox extension... no hostname available and no
|
||||
// storage possible.
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (location.protocol) {
|
||||
case "data:":
|
||||
// data: URLs do not support storage of any type.
|
||||
return null;
|
||||
case "about:":
|
||||
// Fallthrough.
|
||||
case "chrome:":
|
||||
// Fallthrough.
|
||||
case "file:":
|
||||
return location.protocol + location.pathname;
|
||||
case "resource:":
|
||||
return location.origin + location.pathname;
|
||||
case "moz-extension:":
|
||||
return location.origin;
|
||||
case "javascript:":
|
||||
return location.href;
|
||||
default:
|
||||
// http: or unknown protocol.
|
||||
return `${location.protocol}//${location.host}`;
|
||||
}
|
||||
return location.hostname || location.href;
|
||||
},
|
||||
|
||||
initialize(storageActor) {
|
||||
@ -206,7 +232,7 @@ StorageActors.defaults = function (typeName, observationTopics) {
|
||||
*/
|
||||
onWindowReady: Task.async(function* (window) {
|
||||
let host = this.getHostName(window.location);
|
||||
if (!this.hostVsStores.has(host)) {
|
||||
if (host && !this.hostVsStores.has(host)) {
|
||||
yield this.populateStoresForHost(host, window);
|
||||
let data = {};
|
||||
data[host] = this.getNamesForHost(host);
|
||||
@ -227,7 +253,7 @@ StorageActors.defaults = function (typeName, observationTopics) {
|
||||
return;
|
||||
}
|
||||
let host = this.getHostName(window.location);
|
||||
if (!this.hosts.has(host)) {
|
||||
if (host && !this.hosts.has(host)) {
|
||||
this.hostVsStores.delete(host);
|
||||
let data = {};
|
||||
data[host] = [];
|
||||
@ -467,12 +493,16 @@ StorageActors.createActor({
|
||||
if (cookie.host == null) {
|
||||
return host == null;
|
||||
}
|
||||
|
||||
host = trimHttpHttps(host);
|
||||
|
||||
if (cookie.host.startsWith(".")) {
|
||||
return ("." + host).endsWith(cookie.host);
|
||||
}
|
||||
if (cookie.host === "") {
|
||||
return host.startsWith("file://" + cookie.path);
|
||||
}
|
||||
|
||||
return cookie.host == host;
|
||||
},
|
||||
|
||||
@ -714,6 +744,8 @@ var cookieHelpers = {
|
||||
host = "";
|
||||
}
|
||||
|
||||
host = trimHttpHttps(host);
|
||||
|
||||
let cookies = Services.cookies.getCookiesFromHost(host, originAttributes);
|
||||
let store = [];
|
||||
|
||||
@ -848,6 +880,8 @@ var cookieHelpers = {
|
||||
opts.path = split[2];
|
||||
}
|
||||
|
||||
host = trimHttpHttps(host);
|
||||
|
||||
function hostMatches(cookieHost, matchHost) {
|
||||
if (cookieHost == null) {
|
||||
return matchHost == null;
|
||||
@ -1054,16 +1088,6 @@ function getObjectForLocalOrSessionStorage(type) {
|
||||
}));
|
||||
},
|
||||
|
||||
getHostName(location) {
|
||||
if (!location.host) {
|
||||
return location.href;
|
||||
}
|
||||
if (location.protocol === "chrome:") {
|
||||
return location.href;
|
||||
}
|
||||
return location.protocol + "//" + location.host;
|
||||
},
|
||||
|
||||
populateStoresForHost(host, window) {
|
||||
try {
|
||||
this.hostVsStores.set(host, window[type]);
|
||||
@ -1075,7 +1099,10 @@ function getObjectForLocalOrSessionStorage(type) {
|
||||
populateStoresForHosts() {
|
||||
this.hostVsStores = new Map();
|
||||
for (let window of this.windows) {
|
||||
this.populateStoresForHost(this.getHostName(window.location), window);
|
||||
let host = this.getHostName(window.location);
|
||||
if (host) {
|
||||
this.populateStoresForHost(host, window);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -1274,16 +1301,6 @@ StorageActors.createActor({
|
||||
];
|
||||
}),
|
||||
|
||||
getHostName(location) {
|
||||
if (!location.host) {
|
||||
return location.href;
|
||||
}
|
||||
if (location.protocol === "chrome:") {
|
||||
return location.href;
|
||||
}
|
||||
return location.protocol + "//" + location.host;
|
||||
},
|
||||
|
||||
populateStoresForHost: Task.async(function* (host) {
|
||||
let storeMap = new Map();
|
||||
let caches = yield this.getCachesForHost(host);
|
||||
@ -1559,16 +1576,6 @@ StorageActors.createActor({
|
||||
this.removeDBRecord(host, principal, db, store, id);
|
||||
}),
|
||||
|
||||
getHostName(location) {
|
||||
if (!location.host) {
|
||||
return location.href;
|
||||
}
|
||||
if (location.protocol === "chrome:") {
|
||||
return location.href;
|
||||
}
|
||||
return location.protocol + "//" + location.host;
|
||||
},
|
||||
|
||||
/**
|
||||
* This method is overriden and left blank as for indexedDB, this operation
|
||||
* cannot be performed synchronously. Thus, the preListStores method exists to
|
||||
@ -2409,6 +2416,19 @@ exports.setupParentProcessForIndexedDB = function ({ mm, prefix }) {
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* General helpers
|
||||
*/
|
||||
function trimHttpHttps(url) {
|
||||
if (url.startsWith("http://")) {
|
||||
return url.substr(7);
|
||||
}
|
||||
if (url.startsWith("https://")) {
|
||||
return url.substr(8);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* The main Storage Actor.
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@ const {StorageFront} = require("devtools/shared/fronts/storage");
|
||||
Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/devtools/server/tests/browser/storage-helpers.js", this);
|
||||
|
||||
const TESTDATA = {
|
||||
"test1.example.org": [
|
||||
"http://test1.example.org": [
|
||||
{
|
||||
name: "name",
|
||||
value: "value1",
|
||||
|
@ -9,8 +9,8 @@ Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/devtool
|
||||
|
||||
const beforeReload = {
|
||||
cookies: {
|
||||
"test1.example.org": ["c1", "cs2", "c3", "uc1"],
|
||||
"sectest1.example.org": ["uc1", "cs2"]
|
||||
"http://test1.example.org": ["c1", "cs2", "c3", "uc1"],
|
||||
"http://sectest1.example.org": ["uc1", "cs2"]
|
||||
},
|
||||
localStorage: {
|
||||
"http://test1.example.org": ["ls1", "ls2"],
|
||||
@ -99,7 +99,12 @@ function testAddIframe(front) {
|
||||
"https://sectest1.example.org": ["iframe-s-ss1"]
|
||||
},
|
||||
cookies: {
|
||||
"sectest1.example.org": [
|
||||
"https://sectest1.example.org": [
|
||||
getCookieId("cs2", ".example.org", "/"),
|
||||
getCookieId("sc1", "sectest1.example.org",
|
||||
"/browser/devtools/server/tests/browser/")
|
||||
],
|
||||
"http://sectest1.example.org": [
|
||||
getCookieId("sc1", "sectest1.example.org",
|
||||
"/browser/devtools/server/tests/browser/")
|
||||
]
|
||||
|
@ -9,7 +9,7 @@ Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/devtool
|
||||
|
||||
const storeMap = {
|
||||
cookies: {
|
||||
"test1.example.org": [
|
||||
"http://test1.example.org": [
|
||||
{
|
||||
name: "c1",
|
||||
value: "foobar",
|
||||
@ -38,7 +38,29 @@ const storeMap = {
|
||||
isSecure: true,
|
||||
}
|
||||
],
|
||||
"sectest1.example.org": [
|
||||
|
||||
"http://sectest1.example.org": [
|
||||
{
|
||||
name: "cs2",
|
||||
value: "sessionCookie",
|
||||
path: "/",
|
||||
host: ".example.org",
|
||||
expires: 0,
|
||||
isDomain: true,
|
||||
isSecure: false,
|
||||
},
|
||||
{
|
||||
name: "sc1",
|
||||
value: "foobar",
|
||||
path: "/browser/devtools/server/tests/browser/",
|
||||
host: "sectest1.example.org",
|
||||
expires: 0,
|
||||
isDomain: false,
|
||||
isSecure: false,
|
||||
}
|
||||
],
|
||||
|
||||
"https://sectest1.example.org": [
|
||||
{
|
||||
name: "uc1",
|
||||
value: "foobar",
|
||||
@ -328,7 +350,7 @@ function* testStores(data) {
|
||||
}
|
||||
|
||||
function testCookies(cookiesActor) {
|
||||
is(Object.keys(cookiesActor.hosts).length, 2,
|
||||
is(Object.keys(cookiesActor.hosts).length, 3,
|
||||
"Correct number of host entries for cookies");
|
||||
return testCookiesObjects(0, cookiesActor.hosts, cookiesActor);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
const {StorageFront} = require("devtools/shared/fronts/storage");
|
||||
const beforeReload = {
|
||||
cookies: ["test1.example.org", "sectest1.example.org"],
|
||||
cookies: ["http://test1.example.org", "https://sectest1.example.org"],
|
||||
localStorage: ["http://test1.example.org", "http://sectest1.example.org"],
|
||||
sessionStorage: ["http://test1.example.org", "http://sectest1.example.org"],
|
||||
};
|
||||
@ -27,7 +27,7 @@ const TESTS = [
|
||||
expected: {
|
||||
added: {
|
||||
cookies: {
|
||||
"test1.example.org": [
|
||||
"http://test1.example.org": [
|
||||
getCookieId("c1", "test1.example.org",
|
||||
"/browser/devtools/server/tests/browser/"),
|
||||
getCookieId("c2", "test1.example.org",
|
||||
@ -53,7 +53,7 @@ const TESTS = [
|
||||
expected: {
|
||||
changed: {
|
||||
cookies: {
|
||||
"test1.example.org": [
|
||||
"http://test1.example.org": [
|
||||
getCookieId("c1", "test1.example.org",
|
||||
"/browser/devtools/server/tests/browser/"),
|
||||
]
|
||||
@ -82,7 +82,7 @@ const TESTS = [
|
||||
expected: {
|
||||
deleted: {
|
||||
cookies: {
|
||||
"test1.example.org": [
|
||||
"http://test1.example.org": [
|
||||
getCookieId("c2", "test1.example.org",
|
||||
"/browser/devtools/server/tests/browser/"),
|
||||
]
|
||||
@ -123,7 +123,7 @@ const TESTS = [
|
||||
expected: {
|
||||
added: {
|
||||
cookies: {
|
||||
"test1.example.org": [
|
||||
"http://test1.example.org": [
|
||||
getCookieId("c3", "test1.example.org",
|
||||
"/browser/devtools/server/tests/browser/"),
|
||||
]
|
||||
@ -139,7 +139,7 @@ const TESTS = [
|
||||
},
|
||||
deleted: {
|
||||
cookies: {
|
||||
"test1.example.org": [
|
||||
"http://test1.example.org": [
|
||||
getCookieId("c1", "test1.example.org",
|
||||
"/browser/devtools/server/tests/browser/"),
|
||||
]
|
||||
@ -175,7 +175,7 @@ const TESTS = [
|
||||
expected: {
|
||||
deleted: {
|
||||
cookies: {
|
||||
"test1.example.org": [
|
||||
"http://test1.example.org": [
|
||||
getCookieId("c3", "test1.example.org",
|
||||
"/browser/devtools/server/tests/browser/"),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user