<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>20017</bug_id>
          
          <creation_ts>2012-11-20 11:25:29 +0000</creation_ts>
          <short_desc>[Shadow]: Retargeting relatedTarget algorithm prevents events from be fired if a user creates a MouseEvent manually with a relatedTarget which is same to the target.</short_desc>
          <delta_ts>2015-05-12 01:36:12 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>28552</blocked>
    
    <blocked>28564</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Hayato Ito">hayato</reporter>
          <assigned_to name="Hayato Ito">hayato</assigned_to>
          <cc>annevk</cc>
    
    <cc>kenjibaheux</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>78523</commentid>
    <comment_count>0</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-11-20 11:25:29 +0000</bug_when>
    <thetext>Suppose a user fires an MouseEvent manually as follows:

(A)
    var target = document.getElementById(&quot;target&quot;);
    var newEvent = document.createEvent(&quot;MouseEvent&quot;);
    newEvent.initMouseEvent(&quot;mouseover&quot;, false, false, window, 0, 10, 10, 10, 10, false, false, false, false, 0, target);
    target.dispatchEvent(newEvent);

In this case, an event should not be fired even at the target node if we follow the (5.2.2):

  &gt; Event listeners must not be invoked on a node for which the target and relatedTarget are the same.

It seems that UA&apos;s native MouseEvent never has the relatedTarget which is the same to the target node.
But a user generated event can have such a relatedTarget which is the same to the target as I described.

For reference, firefox and webkit fires a &apos;mouseover&apos; event for (A) in the current implementations.


How should we resolve this?

Option 1): It&apos;s okay not to fire an event for (A).
  I am afraid that this will break the Web.

  The spec, http://www.w3.org/TR/2001/WD-DOM-Level-3-Events-20010823/events.html, does not tell anything about what we we should do in this case.


Option 2): Modify the shadow dom spec so that an event should be fired for (A).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78945</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-11-27 19:22:28 +0000</bug_when>
    <thetext>How about this: state explicitly that the wording in spec only applies to events dispatched by the UA?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78979</commentid>
    <comment_count>2</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-11-28 07:40:44 +0000</bug_when>
    <thetext>I am afraid that will mean event relatedTarget retargeting does not happen at all for user generated events?

We have to do retargeting for user generated events anyway so that we don&apos;t expose nodes in Shadow Tree, don&apos;t we?

(In reply to comment #1)
&gt; How about this: state explicitly that the wording in spec only applies to
&gt; events dispatched by the UA?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78981</commentid>
    <comment_count>3</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2012-11-28 07:52:07 +0000</bug_when>
    <thetext>The current WIP patch in WebKit (https://bugs.webkit.org/show_bug.cgi?id=102681) implements the following behavior:

If user fires an custom event with a relatedTarget which is same to the target:

- Dispatch an event on the ancestor nodes in the shadow tree where the event is originally fired (even though these nodes&apos;s target and relatedTarget are same)

- Don&apos;t dispatch an event for ancestors nodes *beyond* the first shadow boundary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79718</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-12-08 00:22:57 +0000</bug_when>
    <thetext>I am trying to figure out how to specify this. The whole notion that we&apos;re treating synthetic events differently smells wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79719</commentid>
    <comment_count>5</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-12-08 00:23:31 +0000</bug_when>
    <thetext>Anne, would love to have your insight here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79747</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-12-08 09:55:09 +0000</bug_when>
    <thetext>I would start by removing the requirements around &quot;In general&quot;. relatedTarget should follow from the algorithm and you do not want two places requiring things about it. Note that relatedTarget can presumably be in a distinct tree as well. In fact, the way it is defined now it can even be an XMLHttpRequest object. So you need to account somehow for these weird cases when doing adjustment. Perhaps just be setting it to the adjusted target?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99377</commentid>
    <comment_count>7</comment_count>
    <who name="Kenji Baheux">kenjibaheux</who>
    <bug_when>2014-01-29 00:44:13 +0000</bug_when>
    <thetext>(Memo)
This is affecting the following test:
    https://github.com/w3c/web-platform-tests/blob/master/shadow-dom/events/event-retargeting/test-002.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119775</commentid>
    <comment_count>8</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-04-22 22:54:46 +0000</bug_when>
    <thetext>This topic looks an old (and minor?) issue, the issue still remains, I think.

My opinion doesn&apos;t change. I&apos;m not sure how we should do.

The speccing comment #3 is reasonable? I&apos;m not confident.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119838</commentid>
    <comment_count>9</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-04-23 18:41:42 +0000</bug_when>
    <thetext>The right approach here is to only do the relatedTarget check when the event is trusted.

So if the event is trusted and the relatedTarget check returns true, pick a limited path at dispatch time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119851</commentid>
    <comment_count>10</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-04-23 20:58:06 +0000</bug_when>
    <thetext>*** Bug 22793 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120249</commentid>
    <comment_count>11</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-05-11 04:58:42 +0000</bug_when>
    <thetext>I&apos;m fine with comment #9.

Unless there is no objection, let me spec it.

I&apos;m assuming that an untrusted event which has a relatedTarget originated the component wouldn&apos;t be *noisy* for the users of the components.

I guess the number of such an event is limited.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120254</commentid>
    <comment_count>12</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-05-12 01:36:12 +0000</bug_when>
    <thetext>Done at https://github.com/w3c/webcomponents/commit/58c8aec79039f403157a18c05b0125c134275e8a.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>