Bug 1532584 - Test event-collector.js with chrome enabled r=ochameau
☠☠ backed out by 9f2370857fa0 ☠ ☠
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Thu, 07 Mar 2019 16:01:28 +0000
changeset 520839 85797ddca8546f5b5248545973e03631f4a1f34e
parent 520838 a1358865bc47de8389ed09c16c5f205980601d12
child 520840 a7c18fe7a05098c880d776c281cfd5c656f3ebdc
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1532584
milestone67.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 1532584 - Test event-collector.js with chrome enabled r=ochameau Differential Revision: https://phabricator.services.mozilla.com/D22076
devtools/client/inspector/markup/test/browser_markup_events_chrome_blocked.js
devtools/client/inspector/markup/test/browser_markup_events_chrome_not_blocked.js
devtools/client/inspector/markup/test/doc_markup_events_chrome_listeners.html
devtools/client/inspector/markup/test/helper_events_test_runner.js
--- a/devtools/client/inspector/markup/test/browser_markup_events_chrome_blocked.js
+++ b/devtools/client/inspector/markup/test/browser_markup_events_chrome_blocked.js
@@ -1,26 +1,40 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 /* import-globals-from helper_events_test_runner.js */
 
 "use strict";
 
-// Test that markup view event bubbles are hidden for <video> tags in the
-// content process when devtools.chrome.enabled=false.
-// <video> tags have 22 chrome listeners.
+// Test that markup view chrome event bubbles are hidden when
+// devtools.chrome.enabled = false.
 
 const TEST_URL = URL_ROOT + "doc_markup_events_chrome_listeners.html";
 
 loadHelperScript("helper_events_test_runner.js");
 
 const TEST_DATA = [
   {
-    selector: "video",
+    selector: "div",
     expected: [ ],
   },
 ];
 
 add_task(async function() {
   await pushPref("devtools.chrome.enabled", false);
-  await runEventPopupTests(TEST_URL, TEST_DATA);
+
+  const {tab, inspector, testActor} = await openInspectorForURL(TEST_URL);
+  const browser = tab.linkedBrowser;
+  const mm = browser.messageManager;
+
+  await mm.loadFrameScript(
+    `data:,const div = content.document.querySelector("div");` +
+    `div.addEventListener("click", () => {` +
+    ` /* Do nothing */` +
+    `});`, false);
+
+  await inspector.markup.expandAll();
+
+  for (const test of TEST_DATA) {
+    await checkEventsForNode(test, inspector, testActor);
+  }
 });
--- a/devtools/client/inspector/markup/test/browser_markup_events_chrome_not_blocked.js
+++ b/devtools/client/inspector/markup/test/browser_markup_events_chrome_not_blocked.js
@@ -1,74 +1,51 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 /* import-globals-from helper_events_test_runner.js */
 
 "use strict";
 
-// Test that markup view event bubbles are shown for <video> tags in the
-// content process when devtools.chrome.enabled=true.
+// Test that markup view chrome event bubbles are shown when
+// devtools.chrome.enabled = true.
 
 const TEST_URL = URL_ROOT + "doc_markup_events_chrome_listeners.html";
 
 loadHelperScript("helper_events_test_runner.js");
 
 const TEST_DATA = [
   {
-    selector: "video",
+    selector: "div",
     expected: [
-      createEvent("canplay"),
-      createEvent("canplaythrough"),
-      createEvent("emptied"),
-      createEvent("ended"),
-      createEvent("error"),
-      createEvent("keypress"),
-      createEvent("loadeddata"),
-      createEvent("loadedmetadata"),
-      createEvent("loadstart"),
-      createEvent("mozvideoonlyseekbegin"),
-      createEvent("mozvideoonlyseekcompleted"),
-      createEvent("pause"),
-      createEvent("play"),
-      createEvent("playing"),
-      createEvent("progress"),
-      createEvent("seeked"),
-      createEvent("seeking"),
-      createEvent("stalled"),
-      createEvent("suspend"),
-      createEvent("timeupdate"),
-      createEvent("volumechange"),
-      createEvent("waiting"),
+      {
+        type: "click",
+        filename: `data:,const div = content.document.querySelector("div");` +
+                  `div.addEventListener("click", () => { /* Do nothing */});:1`,
+        attributes: [
+          "Bubbling",
+          "DOM2",
+        ],
+        handler: `() => { /* Do nothing */ }`,
+      },
     ],
   },
 ];
 
