<?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>25365</bug_id>
          
          <creation_ts>2014-04-16 12:17:53 +0000</creation_ts>
          <short_desc>About trusted=&quot;false&quot; in two event orders</short_desc>
          <delta_ts>2014-05-06 00:43:07 +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 - DOM3 Events</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Arkadiusz Michalski (Spirit)">crimsteam</reporter>
          <assigned_to name="Gary Kacmarcik">garykac</assigned_to>
          <cc>bugs</cc>
    
    <cc>garykac</cc>
    
    <cc>mike</cc>
    
    <cc>travil</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>103960</commentid>
    <comment_count>0</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-04-16 12:17:53 +0000</bug_when>
    <thetext>In two event orders:
https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-activation-event-order
https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#legacy-uievent-event-order

we have trusted=&quot;false&quot;, but what is trusted? Should not be isTrusted attribute?

If yes, then the other site, why in this orders click is not treated as trusted? For example, in FF and IE, when we move focus to &lt;button&gt; and press &apos;Enter&apos; or &apos;Space&apos; we get synthesized click event with isTrusted=&quot;true&quot;. In FF the same will be for synthesized DOMActivate. Chrome doesn&apos;t support isTrusted property.

Simple test:

&lt;button id=&quot;btn&quot;&gt;Move focus to this button and press Enter/Space&lt;/button&gt;
&lt;p style=&quot;color: blue;&quot;&gt;Detailed information for the captured events:&lt;/p&gt;
&lt;p id=&quot;info&quot;&gt;&lt;p/&gt;

&lt;script&gt;

	var btn= document.getElementById(&quot;btn&quot;);
	var info = document.getElementById(&quot;info&quot;);

	function readInfo(e){
	
		var data = &quot;Interface: &quot; + e
			+ &quot;&lt;br&gt;&quot; + &quot;e.type: &quot; + e.type
			+ &quot;&lt;br&gt;&quot; + &quot;e.target: &quot; + e.target
			+ &quot;&lt;br&gt;&quot; + &quot;e.isTrusted: &quot; + e.isTrusted + &quot;&lt;br&gt;&lt;br&gt;&quot;;
	
		info.innerHTML = info.innerHTML + data;
	
	}

	btn.addEventListener(&quot;keydown&quot;, readInfo)
	btn.addEventListener(&quot;DOMActivate&quot;, readInfo)
	btn.addEventListener(&quot;click&quot;, readInfo)

&lt;/script&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104236</commentid>
    <comment_count>1</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-04-23 00:57:41 +0000</bug_when>
    <thetext>Mmmm, maybe a holdover from an earlier &quot;trusted&quot; spec. I&apos;ll see about making this consistent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104237</commentid>
    <comment_count>2</comment_count>
    <who name="Gary Kacmarcik">garykac</who>
    <bug_when>2014-04-23 01:01:01 +0000</bug_when>
    <thetext>In section 3.5.2 &quot;Activation event order&quot;, the comment for &apos;click&apos; in the example says &apos;trusted&apos; instead of &apos;isTrusted&apos;.

Also in C.1.1 &quot;Activation event order&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104511</commentid>
    <comment_count>3</comment_count>
    <who name="Gary Kacmarcik">garykac</who>
    <bug_when>2014-04-27 20:14:24 +0000</bug_when>
    <thetext>trusted -&gt; isTrusted fixed in ED:
https://dvcs.w3.org/hg/dom3events/rev/abc0008f9a1d

As for the larger issue for *why* they are untrusted, I agree that this looks odd.

The trusted/isTrusted attribute was added in 2010, and started out with the exception for click and DOMActivate:

&quot;Most untrusted events should not trigger default actions, with the exception of click or DOMActivate events which have been synthesized and are managed by the user agents event as the default action of an activation trigger (see Activation triggers and behavior for more details); these user-agent-managed synthesized events have a have a trusted attribute value of false, but still initiate any default actions. All other untrusted events must behave as if the Event.preventDefault() method had been called on that event.&quot;

