This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25365 - About trusted="false" in two event orders
Summary: About trusted="false" in two event orders
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - DOM3 Events (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Gary Kacmarcik
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-16 12:17 UTC by Arkadiusz Michalski (Spirit)
Modified: 2014-05-06 00:43 UTC (History)
5 users (show)

See Also:


Attachments

Description Arkadiusz Michalski (Spirit) 2014-04-16 12:17:53 UTC
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="false", 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 <button> and press 'Enter' or 'Space' we get synthesized click event with isTrusted="true". In FF the same will be for synthesized DOMActivate. Chrome doesn't support isTrusted property.

Simple test:

<button id="btn">Move focus to this button and press Enter/Space</button>
<p style="color: blue;">Detailed information for the captured events:</p>
<p id="info"><p/>

<script>

	var btn= document.getElementById("btn");
	var info = document.getElementById("info");

	function readInfo(e){
	
		var data = "Interface: " + e
			+ "<br>" + "e.type: " + e.type
			+ "<br>" + "e.target: " + e.target
			+ "<br>" + "e.isTrusted: " + e.isTrusted + "<br><br>";
	
		info.innerHTML = info.innerHTML + data;
	
	}

	btn.addEventListener("keydown", readInfo)
	btn.addEventListener("DOMActivate", readInfo)
	btn.addEventListener("click", readInfo)

</script>
Comment 1 Travis Leithead [MSFT] 2014-04-23 00:57:41 UTC
Mmmm, maybe a holdover from an earlier "trusted" spec. I'll see about making this consistent.
Comment 2 Gary Kacmarcik 2014-04-23 01:01:01 UTC
In section 3.5.2 "Activation event order", the comment for 'click' in the example says 'trusted' instead of 'isTrusted'.

Also in C.1.1 "Activation event order"
Comment 3 Gary Kacmarcik 2014-04-27 20:14:24 UTC
trusted -> 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:

"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."

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


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

So, I don't see why the synthesized click/DOMActivate events shouldn'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'm missing for why click/DOMActivate have these exceptions in the spec?
Comment 4 Arkadiusz Michalski (Spirit) 2014-04-27 20:33:30 UTC
Oh, I forgot about the chapter "3.4 Trusted events", where this information exist.

Before some changes will be better test more cases in FF and IE, because I check only <button>. Anyway, "untrusted" in this case seems unnecessary complication.
Comment 5 Olli Pettay 2014-04-27 22:41:12 UTC
(In reply to Gary Kacmarcik from comment #3)

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


web relies on untrusted click to trigger default handling, at least for
links.
Comment 6 Arkadiusz Michalski (Spirit) 2014-04-27 23:06:37 UTC
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 "3.4 Trusted events" is correct.

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

<script>

	var btn= document.getElementById("btn");
	var info = document.getElementById("info");

	function readInfo(e){
	
		var data = "Interface: " + e
			+ "<br>" + "e.type: " + e.type
			+ "<br>" + "e.target: " + e.target
			+ "<br>" + "e.isTrusted: " + e.isTrusted + "<br><br>";
	
		info.innerHTML = info.innerHTML + data;
	
	}

	btn.addEventListener("keydown", readInfo)
	btn.addEventListener("DOMActivate", readInfo)
	btn.addEventListener("click", readInfo)
	
	btn.click();

</script>

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

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.
Comment 7 Travis Leithead [MSFT] 2014-04-28 22:09:02 UTC
In looking through this, we don't see a problem with actually letting the isTrusted value be 'true' 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's really hard to read at the moment.)
Comment 8 Travis Leithead [MSFT] 2014-04-28 22:26:44 UTC
Tried to address this in:

https://dvcs.w3.org/hg/dom3events/rev/ddb380ad70de
Comment 9 Arkadiusz Michalski (Spirit) 2014-04-30 23:11:53 UTC
C.1.1 Activation event order (second order):

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

not isTrusted="true"?
Comment 10 Travis Leithead [MSFT] 2014-05-06 00:43:07 UTC
Oh, thanks!

Followup changelist: https://dvcs.w3.org/hg/dom3events/rev/0e86d968e9d4