summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_filter-sts-search.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/netmonitor/test/browser_net_filter-sts-search.js')
-rw-r--r--devtools/client/netmonitor/test/browser_net_filter-sts-search.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/test/browser_net_filter-sts-search.js b/devtools/client/netmonitor/test/browser_net_filter-sts-search.js
new file mode 100644
index 0000000000..d8de156cb6
--- /dev/null
+++ b/devtools/client/netmonitor/test/browser_net_filter-sts-search.js
@@ -0,0 +1,59 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Test incomplete status-code search
+ */
+const REQUESTS = [
+ { url: "sjs_status-codes-test-server.sjs?sts=400" },
+ { url: "sjs_status-codes-test-server.sjs?sts=300" },
+ { url: "sjs_status-codes-test-server.sjs?sts=304" },
+];
+
+add_task(async function () {
+ const { monitor } = await initNetMonitor(FILTERING_URL, { requestCount: 1 });
+ const { document, store, windowRequire } = monitor.panelWin;
+ const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
+
+ const { getDisplayedRequests } = windowRequire(
+ "devtools/client/netmonitor/src/selectors/index"
+ );
+
+ store.dispatch(Actions.batchEnable(false));
+
+ info("Starting test... ");
+
+ // Let the requests load completely before the incomplete search tests begin
+ // because we are searching for the status code in these requests.
+ const waitNetwork = waitForNetworkEvents(monitor, REQUESTS.length);
+ await performRequestsInContent(REQUESTS);
+ await waitNetwork;
+
+ document.querySelector(".devtools-filterinput").focus();
+
+ EventUtils.sendString("status-code:3");
+
+ let visibleItems = getDisplayedRequests(store.getState());
+
+ // Results will be updated asynchronously, so we should wait until
+ // displayed requests reach final state.
+ await waitUntil(() => {
+ visibleItems = getDisplayedRequests(store.getState());
+ return visibleItems.length === 2;
+ });
+
+ is(
+ Number(visibleItems[0].status),
+ 303,
+ "First visible item has expected status"
+ );
+ is(
+ Number(visibleItems[1].status),
+ 304,
+ "Second visible item has expected status"
+ );
+
+ await teardown(monitor);
+});