Bug 1579784 - Basic test for the Search panel, displaying the right search results. r=Honza
authorlloan <lloanalas@outlook.com>
Wed, 18 Sep 2019 10:17:07 +0000
changeset 493772 d7bfa93013b461dbe44eef290d22b3c839e33934
parent 493771 1feec83ee6f92a35de0d4b27ebea04e68a0d7ef0
child 493773 45b3bf9cfeccd8b057c95440be77b7ae61428de0
push id36589
push usernerli@mozilla.com
push dateWed, 18 Sep 2019 21:49:27 +0000
treeherdermozilla-central@21aff209f5a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1579784
milestone71.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 1579784 - Basic test for the Search panel, displaying the right search results. r=Honza Differential Revision: https://phabricator.services.mozilla.com/D45815
devtools/client/netmonitor/test/browser.ini
devtools/client/netmonitor/test/browser_net_basic-search.js
devtools/client/netmonitor/test/head.js
devtools/client/netmonitor/test/sjs_search-test-server.sjs
--- a/devtools/client/netmonitor/test/browser.ini
+++ b/devtools/client/netmonitor/test/browser.ini
@@ -53,16 +53,17 @@ support-files =
   js_worker-test.js
   js_worker-test2.js
   js_websocket-worker-test.js
   sjs_content-type-test-server.sjs
   sjs_cors-test-server.sjs
   sjs_https-redirect-test-server.sjs
   sjs_hsts-test-server.sjs
   sjs_json-test-server.sjs
+  sjs_search-test-server.sjs
   sjs_method-test-server.sjs
   sjs_set-cookie-same-site.sjs
   sjs_simple-test-server.sjs
   sjs_simple-unsorted-cookies-test-server.sjs
   sjs_slow-script-server.sjs
   sjs_sorting-test-server.sjs
   sjs_status-codes-test-server.sjs
   sjs_truncate-test-server.sjs
@@ -74,16 +75,17 @@ support-files =
   xhr_original.js
   !/devtools/client/shared/test/frame-script-utils.js
   !/devtools/client/shared/test/shared-head.js
   !/devtools/client/shared/test/telemetry-test-helpers.js
 
 [browser_net_accessibility-01.js]
 [browser_net_accessibility-02.js]
 [browser_net_api-calls.js]
+[browser_net_basic-search.js]
 [browser_net_background_update.js]
 [browser_net_autoscroll.js]
 [browser_net_block.js]
 [browser_net_block-csp.js]
 [browser_net_cached-status.js]
 skip-if = verify
 [browser_net_cause.js]
 [browser_net_cause_redirect.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/netmonitor/test/browser_net_basic-search.js
@@ -0,0 +1,61 @@
+/* Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Test basic search functionality.
+ * Search panel is visible and number of expected results are returned.
+ */
+
+add_task(async function() {
+  const { tab, monitor } = await initNetMonitor(CUSTOM_GET_URL);
+  info("Starting test... ");
+
+  const { document, store, windowRequire } = monitor.panelWin;
+
+  // Action should be processed synchronously in tests.
+  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
+  store.dispatch(Actions.batchEnable(false));
+
+  // Execute two XHRs (the same URL) and wait till it's finished.
+  const URL = SEARCH_SJS + "?value=test";
+  const wait = waitForNetworkEvents(monitor, 2);
+
+  await ContentTask.spawn(tab.linkedBrowser, URL, async function(url) {
+    content.wrappedJSObject.performRequests(2, url);
+  });
+  await wait;
+
+  // Open the Search panel
+  store.dispatch(Actions.openSearch());
+
+  // Helper for keyboard typing
+  const type = string => {
+    for (const ch of string) {
+      EventUtils.synthesizeKey(ch, {}, monitor.panelWin);
+    }
+  };
+
+  // Fill Filter input with text and check displayed messages.
+  // The filter should be focused automatically.
+  type("test");
+  EventUtils.synthesizeKey("KEY_Enter");
+
+  // Wait till there are two resources rendered in the results.
+  await waitForDOM(document, ".search-panel-content .treeRow.resourceRow", 2);
+
+  // Click on the first resource to expand it
+  EventUtils.sendMouseEvent(
+    { type: "click" },
+    document.querySelector(".search-panel-content .treeRow .treeIcon")
+  );
+
+  // Check that there is 5 matches.
+  const matches = document.querySelectorAll(
+    ".search-panel-content .treeRow.resultRow"
+  );
+  is(matches.length, 5, "There must be 5 matches");
+
+  await teardown(monitor);
+});
--- a/devtools/client/netmonitor/test/head.js
+++ b/devtools/client/netmonitor/test/head.js
@@ -103,16 +103,17 @@ const STATUS_CODES_SJS = EXAMPLE_URL + "
 const SORTING_SJS = EXAMPLE_URL + "sjs_sorting-test-server.sjs";
 const HTTPS_REDIRECT_SJS = EXAMPLE_URL + "sjs_https-redirect-test-server.sjs";
 const CORS_SJS_PATH =
   "/browser/devtools/client/netmonitor/test/sjs_cors-test-server.sjs";
 const HSTS_SJS = EXAMPLE_URL + "sjs_hsts-test-server.sjs";
 const METHOD_SJS = EXAMPLE_URL + "sjs_method-test-server.sjs";
 const SLOW_SJS = EXAMPLE_URL + "sjs_slow-test-server.sjs";
 const SET_COOKIE_SAME_SITE_SJS = EXAMPLE_URL + "sjs_set-cookie-same-site.sjs";
+const SEARCH_SJS = EXAMPLE_URL + "sjs_search-test-server.sjs";
 
 const HSTS_BASE_URL = EXAMPLE_URL;
 const HSTS_PAGE_URL = CUSTOM_GET_URL;
 
 const TEST_IMAGE = EXAMPLE_URL + "test-image.png";
 const TEST_IMAGE_DATA_URI =
   "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==";
 
new file mode 100644
--- /dev/null
+++ b/devtools/client/netmonitor/test/sjs_search-test-server.sjs
@@ -0,0 +1,9 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function handleRequest(request, response) {
+  response.setStatusLine(request.httpVersion, 200, "OK");
+  response.setHeader("Content-Type", "text/xml; charset=utf-8", false);
+  response.setHeader("Set-Cookie", "name1=test;", true);
+  response.write("<label value='test'>Hello From XML!</label>");
+}