Bug 1534562, setPointerCapture should work also in Shadow DOM, r=masayuki
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 14 Mar 2019 21:40:19 +0200
changeset 522098 cc090db10bec9cc215fc448c309c21c16895a1db
parent 522071 7b9be2d40a83d028ef43b3ad88c16a616c4e178b
child 522099 df478b79c9b36db774066005f066de5d9909c5d6
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1534562
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 1534562, setPointerCapture should work also in Shadow DOM, r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D23574
dom/base/Element.h
dom/events/test/mochitest.ini
dom/events/test/test_bug1534562.html
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -1126,17 +1126,17 @@ class Element : public FragmentOrElement
         aPointerId != PointerEventHandler::GetSpoofedPointerIdForRFP()) {
       aError.Throw(NS_ERROR_DOM_INVALID_POINTER_ERR);
       return;
     }
     if (!PointerEventHandler::GetPointerInfo(aPointerId, activeState)) {
       aError.Throw(NS_ERROR_DOM_INVALID_POINTER_ERR);
       return;
     }
-    if (!IsInUncomposedDoc()) {
+    if (!IsInComposedDoc()) {
       aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
       return;
     }
     if (OwnerDoc()->GetPointerLockElement()) {
       // Throw an exception 'InvalidStateError' while the page has a locked
       // element.
       aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
       return;
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -204,14 +204,16 @@ skip-if = toolkit == 'android'
 support-files = window_bug1429572.html
 [test_bug1446834.html]
 support-files = file_bug1446834.html
 [test_bug1447993.html]
 support-files = window_bug1447993.html
 skip-if = toolkit == 'android'
 [test_bug1484371.html]
 support-files = file_bug1484371.html
+[test_bug1534562.html]
+skip-if = toolkit == 'android' # Bug 1312791
 [test_dnd_with_modifiers.html]
 [test_hover_mouseleave.html]
 [test_marquee_events.html]
 [test_slotted_mouse_event.html]
 [test_slotted_text_click.html]
 [test_unbound_before_in_active_chain.html]
new file mode 100644
--- /dev/null
+++ b/dom/events/test/test_bug1534562.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1534562
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1534562</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+
+  /** Test for Bug 1534562 **/
+
+  function runTest() {
+    var host = document.getElementById("host");
+    var shadow = host.attachShadow({mode: 'open'});
+    var shadowDiv = document.createElement('div');
+    shadowDiv.style.cssText = "height: 100%; width: 100%";
+    shadowDiv.onpointerdown = function (e) {
+      shadowDiv.setPointerCapture(e.pointerId);
+    };
+    var shadowDivGotPointerMove = false;
+    shadowDiv.onpointermove = function(e) {
+      shadowDivGotPointerMove = true;
+    }
+    shadow.appendChild(shadowDiv);
+    host.offsetLeft; // Flush layout.
+
+    synthesizeMouseAtCenter(shadowDiv, { type: "mousedown" });
+    synthesizeMouseAtCenter(document.getElementById("lightDOM"),  { type: "mousemove" });
+    ok(shadowDivGotPointerMove, "shadowDiv should have got pointermove event.");
+    synthesizeMouseAtCenter(document.getElementById("lightDOM"),  { type: "mouseup" });
+    SimpleTest.finish();
+  }
+
+  SimpleTest.waitForExplicitFinish();
+  SimpleTest.waitForFocus(runTest);
+
+
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1534562">Mozilla Bug 1534562</a>
+<div id="host" style="height: 50px; width: 50px;">
+</div>
+<div id="lightDOM" style="height: 50px; width: 50px;">
+</div>
+</body>
+</html>