(see http://www.w3.org/TR/2010/WD-DOM-Level-3-Events-20100907/#trusted-events)


I don&apos;t know what the motivation was here, but it seems a weird exception:
* untrusted events shouldn&apos;t cause default actions
* click/DOMActivate synthesized events should be untrusted but still need to cause default actions.

So, I don&apos;t see why the synthesized click/DOMActivate events shouldn&apos;t be trusted. Then these events would be consistent with other events in terms of causing the default actions. Especially if FF/IE are currently generating these as trusted.

Is there some context that I&apos;m missing for why click/DOMActivate have these exceptions in the spec?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104512</commentid>
    <comment_count>4</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-04-27 20:33:30 +0000</bug_when>
    <thetext>Oh, I forgot about the chapter &quot;3.4 Trusted events&quot;, where this information exist.

Before some changes will be better test more cases in FF and IE, because I check only &lt;button&gt;. Anyway, &quot;untrusted&quot; in this case seems unnecessary complication.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104516</commentid>
    <comment_count>5</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-04-27 22:41:12 +0000</bug_when>
    <thetext>(In reply to Gary Kacmarcik from comment #3)

&gt; I don&apos;t know what the motivation was here, but it seems a weird exception:
&gt; * untrusted events shouldn&apos;t cause default actions
&gt; * click/DOMActivate synthesized events should be untrusted but still need to
&gt; cause default actions.


web relies on untrusted click to trigger default handling, at least for
links.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104517</commentid>
    <comment_count>6</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-04-27 23:06:37 +0000</bug_when>
    <thetext>Right, still exist sth like element.click()

http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#dom-click

which generate untrusted event but trigger default action. So description in &quot;3.4 Trusted events&quot; is correct.

Small test:
&lt;button id=&quot;btn&quot;&gt;Move focus to this button and press Enter/Space&lt;/button&gt;
&lt;p style=&quot;color: blue;&quot;&gt;Detailed information for the captured events:&lt;/p&gt;
&lt;p id=&quot;info&quot;&gt;&lt;p/&gt;

&lt;script&gt;

	var btn= document.getElementById(&quot;btn&quot;);
	var info = document.getElementById(&quot;info&quot;);

	function readInfo(e){
	
		var data = &quot;Interface: &quot; + e
			+ &quot;&lt;br&gt;&quot; + &quot;e.type: &quot; + e.type
			+ &quot;&lt;br&gt;&quot; + &quot;e.target: &quot; + e.target
			+ &quot;&lt;br&gt;&quot; + &quot;e.isTrusted: &quot; + e.isTrusted + &quot;&lt;br&gt;&lt;br&gt;&quot;;
	
		info.innerHTML = info.innerHTML + data;
	
	}

	btn.addEventListener(&quot;keydown&quot;, readInfo)
	btn.addEventListener(&quot;DOMActivate&quot;, readInfo)
	btn.addEventListener(&quot;click&quot;, readInfo)
	
	btn.click();

&lt;/script&gt;

But, in IE11 above return e.isTrusted=&quot;true&quot; (incorrect with HTML5), when Firefox has &quot;false&quot;.

Event orders in cited examples sholud inform if it represented trusted (like manual key press) or untrusted case (call method from script) and everything would be obvious.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104591</commentid>
    <comment_count>7</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-04-28 22:09:02 +0000</bug_when>
    <thetext>In looking through this, we don&apos;t see a problem with actually letting the isTrusted value be &apos;true&apos; for the synthesized (by the user-agent) click events. This would change some of the isTrusted values in examples 3.5.2, and C.1.1. 

(Also we will re-write section 3.4 to be more clear -- it&apos;s really hard to read at the moment.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104600</commentid>
    <comment_count>8</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-04-28 22:26:44 +0000</bug_when>
    <thetext>Tried to address this in:

https://dvcs.w3.org/hg/dom3events/rev/ddb380ad70de</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104880</commentid>
    <comment_count>9</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-04-30 23:11:53 +0000</bug_when>
    <thetext>C.1.1 Activation event order (second order):

3. DOMActivate 	default action, if supported by the user agent; synthesized; isTrusted=&quot;false&quot;

not isTrusted=&quot;true&quot;?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105141</commentid>
    <comment_count>10</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-05-06 00:43:07 +0000</bug_when>
    <thetext>Oh, thanks!

Followup changelist: https://dvcs.w3.org/hg/dom3events/rev/0e86d968e9d4</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>