-function createEvent(type) {
-  return {
-    type: type,
-    filename: "chrome://global/content/elements/videocontrols.js:437",
-    attributes: [
-      "Capturing",
-      "DOM2",
-    ],
-    handler: `
-      ${type === "play" ? "function" : "handleEvent"}(aEvent) {
-        if (!aEvent.isTrusted) {
-          this.log("Drop untrusted event ----> " + aEvent.type);
-          return;
-        }
-
-        this.log("Got event ----> " + aEvent.type);
-
-        if (this.videoEvents.includes(aEvent.type)) {
-          this.handleVideoEvent(aEvent);
-        } else {
-          this.handleControlEvent(aEvent);
-        }
-      }`,
-  };
-}
-
 add_task(async function() {
   await pushPref("devtools.chrome.enabled", true);
-  await runEventPopupTests(TEST_URL, TEST_DATA);
+
+  const {tab, inspector, testActor} = await openInspectorForURL(TEST_URL);
+  const browser = tab.linkedBrowser;
+  const mm = browser.messageManager;
+
+  await mm.loadFrameScript(
+    `data:,const div = content.document.querySelector("div");` +
+    `div.addEventListener("click", () => {` +
+    ` /* Do nothing */` +
+    `});`, false);
+
+  await inspector.markup.expandAll();
+
+  for (const test of TEST_DATA) {
+    await checkEventsForNode(test, inspector, testActor);
+  }
 });
--- a/devtools/client/inspector/markup/test/doc_markup_events_chrome_listeners.html
+++ b/devtools/client/inspector/markup/test/doc_markup_events_chrome_listeners.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html lang="en">
 <head>
 	<meta charset="utf-8">
 </head>
 <body>
-	<video controls></video>
+	<div></div>
 </body>
 </html>
\ No newline at end of file
--- a/devtools/client/inspector/markup/test/helper_events_test_runner.js
+++ b/devtools/client/inspector/markup/test/helper_events_test_runner.js
@@ -89,17 +89,18 @@ async function checkEventsForNode(test, 
   }
 
   // Check values
   const headers = tooltip.panel.querySelectorAll(".event-header");
   const nodeFront = container.node;
   const cssSelector = nodeFront.nodeName + "#" + nodeFront.id;
 
   for (let i = 0; i < headers.length; i++) {
-    info("Processing header[" + i + "] for " + cssSelector);
+    const label = `${cssSelector}.${expected[i].type} (index ${i})`;
+    info(`${label} START`);
 
     const header = headers[i];
     const type = header.querySelector(".event-tooltip-event-type");
     const filename = header.querySelector(".event-tooltip-filename");
     const attributes = header.querySelectorAll(".event-tooltip-attributes");
     const contentBox = header.nextElementSibling;
 
     info("Looking for " + type.textContent);
@@ -131,19 +132,23 @@ async function checkEventsForNode(test, 
         "We are in expanded state and icon changed");
 
     const editor = tooltip.eventTooltip._eventEditors.get(contentBox).editor;
     const tidiedHandler = beautify.js(expected[i].handler, {
       "indent_size": 2,
     });
     testDiff(editor.getText(), tidiedHandler,
        "handler matches for " + cssSelector, ok);
+
+    info(`${label} END`);
   }
 
+  const tooltipHidden = tooltip.once("hidden");
   tooltip.hide();
+  await tooltipHidden;
 }
 
 /**
  * Create diff of two strings.
  *
  * @param  {String} text1
  *         String to compare with text2.
  * @param  {String} text2 [description]