summaryrefslogtreecommitdiffstats
path: root/devtools/client/storage
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-04 01:35:21 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-04 01:35:21 +0100
commita53fe8f5c92ceeb091df55ce41b69f49f7d6c6d6 (patch)
treed9738081fe4e6e3cc3d29eea6e9d71c5c30dcc06 /devtools/client/storage
parentbba13e3d3404473373d9d2122608a90e0aa2ca9f (diff)
downloadUXP-a53fe8f5c92ceeb091df55ce41b69f49f7d6c6d6.tar
UXP-a53fe8f5c92ceeb091df55ce41b69f49f7d6c6d6.tar.gz
UXP-a53fe8f5c92ceeb091df55ce41b69f49f7d6c6d6.tar.lz
UXP-a53fe8f5c92ceeb091df55ce41b69f49f7d6c6d6.tar.xz
UXP-a53fe8f5c92ceeb091df55ce41b69f49f7d6c6d6.zip
Bug 1302989: Make storage inspector work with file:// when # is in the URL
Issue #31
Diffstat (limited to 'devtools/client/storage')
-rw-r--r--devtools/client/storage/test/browser.ini2
-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_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/storage-listings-with-fragment.html0
-rw-r--r--devtools/client/storage/test/storage-listings.html2
11 files changed, 173 insertions, 32 deletions
diff --git a/devtools/client/storage/test/browser.ini b/devtools/client/storage/test/browser.ini
index 1250d35d5..52ea71226 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,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_add.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_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/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">