title: How to Create a TouchEvent in Chrome?
body: <p>The <a href="http://www.w3.org/TR/2011/WD-touch-events-20110505/#idl-def-TouchEvent" rel="nofollow">W3C specification</a> declares <code>initTouchEvent</code> as following:</p>
  
  <pre><code>void initTouchEvent (in DOMString    type,
                       in boolean      canBubble,
                       in boolean      cancelable,
                       in AbstractView view,
                       in long         detail,
                       in boolean      ctrlKey,
                       in boolean      altKey,
                       in boolean      shiftKey,
                       in boolean      metaKey,
                       in TouchList    touches,
                       in TouchList    targetTouches,
                       in TouchList    changedTouches);
  </code></pre>
  
  <p>However, when I try it in Chrome 44:</p>
  
  <pre><code>var e = document.createEvent('TouchEvent');
  e.initTouchEvent("touchstart", true, true, window, 1,
                   false, false, false, false, touches, null, null);
  </code></pre>
  
  <p>where <code>touches</code> is a valid <code>TouchList</code>, this is what Chrome created:</p>
  
  <pre><code>&gt; TouchEvent {}
      altKey: false
      bubbles: true
      cancelBubble: false
      cancelable: true
      changedTouches: null
      charCode: 0
      ctrlKey: true
      currentTarget: null
      defaultPrevented: false
      detail: 0
      eventPhase: 0
      keyCode: 0
      layerX: 0
      layerY: 0
      metaKey: false
      pageX: 0
      pageY: 0
      path: Array[0]
      returnValue: true
      shiftKey: false
      srcElement: null
      target: null
      targetTouches: null
      timeStamp: 1435339572699
      touches: null
      type: "[object Window]"
      view: null
      which: 0
  </code></pre>
  
  <p>Look closely at the <code>type</code> field. Seems like Chrome is not following the spec where the 4th parameter turned into the type instead of the 1st parameter.</p>
  
  <p>This brings us the question, that how do I actually create a <code>TouchEvent</code> in Chrome since it does not follow the spec?</p>