Bug 1393760 - Fix intermittency and re-enabled browser_ext_devtools_panels_elements. r=ochameau
authorLuca Greco <lgreco@mozilla.com>
Tue, 16 Oct 2018 16:58:31 +0000
changeset 497429 ddaf0bd9ee3ae6da8cbb809a36b8c089e07d8655
parent 497428 1604addc1fc97587040e1b17e6e454ce54328703
child 497430 c77616575b61861ab271efcb0a821ad2c8085687
push id9996
push userarchaeopteryx@coole-files.de
push dateThu, 18 Oct 2018 18:37:15 +0000
treeherdermozilla-beta@8efe26839243 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1393760
milestone64.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 1393760 - Fix intermittency and re-enabled browser_ext_devtools_panels_elements. r=ochameau Differential Revision: https://phabricator.services.mozilla.com/D8717
browser/components/extensions/test/browser/browser-common.ini
browser/components/extensions/test/browser/browser_ext_devtools_panels_elements.js
--- a/browser/components/extensions/test/browser/browser-common.ini
+++ b/browser/components/extensions/test/browser/browser-common.ini
@@ -90,17 +90,16 @@ skip-if = (verify && (os == 'linux' || o
 [browser_ext_currentWindow.js]
 [browser_ext_devtools_inspectedWindow.js]
 [browser_ext_devtools_inspectedWindow_eval_bindings.js]
 [browser_ext_devtools_inspectedWindow_reload.js]
 [browser_ext_devtools_network.js]
 [browser_ext_devtools_page.js]
 [browser_ext_devtools_panel.js]
 [browser_ext_devtools_panels_elements.js]
-skip-if = true # Bug 1393760
 [browser_ext_devtools_panels_elements_sidebar.js]
 support-files =
   ../../../../../devtools/client/inspector/extensions/test/head_devtools_inspector_sidebar.js
 [browser_ext_find.js]
 skip-if = (verify && (os == 'linux' || os == 'mac'))
 [browser_ext_getViews.js]
 [browser_ext_history_redirect.js]
 [browser_ext_identity_indication.js]
--- a/browser/components/extensions/test/browser/browser_ext_devtools_panels_elements.js
+++ b/browser/components/extensions/test/browser/browser_ext_devtools_panels_elements.js
@@ -6,55 +6,38 @@ ChromeUtils.defineModuleGetter(this, "gD
                                "resource://devtools/client/framework/gDevTools.jsm");
 ChromeUtils.defineModuleGetter(this, "devtools",
                                "resource://devtools/shared/Loader.jsm");
 
 add_task(async function test_devtools_panels_elements_onSelectionChanged() {
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
 
   function devtools_page() {
-    let isReloading = false;
-    let collectedEvalResults = [];
-
     browser.devtools.panels.elements.onSelectionChanged.addListener(async () => {
       const [
         evalResult, exceptionInfo,
       ] = await browser.devtools.inspectedWindow.eval("$0 && $0.tagName");
 
       if (exceptionInfo) {
         browser.test.fail("Unexpected exceptionInfo on inspectedWindow.eval: " +
                           JSON.stringify(exceptionInfo));
       }
 
-      collectedEvalResults.push(evalResult);
-
-      // The eval results that are happening during the reload are going to
-      // be retrieved all at once using the "collected_devttols_eval_results:request".
-      if (!isReloading) {
-        browser.test.sendMessage("devtools_eval_result", evalResult);
-      }
+      browser.test.sendMessage("devtools_eval_result", evalResult);
     });
 
     browser.test.onMessage.addListener(msg => {
       switch (msg) {
         case "inspectedWindow_reload": {
           // Force a reload to test that the expected onSelectionChanged events are sent
           // while the page is navigating and once it has been fully reloaded.
-          isReloading = true;
-          collectedEvalResults = [];
           browser.devtools.inspectedWindow.eval("window.location.reload();");
           break;
         }
 
-        case "collected_devtools_eval_results:request": {
-          browser.test.sendMessage("collected_devtools_eval_results:reply",
-                                   collectedEvalResults);
-          break;
-        }
-
         default: {
           browser.test.fail(`Received unexpected test.onMesssage: ${msg}`);
         }
       }
     });
 
     browser.test.sendMessage("devtools_page_loaded");
   }
@@ -85,37 +68,38 @@ add_task(async function test_devtools_pa
   info("developer toolbox opened");
 
   await extension.awaitMessage("devtools_page_loaded");
 
   await toolbox.selectTool("inspector");
 
   const inspector = toolbox.getPanel("inspector");
 
+  info("Waiting for the first onSelectionChanged event to be fired once the inspector is open");
+
   const evalResult = await extension.awaitMessage("devtools_eval_result");
-
   is(evalResult, "BODY", "Got the expected onSelectionChanged once the inspector is selected");
 
   // Reload the inspected tab and wait for the inspector markup view to have been
   // fully reloaded.
   const onceMarkupReloaded = inspector.once("markuploaded");
   extension.sendMessage("inspectedWindow_reload");
   await onceMarkupReloaded;
 
-  // Retrieve the first and last collected eval result (the first is related to the
-  // page navigating away, the last one is related to the updated inspector markup view
-  // fully reloaded and the selection updated).
-  extension.sendMessage("collected_devtools_eval_results:request");
-  const collectedEvalResults = await extension.awaitMessage("collected_devtools_eval_results:reply");
-  const evalResultNavigating = collectedEvalResults.shift();
-  const evalResultOnceMarkupReloaded = collectedEvalResults.pop();
+  info("Waiting for the two onSelectionChanged events fired before and after the navigation");
 
+  // Expect the eval result to be undefined on the first onSelectionChanged event
+  // (fired when the page is navigating away, and so the current selection is undefined).
+  const evalResultNavigating = await extension.awaitMessage("devtools_eval_result");
   is(evalResultNavigating, undefined,
      "Got the expected onSelectionChanged once the tab is navigating");
 
+  // Expect the eval result to be related to the body element on the second onSelectionChanged
+  // event (fired when the page have been navigated to the new page).
+  const evalResultOnceMarkupReloaded = await extension.awaitMessage("devtools_eval_result");
   is(evalResultOnceMarkupReloaded, "BODY",
      "Got the expected onSelectionChanged once the tab has been completely reloaded");
 
   await gDevTools.closeToolbox(target);
 
   await target.destroy();
 
   await extension.unload();