Bug 1367652 - split browser_storage_basic_usercontextid.js r=pbro
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Mon, 05 Jun 2017 17:35:31 +0100
changeset 410608 cc0069335c6d0eccda9501ff9a5cf94eb1b5d587
parent 410607 73f9f9a12e3510cd13f835640c99be921b545574
child 410609 4eff5f82fe40e01b28772ddddc72e9191a481c17
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1367652
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1367652 - split browser_storage_basic_usercontextid.js r=pbro MozReview-Commit-ID: 7oZQbmMYlla
devtools/client/storage/test/browser.ini
devtools/client/storage/test/browser_storage_basic_usercontextid.js
devtools/client/storage/test/browser_storage_basic_usercontextid_1.js
devtools/client/storage/test/browser_storage_basic_usercontextid_2.js
--- a/devtools/client/storage/test/browser.ini
+++ b/devtools/client/storage/test/browser.ini
@@ -19,17 +19,18 @@ support-files =
   storage-sessionstorage.html
   storage-unsecured-iframe.html
   storage-unsecured-iframe-usercontextid.html
   storage-updates.html
   head.js
   !/devtools/client/framework/test/shared-head.js
 
 [browser_storage_basic.js]
-[browser_storage_basic_usercontextid.js]
+[browser_storage_basic_usercontextid_1.js]
+[browser_storage_basic_usercontextid_2.js]
 tags = usercontextid
 [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]
