Bug 1472887, focusin/out should be composed, and mark chrome event target chain items as chrome, r=masayuki
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 09 Jul 2018 17:40:01 +0300
changeset 425558 45853b30dd6b750493fd7440333e71889a40e93b
parent 425557 b6f878099e46a609f1e504e12e14afc89307798c
child 425559 086667f4a18d7ef2588a769cab02b9b58b463548
push id34259
push usertoros@mozilla.com
push dateTue, 10 Jul 2018 09:45:44 +0000
treeherdermozilla-central@a675c5d7eb76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1472887
milestone63.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 1472887, focusin/out should be composed, and mark chrome event target chain items as chrome, r=masayuki
dom/events/EventDispatcher.cpp
testing/web-platform/meta/shadow-dom/untriaged/events/event-dispatch/test-003.html.ini
testing/web-platform/tests/shadow-dom/untriaged/events/event-dispatch/test-003.html
widget/BasicEvents.h
--- a/dom/events/EventDispatcher.cpp
+++ b/dom/events/EventDispatcher.cpp
@@ -768,16 +768,20 @@ MayRetargetToChromeIfCanNotHandleEvent(
     EventTargetChainItem::DestroyLast(aChain, aTargetEtci);
   }
   if (aPreVisitor.mAutomaticChromeDispatch && aContent) {
     aPreVisitor.mRelatedTargetRetargetedInCurrentScope = false;
     // Event target couldn't handle the event. Try to propagate to chrome.
     EventTargetChainItem* chromeTargetEtci =
       EventTargetChainItemForChromeTarget(aChain, aContent, aChildEtci);
     if (chromeTargetEtci) {
+      // If we propagate to chrome, need to ensure we mark
+      // EventTargetChainItem to be chrome handler so that event.composedPath()
+      // can return the right value.
+      chromeTargetEtci->SetIsChromeHandler(true);
       chromeTargetEtci->GetEventTargetParent(aPreVisitor);
       return chromeTargetEtci;
     }
   }
   return nullptr;
 }
 
 static bool
--- a/testing/web-platform/meta/shadow-dom/untriaged/events/event-dispatch/test-003.html.ini
+++ b/testing/web-platform/meta/shadow-dom/untriaged/events/event-dispatch/test-003.html.ini
@@ -1,4 +1,3 @@
 [test-003.html]
-  [A_05_05_03_T01]
-    expected: FAIL
+  prefs: [dom.webcomponents.shadowdom.enabled:true]
 
--- a/testing/web-platform/tests/shadow-dom/untriaged/events/event-dispatch/test-003.html
+++ b/testing/web-platform/tests/shadow-dom/untriaged/events/event-dispatch/test-003.html
@@ -40,26 +40,31 @@ A_05_05_03_T01.step(unit(function (ctx) 
     input1.setAttribute('id', 'input1');
     s.appendChild(input1);
 
     var input2 = d.createElement('input');
     input2.setAttribute('id', 'input2');
     s.appendChild(input2);
 
     input1.addEventListener('focusin', A_05_05_03_T01.step_func(function(event) {
+        assert_equals(event.composed, true);
         assert_equals(event.composedPath().length, 7);
         assert_equals(event.composedPath()[0].id, 'input1');
         assert_equals(event.composedPath()[1].id, 'shadow');
         assert_equals(event.composedPath()[2].id, 'host');
         assert_equals(event.composedPath()[3].tagName, 'BODY');
         assert_equals(event.composedPath()[4].tagName, 'HTML');
         assert_equals(event.composedPath()[5], d);
         assert_equals(event.composedPath()[6], ctx.iframes[0].contentWindow);
     }), false);
 
+    input1.addEventListener('focusout',  A_05_05_03_T01.step_func(function(event) {
+        assert_equals(event.composed, true);
+    }), false);
+
     input2.addEventListener('focusin', A_05_05_03_T01.step_func(function(event) {
         assert_equals(event.composedPath().length, 2);
         assert_equals(event.composedPath()[0].id, 'input2');
         assert_equals(event.composedPath()[1].id, 'shadow');
         A_05_05_03_T01.done();
     }), false);
 
     // Expected event path for #input1:
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -927,17 +927,18 @@ public:
                            mMessage == eDragEnter || mMessage == eDragExit ||
                            mMessage == eDragLeave || mMessage == eDragOver ||
                            mMessage == eDragStart || mMessage == eDrop;
         break;
       case eEditorInputEventClass:
         mFlags.mComposed = mMessage == eEditorInput;
         break;
       case eFocusEventClass:
-        mFlags.mComposed = mMessage == eBlur || mMessage == eFocus;
+        mFlags.mComposed = mMessage == eBlur || mMessage == eFocus ||
+                           mMessage == eFocusOut || mMessage == eFocusIn;
         break;
       case eKeyboardEventClass:
         mFlags.mComposed = mMessage == eKeyDown || mMessage == eKeyUp ||
                            mMessage == eKeyPress;
         break;
       case eMouseEventClass:
         mFlags.mComposed = mMessage == eMouseClick ||
                            mMessage == eMouseDoubleClick ||