Bug 1472887, focusin/out should be composed, and mark chrome event target chain items as chrome, r=masayuki

This commit is contained in:
Olli Pettay 2018-07-09 17:40:01 +03:00
parent 9df2f94e3d
commit 7146d67afe
4 changed files with 12 additions and 3 deletions

View File

@ -773,6 +773,10 @@ MayRetargetToChromeIfCanNotHandleEvent(
EventTargetChainItem* chromeTargetEtci = EventTargetChainItem* chromeTargetEtci =
EventTargetChainItemForChromeTarget(aChain, aContent, aChildEtci); EventTargetChainItemForChromeTarget(aChain, aContent, aChildEtci);
if (chromeTargetEtci) { 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); chromeTargetEtci->GetEventTargetParent(aPreVisitor);
return chromeTargetEtci; return chromeTargetEtci;
} }

View File

@ -1,4 +1,3 @@
[test-003.html] [test-003.html]
[A_05_05_03_T01] prefs: [dom.webcomponents.shadowdom.enabled:true]
expected: FAIL

View File

@ -45,6 +45,7 @@ A_05_05_03_T01.step(unit(function (ctx) {
s.appendChild(input2); s.appendChild(input2);
input1.addEventListener('focusin', A_05_05_03_T01.step_func(function(event) { 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().length, 7);
assert_equals(event.composedPath()[0].id, 'input1'); assert_equals(event.composedPath()[0].id, 'input1');
assert_equals(event.composedPath()[1].id, 'shadow'); assert_equals(event.composedPath()[1].id, 'shadow');
@ -55,6 +56,10 @@ A_05_05_03_T01.step(unit(function (ctx) {
assert_equals(event.composedPath()[6], ctx.iframes[0].contentWindow); assert_equals(event.composedPath()[6], ctx.iframes[0].contentWindow);
}), false); }), 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) { input2.addEventListener('focusin', A_05_05_03_T01.step_func(function(event) {
assert_equals(event.composedPath().length, 2); assert_equals(event.composedPath().length, 2);
assert_equals(event.composedPath()[0].id, 'input2'); assert_equals(event.composedPath()[0].id, 'input2');

View File

@ -932,7 +932,8 @@ public:
mFlags.mComposed = mMessage == eEditorInput; mFlags.mComposed = mMessage == eEditorInput;
break; break;
case eFocusEventClass: case eFocusEventClass:
mFlags.mComposed = mMessage == eBlur || mMessage == eFocus; mFlags.mComposed = mMessage == eBlur || mMessage == eFocus ||
mMessage == eFocusOut || mMessage == eFocusIn;
break; break;
case eKeyboardEventClass: case eKeyboardEventClass:
mFlags.mComposed = mMessage == eKeyDown || mMessage == eKeyUp || mFlags.mComposed = mMessage == eKeyDown || mMessage == eKeyUp ||