Bug 1412775 - Implement Event.composedPath, tests for chrome handling, r=stone
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 18 Dec 2017 18:08:03 +0200
changeset 396709 45ed85bd1b6ab5e85afc870969173e5f3b29cfd0
parent 396708 9c0350b68863ed20379ae03781bbd9a74f46f733
child 396710 67986543a6bf280f3c960756e9e9a573d3caf09c
push id98352
push useropettay@mozilla.com
push dateMon, 18 Dec 2017 17:06:12 +0000
treeherdermozilla-inbound@45ed85bd1b6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstone
bugs1412775
milestone59.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 1412775 - Implement Event.composedPath, tests for chrome handling, r=stone
dom/events/test/chrome.ini
dom/events/test/test_bug1412775.xul
dom/events/test/window_bug1412775.xul
--- a/dom/events/test/chrome.ini
+++ b/dom/events/test/chrome.ini
@@ -3,25 +3,27 @@ skip-if = os == 'android'
 support-files =
   bug415498-doc1.html
   bug415498-doc2.html
   bug418986-3.js
   bug591249_iframe.xul
   bug602962.xul
   file_bug679494.html
   window_bug617528.xul
+  window_bug1412775.xul
   test_bug336682.js
 
 [test_bug336682_2.xul]
 [test_bug415498.xul]
 [test_bug418986-3.xul]
 [test_bug524674.xul]
 [test_bug586961.xul]
 [test_bug591249.xul]
 [test_bug602962.xul]
 [test_bug617528.xul]
 [test_bug679494.xul]
 [test_bug930374-chrome.html]
 [test_bug1128787-1.html]
 [test_bug1128787-2.html]
 [test_bug1128787-3.html]
+[test_bug1412775.xul]
 [test_eventctors.xul]
 [test_DataTransferItemList.html]
new file mode 100644
--- /dev/null
+++ b/dom/events/test/test_bug1412775.xul
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1412775
+-->
+<window title="Mozilla Bug 1412775"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        onload="init()">
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome-harness.js"></script>
+
+  <!-- test code goes here -->
+  <script type="application/javascript">
+  <![CDATA[
+
+  /** Test for Bug 1412775 **/
+  const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+
+  var win;
+  function init() {
+    SimpleTest.waitForExplicitFinish();
+    win = window.open("window_bug1412775.xul", "_new", "chrome");
+    win.onload = function() {
+      var b = win.document.getElementById("browser");
+      var d = b.contentWindow.document;
+      var e = new d.defaultView.Event("foo");
+      var didCallChromeSide = false;
+      var didCallContentSide = false;
+      b.addEventListener("foo", function(e) {
+        didCallChromeSide = true;
+        var path = e.composedPath();
+        var mm = d.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
+                              .getInterface(Ci.nsIWebNavigation)
+                              .QueryInterface(Ci.nsIInterfaceRequestor)
+                              .getInterface(Ci.nsIContentFrameMessageManager);
+        is(path.length, 5, "Should have 5 items in composedPath in chrome.");
+        is(path[0], mm, "TabChildGlobal is the chrome handler.");
+        is(path[1], b, "browser element should be in the path.");
+        is(path[2], b.parentNode, "window element should be in the path.");
+        is(path[3], win.document, "Document object should be in the path.");
+        is(path[4], win, "Window object should be in the path.");
+      }, true, true);
+      d.addEventListener("foo", function(e) {
+        didCallContentSide = true;;
+        var path = e.composedPath();
+        is(path.length, 4, "Should have 4 items in composedPath in content.");
+        is(path[0], d.body, "body element should be in the path.");
+        is(path[1], d.documentElement, "html element should be in the path.");
+        is(path[2], d, "Document object should be in the path.");
+        is(path[3], d.defaultView, "Window object should be in the path.");
+      }, true, true);
+      d.body.dispatchEvent(e);
+      ok(didCallChromeSide, "didCallChromeSide");
+      ok(didCallContentSide, "didCallContentSide");
+      win.close();
+      SimpleTest.finish();
+    }
+  }
+
+  ]]>
+  </script>
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1412775"
+     target="_blank">Mozilla Bug 1412775</a>
+  </body>
+</window>
new file mode 100644
--- /dev/null
+++ b/dom/events/test/window_bug1412775.xul
@@ -0,0 +1,8 @@
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        width="640" height="480">
+
+  <browser id="browser" type="content" primary="true" flex="1" src="about:blank"/>
+
+</window>