<?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>21068</bug_id>
          
          <creation_ts>2013-02-21 09:20:46 +0000</creation_ts>
          <short_desc>event.isTrusted should be [Unforgeable]</short_desc>
          <delta_ts>2013-02-21 11:02:20 +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>DOM</component>
          <version>unspecified</version>
          <rep_platform>All</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Igor Bukanov">igor</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>bruant.d</cc>
    
    <cc>mike</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>83474</commentid>
    <comment_count>0</comment_count>
    <who name="Igor Bukanov">igor</who>
    <bug_when>2013-02-21 09:20:46 +0000</bug_when>
    <thetext>Currently isTrusted attribute in the Event is defined as readonly property:

http://www.w3.org/TR/DOM-Level-3-Events/#interface-Event :

...
readonly attribute boolean        isTrusted;

That defines a configurable property on the event prototype. As such the attribute could be trivially forged to mark synthetic events as trusted using Object.defineProperty to set the property on the event itself:

var e = document.createEvent(&quot;MouseEvents&quot;); 
Object.defineProperty(e, &quot;isTrusted&quot;, { value: true }); 
alert(typeof e.isTrusted+&quot; &quot;+e.isTrusted);

This fragment shows &quot;boolean true&quot; in Firefox 19 that implements the current spec. This makes isTrusted pretty useless in code like a popup blocker. For example, one can try to replace event.isTrusted check with:

var getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(document.createEvent(&quot;MouseEvents&quot;)), &quot;isTrusted&quot;).get;

getter.call(event)

that extracts the getter from the prototype and apply it directly to the object. But then one has to consider that isTrusted could be redefined on the prototype as well since the property is configurable.

To fix this and to make isTrusted really trustworthy the attribute should e changed from readonly to [Unforgeable].

See also https://bugzilla.mozilla.org/show_bug.cgi?id=637248</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83477</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-02-21 11:02:20 +0000</bug_when>
    <thetext>Thanks Igor!

https://github.com/whatwg/dom/commit/559d92560a94b5bebc3fdc9f037f971af7e9beb5</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>