rename from devtools/client/storage/test/browser_storage_basic_usercontextid.js
rename to devtools/client/storage/test/browser_storage_basic_usercontextid_1.js
--- a/devtools/client/storage/test/browser_storage_basic_usercontextid.js
+++ b/devtools/client/storage/test/browser_storage_basic_usercontextid_1.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-// A test to check that the storage inspector is working correctly with
+// A test to check that the storage inspector is working correctly without
 // userContextId.
 
 "use strict";
 
 const testCases = [
   [
     ["cookies", "http://test1.example.org"],
     [
@@ -61,76 +61,16 @@ const testCases = [
    [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"]],
 ];
 
-const testCasesUserContextId = [
-  [
-    ["cookies", "http://test1.example.org"],
-    [
-      getCookieId("c1uc1", "test1.example.org", "/browser"),
-      getCookieId("cs2uc1", ".example.org", "/"),
-      getCookieId("c3uc1", "test1.example.org", "/"),
-      getCookieId("uc1uc1", ".example.org", "/")
-    ]
-  ],
-  [
-    ["cookies", "https://sectest1.example.org"],
-    [
-      getCookieId("uc1uc1", ".example.org", "/"),
-      getCookieId("cs2uc1", ".example.org", "/"),
-      getCookieId("sc1uc1", "sectest1.example.org",
-        "/browser/devtools/client/storage/test/")
-    ]
-  ],
-  [["localStorage", "http://test1.example.org"],
-   ["ls1uc1", "ls2uc1"]],
-  [["localStorage", "http://sectest1.example.org"],
-   ["iframe-u-ls1uc1"]],
-  [["localStorage", "https://sectest1.example.org"],
-   ["iframe-s-ls1uc1"]],
-  [["sessionStorage", "http://test1.example.org"],
-   ["ss1uc1"]],
-  [["sessionStorage", "http://sectest1.example.org"],
-   ["iframe-u-ss1uc1", "iframe-u-ss2uc1"]],
-  [["sessionStorage", "https://sectest1.example.org"],
-   ["iframe-s-ss1uc1"]],
-  [["indexedDB", "http://test1.example.org"],
-   ["idb1uc1 (default)", "idb2uc1 (default)"]],
-  [["indexedDB", "http://test1.example.org", "idb1uc1 (default)"],
-   ["obj1uc1", "obj2uc1"]],
-  [["indexedDB", "http://test1.example.org", "idb2uc1 (default)"],
-   ["obj3uc1"]],
-  [["indexedDB", "http://test1.example.org", "idb1uc1 (default)", "obj1uc1"],
-   [1, 2, 3]],
-  [["indexedDB", "http://test1.example.org", "idb1uc1 (default)", "obj2uc1"],
-   [1]],
-  [["indexedDB", "http://test1.example.org", "idb2uc1 (default)", "obj3uc1"],
-   []],
-  [["indexedDB", "http://sectest1.example.org"],
-   []],
-  [["indexedDB", "https://sectest1.example.org"],
-   ["idb-s1uc1 (default)", "idb-s2uc1 (default)"]],
-  [["indexedDB", "https://sectest1.example.org", "idb-s1uc1 (default)"],
-   ["obj-s1uc1"]],
-  [["indexedDB", "https://sectest1.example.org", "idb-s2uc1 (default)"],
-   ["obj-s2uc1"]],
-  [["indexedDB", "https://sectest1.example.org", "idb-s1uc1 (default)", "obj-s1uc1"],
-   [6, 7]],
-  [["indexedDB", "https://sectest1.example.org", "idb-s2uc1 (default)", "obj-s2uc1"],
-   [16]],
-  [["Cache", "http://test1.example.org", "plopuc1"],
-   [MAIN_DOMAIN + "404_cached_file.js",
-    MAIN_DOMAIN + "browser_storage_basic.js"]],
-];
-
 /**
  * Test that the desired number of tree items are present
  */
 function testTree(tests) {
   let doc = gPanelWindow.document;
   for (let [item] of tests) {
     ok(doc.querySelector("[data-id='" + JSON.stringify(item) + "']"),
        "Tree item " + item[0] + " should be present in the storage tree");
@@ -169,16 +109,10 @@ function* testTables(tests) {
 }
 
 add_task(function* () {
   yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-listings.html");
 
   testTree(testCases);
   yield testTables(testCases);
 
-  yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-listings-usercontextid.html",
-                               {userContextId: 1});
-
-  testTree(testCasesUserContextId);
-  yield testTables(testCasesUserContextId);
-
   yield finishTests();
 });
new file mode 100644
--- /dev/null
+++ b/devtools/client/storage/test/browser_storage_basic_usercontextid_2.js
@@ -0,0 +1,120 @@
+/* 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/. */
+
+// A test to check that the storage inspector is working correctly with
+// userContextId.
+
+"use strict";
+
+const testCasesUserContextId = [
+  [
+    ["cookies", "http://test1.example.org"],
+    [
+      getCookieId("c1uc1", "test1.example.org", "/browser"),
+      getCookieId("cs2uc1", ".example.org", "/"),
+      getCookieId("c3uc1", "test1.example.org", "/"),
+      getCookieId("uc1uc1", ".example.org", "/")
+    ]
+  ],
+  [
+    ["cookies", "https://sectest1.example.org"],
+    [
+      getCookieId("uc1uc1", ".example.org", "/"),
+      getCookieId("cs2uc1", ".example.org", "/"),
+      getCookieId("sc1uc1", "sectest1.example.org",
+        "/browser/devtools/client/storage/test/")
+    ]
+  ],
+  [["localStorage", "http://test1.example.org"],
+   ["ls1uc1", "ls2uc1"]],
+  [["localStorage", "http://sectest1.example.org"],
+   ["iframe-u-ls1uc1"]],
+  [["localStorage", "https://sectest1.example.org"],
+   ["iframe-s-ls1uc1"]],
+  [["sessionStorage", "http://test1.example.org"],
+   ["ss1uc1"]],
+  [["sessionStorage", "http://sectest1.example.org"],
+   ["iframe-u-ss1uc1", "iframe-u-ss2uc1"]],
+  [["sessionStorage", "https://sectest1.example.org"],
+   ["iframe-s-ss1uc1"]],
+  [["indexedDB", "http://test1.example.org"],
+   ["idb1uc1 (default)", "idb2uc1 (default)"]],
+  [["indexedDB", "http://test1.example.org", "idb1uc1 (default)"],
+   ["obj1uc1", "obj2uc1"]],
+  [["indexedDB", "http://test1.example.org", "idb2uc1 (default)"],
+   ["obj3uc1"]],
+  [["indexedDB", "http://test1.example.org", "idb1uc1 (default)", "obj1uc1"],
+   [1, 2, 3]],
+  [["indexedDB", "http://test1.example.org", "idb1uc1 (default)", "obj2uc1"],
+   [1]],
+  [["indexedDB", "http://test1.example.org", "idb2uc1 (default)", "obj3uc1"],
+   []],
+  [["indexedDB", "http://sectest1.example.org"],
+   []],
+  [["indexedDB", "https://sectest1.example.org"],
+   ["idb-s1uc1 (default)", "idb-s2uc1 (default)"]],
+  [["indexedDB", "https://sectest1.example.org", "idb-s1uc1 (default)"],
+   ["obj-s1uc1"]],
+  [["indexedDB", "https://sectest1.example.org", "idb-s2uc1 (default)"],
+   ["obj-s2uc1"]],
+  [["indexedDB", "https://sectest1.example.org", "idb-s1uc1 (default)", "obj-s1uc1"],
+   [6, 7]],
+  [["indexedDB", "https://sectest1.example.org", "idb-s2uc1 (default)", "obj-s2uc1"],
+   [16]],
+  [["Cache", "http://test1.example.org", "plopuc1"],
+   [MAIN_DOMAIN + "404_cached_file.js",
+    MAIN_DOMAIN + "browser_storage_basic.js"]],
+];
+
+/**
+ * Test that the desired number of tree items are present
+ */
+function testTree(tests) {
+  let doc = gPanelWindow.document;
+  for (let [item] of tests) {
+    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(tests) {
+  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 tests[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 tests.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-usercontextid.html",
+                               {userContextId: 1});
+
+  testTree(testCasesUserContextId);
+  yield testTables(testCasesUserContextId);
+
+  yield finishTests();
+});