summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-03-04 10:28:35 +0100
committerGitHub <noreply@github.com>2018-03-04 10:28:35 +0100
commitf6e7a511bc39106c1bb0f9461d1eb23564c10c8b (patch)
treeea591de8f3a91755421f7416c0b574271a8a6ea6
parenteb7399a0ab12c320ffcd8ea54a4f7d521150daa3 (diff)
parente78a87b4188fd266d6ec9662c95ef147dbbd92cd (diff)
downloadUXP-f6e7a511bc39106c1bb0f9461d1eb23564c10c8b.tar
UXP-f6e7a511bc39106c1bb0f9461d1eb23564c10c8b.tar.gz
UXP-f6e7a511bc39106c1bb0f9461d1eb23564c10c8b.tar.lz
UXP-f6e7a511bc39106c1bb0f9461d1eb23564c10c8b.tar.xz
UXP-f6e7a511bc39106c1bb0f9461d1eb23564c10c8b.zip
Merge pull request #40 from janekptacijarabaci/devtools_import-from-moebius_3
Port across devtools enhancements - 3
-rw-r--r--devtools/client/storage/test/browser.ini3
-rw-r--r--devtools/client/storage/test/browser_storage_basic.js16
-rw-r--r--devtools/client/storage/test/browser_storage_basic_with_fragment.js139
-rw-r--r--devtools/client/storage/test/browser_storage_cookies_delete_all.js18
-rw-r--r--devtools/client/storage/test/browser_storage_cookies_domain.js2
-rw-r--r--devtools/client/storage/test/browser_storage_cookies_domain_port.js29
-rw-r--r--devtools/client/storage/test/browser_storage_delete.js2
-rw-r--r--devtools/client/storage/test/browser_storage_delete_tree.js6
-rw-r--r--devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js16
-rw-r--r--devtools/client/storage/test/browser_storage_sidebar.js2
-rw-r--r--devtools/client/storage/test/head.js1
-rw-r--r--devtools/client/storage/test/storage-listings-with-fragment.html0
-rw-r--r--devtools/client/storage/test/storage-listings.html2
-rw-r--r--devtools/server/actors/storage.js100
-rw-r--r--devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js2
-rw-r--r--devtools/server/tests/browser/browser_storage_dynamic_windows.js11
-rw-r--r--devtools/server/tests/browser/browser_storage_listings.js28
-rw-r--r--devtools/server/tests/browser/browser_storage_updates.js14
18 files changed, 307 insertions, 84 deletions
diff --git a/devtools/client/storage/test/browser.ini b/devtools/client/storage/test/browser.ini
index 1250d35d5..0290aaa5e 100644
--- a/devtools/client/storage/test/browser.ini
+++ b/devtools/client/storage/test/browser.ini
@@ -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,11 +21,13 @@ 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_add.js]
[browser_storage_cookies_delete_all.js]
[browser_storage_cookies_domain.js]
+[browser_storage_cookies_domain_port.js]
[browser_storage_cookies_edit.js]
[browser_storage_cookies_edit_keyboard.js]
[browser_storage_cookies_tab_navigation.js]
diff --git a/devtools/client/storage/test/browser_storage_basic.js b/devtools/client/storage/test/browser_storage_basic.js
index 7585eed1f..35d08afce 100644
--- a/devtools/client/storage/test/browser_storage_basic.js
+++ b/devtools/client/storage/test/browser_storage_basic.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", "/"),
@@ -35,7 +35,7 @@ const testCases = [
]
],
[
- ["cookies", "sectest1.example.org"],
+ ["cookies", "https://sectest1.example.org"],
[
getCookieId("uc1", ".example.org", "/"),
getCookieId("uc2", ".example.org", "/"),
@@ -93,8 +93,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");
}
}
@@ -108,8 +108,8 @@ function* testTables() {
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 + "']"),
+ for (let [treeItem, items] of testCases.slice(1)) {
+ yield selectTreeItem(treeItem);
"Table item " + id + " should be present");
}
@@ -120,10 +120,10 @@ function* testTables() {
// 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");
}
diff --git a/devtools/client/storage/test/browser_storage_basic_with_fragment.js b/devtools/client/storage/test/browser_storage_basic_with_fragment.js
new file mode 100644
index 000000000..7769781c0
--- /dev/null
+++ b/devtools/client/storage/test/browser_storage_basic_with_fragment.js
@@ -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();
+});
diff --git a/devtools/client/storage/test/browser_storage_cookies_delete_all.js b/devtools/client/storage/test/browser_storage_cookies_delete_all.js
index 4640ebecb..f8e9bb288 100644
--- a/devtools/client/storage/test/browser_storage_cookies_delete_all.js
+++ b/devtools/client/storage/test/browser_storage_cookies_delete_all.js
@@ -52,7 +52,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", "/"),
@@ -62,7 +62,7 @@ add_task(function* () {
]
],
[
- ["cookies", "sectest1.example.org"], [
+ ["cookies", "https://sectest1.example.org"], [
getCookieId("cs2", ".example.org", "/"),
getCookieId("c4", ".example.org", "/"),
getCookieId("sc1", "sectest1.example.org",
@@ -78,14 +78,13 @@ 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, "deleteAllFrom");
- yield performDelete(["cookies", "test1.example.org"], id, false);
+ yield performDelete(["cookies", "http://test1.example.org"], id, "deleteAllFrom");
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("c4", ".example.org", "/"),
@@ -94,7 +93,7 @@ add_task(function* () {
]
],
[
- ["cookies", "sectest1.example.org"],
+ ["cookies", "https://sectest1.example.org"],
[
getCookieId("cs2", ".example.org", "/"),
getCookieId("c4", ".example.org", "/"),
@@ -138,14 +137,15 @@ add_task(function* () {
info("delete all");
// delete all cookies for host, including domain cookies
id = getCookieId("uc2", ".example.org", "/");
- yield performDelete(["cookies", "sectest1.example.org"], id, "deleteAll");
+ yield performDelete(["cookies", "http://sectest1.example.org"], id,
+ "deleteAll");
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();
diff --git a/devtools/client/storage/test/browser_storage_cookies_domain.js b/devtools/client/storage/test/browser_storage_cookies_domain.js
index 7b194b73e..06f0a464d 100644
--- a/devtools/client/storage/test/browser_storage_cookies_domain.js
+++ b/devtools/client/storage/test/browser_storage_cookies_domain.js
@@ -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"),
diff --git a/devtools/client/storage/test/browser_storage_cookies_domain_port.js b/devtools/client/storage/test/browser_storage_cookies_domain_port.js
new file mode 100644
index 000000000..a5bc2e5be
--- /dev/null
+++ b/devtools/client/storage/test/browser_storage_cookies_domain_port.js
@@ -0,0 +1,29 @@
+/* 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 ../../framework/test/shared-head.js */
+
+"use strict";
+
+// Test that cookies with domain equal to full host name and port are listed.
+// E.g., ".example.org:8000" vs. example.org:8000).
+
+add_task(function* () {
+ yield openTabAndSetupStorage(MAIN_DOMAIN_WITH_PORT + "storage-cookies.html");
+
+ yield checkState([
+ [
+ ["cookies", "http://test1.example.org:8000"],
+ [
+ getCookieId("test1", ".test1.example.org", "/browser"),
+ getCookieId("test2", "test1.example.org", "/browser"),
+ getCookieId("test3", ".test1.example.org", "/browser"),
+ getCookieId("test4", "test1.example.org", "/browser"),
+ getCookieId("test5", ".test1.example.org", "/browser")
+ ]
+ ],
+ ]);
+
+ yield finishTests();
+});
diff --git a/devtools/client/storage/test/browser_storage_delete.js b/devtools/client/storage/test/browser_storage_delete.js
index a3ef7c290..306c33d24 100644
--- a/devtools/client/storage/test/browser_storage_delete.js
+++ b/devtools/client/storage/test/browser_storage_delete.js
@@ -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"],
diff --git a/devtools/client/storage/test/browser_storage_delete_tree.js b/devtools/client/storage/test/browser_storage_delete_tree.js
index 2bca4c344..6705dba8a 100644
--- a/devtools/client/storage/test/browser_storage_delete_tree.js
+++ b/devtools/client/storage/test/browser_storage_delete_tree.js
@@ -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", "/"),
@@ -37,7 +37,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"],
@@ -66,7 +66,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"], []],
diff --git a/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js b/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js
index 6cf52f2d3..032e7b7b9 100644
--- a/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js
+++ b/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js
@@ -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");
diff --git a/devtools/client/storage/test/browser_storage_sidebar.js b/devtools/client/storage/test/browser_storage_sidebar.js
index 6712ac013..ed8a333e2 100644
--- a/devtools/client/storage/test/browser_storage_sidebar.js
+++ b/devtools/client/storage/test/browser_storage_sidebar.js
@@ -16,7 +16,7 @@
const testCases = [
{
- location: ["cookies", "sectest1.example.org"],
+ location: ["cookies", "https://sectest1.example.org"],
sidebarHidden: true
},
{
diff --git a/devtools/client/storage/test/head.js b/devtools/client/storage/test/head.js
index 181132a45..c734f7b8f 100644
--- a/devtools/client/storage/test/head.js
+++ b/devtools/client/storage/test/head.js
@@ -22,6 +22,7 @@ const DEBUGGERLOG_PREF = "devtools.debugger.log";
const CACHES_ON_HTTP_PREF = "dom.caches.testing.enabled";
const PATH = "browser/devtools/client/storage/test/";
const MAIN_DOMAIN = "http://test1.example.org/" + PATH;
+const MAIN_DOMAIN_WITH_PORT = "http://test1.example.org:8000/" + PATH;
const ALT_DOMAIN = "http://sectest1.example.org/" + PATH;
const ALT_DOMAIN_SECURED = "https://sectest1.example.org:443/" + PATH;
diff --git a/devtools/client/storage/test/storage-listings-with-fragment.html b/devtools/client/storage/test/storage-listings-with-fragment.html
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/devtools/client/storage/test/storage-listings-with-fragment.html
diff --git a/devtools/client/storage/test/storage-listings.html b/devtools/client/storage/test/storage-listings.html
index 313b36b71..385d33193 100644
--- a/devtools/client/storage/test/storage-listings.html
+++ b/devtools/client/storage/test/storage-listings.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">
diff --git a/devtools/server/actors/storage.js b/devtools/server/actors/storage.js
index 015d849ee..c702e8145 100644
--- a/devtools/server/actors/storage.js
+++ b/devtools/server/actors/storage.js
@@ -129,7 +129,11 @@ StorageActors.defaults = function (typeName, observationTopic) {
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;
},
@@ -143,13 +147,35 @@ StorageActors.defaults = function (typeName, observationTopic) {
},
/**
- * 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) {
@@ -202,7 +228,7 @@ StorageActors.defaults = function (typeName, observationTopic) {
*/
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);
@@ -223,7 +249,7 @@ StorageActors.defaults = function (typeName, observationTopic) {
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,6 +493,9 @@ StorageActors.createActor({
if (cookie.host == null) {
return host == null;
}
+
+ host = trimHttpHttpsPort(host);
+
if (cookie.host.startsWith(".")) {
return ("." + host).endsWith(cookie.host);
}
@@ -732,6 +761,8 @@ var cookieHelpers = {
host = "";
}
+ host = trimHttpHttpsPort(host);
+
let cookies = Services.cookies.getCookiesFromHost(host, originAttributes);
let store = [];
@@ -866,6 +897,8 @@ var cookieHelpers = {
opts.path = split[2];
}
+ host = trimHttpHttpsPort(host);
+
function hostMatches(cookieHost, matchHost) {
if (cookieHost == null) {
return matchHost == null;
@@ -1089,16 +1122,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]);
@@ -1110,7 +1133,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);
+ }
}
},
@@ -1315,16 +1341,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);
@@ -1596,16 +1612,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
@@ -2444,6 +2450,24 @@ exports.setupParentProcessForIndexedDB = function ({ mm, prefix }) {
};
/**
+ * General helpers
+ */
+function trimHttpHttpsPort(url) {
+ let match = url.match(/(.+):\d+$/);
+
+ if (match) {
+ url = match[1];
+ }
+ if (url.startsWith("http://")) {
+ return url.substr(7);
+ }
+ if (url.startsWith("https://")) {
+ return url.substr(8);
+ }
+ return url;
+}
+
+/**
* The main Storage Actor.
*/
let StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
diff --git a/devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js b/devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js
index c1cf0aa72..1cdc8b490 100644
--- a/devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js
+++ b/devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js
@@ -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",
diff --git a/devtools/server/tests/browser/browser_storage_dynamic_windows.js b/devtools/server/tests/browser/browser_storage_dynamic_windows.js
index 91b4155d9..a8f791f15 100644
--- a/devtools/server/tests/browser/browser_storage_dynamic_windows.js
+++ b/devtools/server/tests/browser/browser_storage_dynamic_windows.js
@@ -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/")
]
diff --git a/devtools/server/tests/browser/browser_storage_listings.js b/devtools/server/tests/browser/browser_storage_listings.js
index e47a320b8..6c1668321 100644
--- a/devtools/server/tests/browser/browser_storage_listings.js
+++ b/devtools/server/tests/browser/browser_storage_listings.js
@@ -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);
}
diff --git a/devtools/server/tests/browser/browser_storage_updates.js b/devtools/server/tests/browser/browser_storage_updates.js
index 01a35cefc..4a1604787 100644
--- a/devtools/server/tests/browser/browser_storage_updates.js
+++ b/devtools/server/tests/browser/browser_storage_updates.js
@@ -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/"),
]