Bug 1429803 - Fix test; r=ochameau
authorJan Odvarko <odvarko@gmail.com>
Wed, 14 Feb 2018 18:41:36 +0100
changeset 403992 8592fd84fc79597063b8ea3b19af8f8528bd02b8
parent 403991 83a578a1c62dd990167d555e25c17ebe9a722956
child 403993 117cd9ec7414392ccc3f46ff0a3e2bb217c85316
push id99924
push userebalazs@mozilla.com
push dateThu, 15 Feb 2018 20:43:51 +0000
treeherdermozilla-inbound@a7d2a49f46fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1429803
milestone60.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 1429803 - Fix test; r=ochameau MozReview-Commit-ID: 5O2N7xsMzyh
devtools/client/netmonitor/test/browser_net_columns_showhide.js
--- a/devtools/client/netmonitor/test/browser_net_columns_showhide.js
+++ b/devtools/client/netmonitor/test/browser_net_columns_showhide.js
@@ -1,27 +1,37 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 /**
  * Test showing/hiding columns.
  */
-
 add_task(async function () {
   let { monitor, tab } = await initNetMonitor(SIMPLE_URL);
   info("Starting test... ");
 
-  let { document, store, parent } = monitor.panelWin;
+  let { document, store, parent, connector, windowRequire } = monitor.panelWin;
+  let { requestData } = connector;
+  let {
+    getSortedRequests,
+  } = windowRequire("devtools/client/netmonitor/src/selectors/index");
 
   let wait = waitForNetworkEvents(monitor, 1);
   tab.linkedBrowser.loadURI(SIMPLE_URL);
   await wait;
 
+  let item = getSortedRequests(store.getState()).get(0);
+  ok(item.responseHeadersAvailable, "headers are available for lazily fetching");
+
+  if (item.responseHeadersAvailable && !item.responseHeaders) {
+    await requestData(item.id, "responseHeaders");
+  }
+
   let requestsContainer = document.querySelector(".requests-list-contents");
   ok(requestsContainer, "Container element exists as expected.");
   let headers = document.querySelector(".requests-list-headers");
 
   let columns = store.getState().ui.columns;
   for (let column in columns) {
     if (columns[column]) {
       await testVisibleColumnContextMenuItem(column, document, parent);
@@ -48,66 +58,73 @@ add_task(async function () {
 async function testWhiteSpaceContextMenuItem(column, document, parent) {
   ok(!document.querySelector(`#requests-list-${column}-button`),
      `Column ${column} should be hidden`);
 
   info(`Right clicking on white-space in the header to get the context menu`);
   EventUtils.sendMouseEvent({ type: "contextmenu" },
     document.querySelector(".devtools-toolbar.requests-list-headers"));
 
+  // Wait for next tick to do stuff async and force repaint.
+  await waitForTick();
   await toggleAndCheckColumnVisibility(column, document, parent);
 }
 
 async function testVisibleColumnContextMenuItem(column, document, parent) {
   ok(document.querySelector(`#requests-list-${column}-button`),
      `Column ${column} should be visible`);
 
   info(`Clicking context-menu item for ${column}`);
   EventUtils.sendMouseEvent({ type: "contextmenu" },
     document.querySelector("#requests-list-status-button") ||
     document.querySelector("#requests-list-waterfall-button"));
 
+  await waitForTick();
+
   let menuItem = parent.document.querySelector(`#request-list-header-${column}-toggle`);
 
   is(menuItem.getAttribute("type"), "checkbox",
      `${column} menu item should have type="checkbox" attribute`);
   is(menuItem.getAttribute("checked"), "true",
      `checked state of ${column} menu item should be correct`);
   ok(!menuItem.disabled, `disabled state of ${column} menu item should be correct`);
 
   let onHeaderRemoved = waitForDOM(document, `#requests-list-${column}-button`, 0);
   menuItem.click();
 
   await onHeaderRemoved;
+  await waitForTick();
 
   ok(!document.querySelector(`#requests-list-${column}-button`),
      `Column ${column} should be hidden`);
 }
 
 async function testHiddenColumnContextMenuItem(column, document, parent) {
   ok(!document.querySelector(`#requests-list-${column}-button`),
      `Column ${column} should be hidden`);
 
   info(`Clicking context-menu item for ${column}`);
   EventUtils.sendMouseEvent({ type: "contextmenu" },
     document.querySelector("#requests-list-status-button") ||
     document.querySelector("#requests-list-waterfall-button"));
 
+  await waitForTick();
   await toggleAndCheckColumnVisibility(column, document, parent);
 }
 
 async function toggleAndCheckColumnVisibility(column, document, parent) {
   let menuItem = parent.document.querySelector(`#request-list-header-${column}-toggle`);
 
   is(menuItem.getAttribute("type"), "checkbox",
      `${column} menu item should have type="checkbox" attribute`);
   ok(!menuItem.getAttribute("checked"),
      `checked state of ${column} menu item should be correct`);
   ok(!menuItem.disabled, `disabled state of ${column} menu item should be correct`);
 
   let onHeaderAdded = waitForDOM(document, `#requests-list-${column}-button`, 1);
   menuItem.click();
 
   await onHeaderAdded;
+  await waitForTick();
 
   ok(document.querySelector(`#requests-list-${column}-button`),
      `Column ${column} should be visible`);
 }