Bug 974305 - Add a test for WidgetPointerEvent::AssignPointerEventData(). r=smaug
authorMaksim Lebedev <Alessarik@gmail.com>
Wed, 22 Apr 2015 16:09:10 +0900
changeset 259380 100b9eafbbfed8dee4827abe56bacea81c9a1bef
parent 259379 91e9b0c36889b9c42c5b295f60d63015130f060c
child 259381 0b6996293b8f7997281da38d85d35543ddf0fdbf
push id8007
push userraliiev@mozilla.com
push dateMon, 11 May 2015 19:23:16 +0000
treeherdermozilla-aurora@e2ce1aac996e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs974305
milestone40.0a1
Bug 974305 - Add a test for WidgetPointerEvent::AssignPointerEventData(). r=smaug
widget/tests/test_assign_event_data.html
--- a/widget/tests/test_assign_event_data.html
+++ b/widget/tests/test_assign_event_data.html
@@ -24,36 +24,62 @@
     @keyframes slidein {
       from {
         margin-left: 100%;
       }
       to {
         margin-left: 0;
       }
     }
+    #pointer-target {
+      border: 1px dashed red;
+      background: yellow;
+      margin: 0px 10px;
+      padding: 0px 10px;
+    }
+    #scrollable-div {
+      background: green;
+      overflow: auto;
+      width: 30px;
+      height: 30px;
+    }
+    #scrolled-div {
+      background: magenta;
+      width: 10px;
+      height: 10px;
+    }
+    #form {
+      background: silver;
+      padding: 0px 10px;
+    }
+    #animated-div {
+      background: cyan;
+      padding: 0px 10px;
+    }
   </style>
 </head>
 <body>
 <div id="display">
   <input id="input-text">
   <button id="button">button</button>
   <a id="a" href="about:blank">hyper link</a>
-  <div id="scrollable-div" style="overflow: auto; width: 30px; height: 30px;"><div id="scrolled-div" style="width: 10px; height: 10px;"></div></div>
-  <form id="form"></form>
-  <div id="animated-div"></div>
+  <span id="pointer-target">span</span>
+  <div id="scrollable-div"><div id="scrolled-div"></div></div>
+  <form id="form">form</form>
+  <div id="animated-div">&nbsp;</div>
 </div>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
-SimpleTest.expectAssertions(0, 32);
+SimpleTest.expectAssertions(0, 34);
 
 const kIsMac = (navigator.platform.indexOf("Mac") == 0);
 const kIsWin = (navigator.platform.indexOf("Win") == 0);
 
 var gEvent = null;
 var gCopiedEvent = [];
 var gCallback = null;
 var gCallPreventDefault = false;
@@ -561,16 +587,42 @@ const kTests = [
     dispatchEvent: function () {
       document.getElementById("animated-div").removeChild(document.getElementById("inserted-div"));
     },
     canRun: function () {
       return true;
     },
     todoMismatch: [],
   },
+  { description: "PointerEvent (pointerdown)",
+    targetID: "pointer-target", eventType: "pointerdown",
+    dispatchEvent: function () {
+      var elem = document.getElementById(this.targetID);
+      var rect = elem.getBoundingClientRect();
+      synthesizePointer(elem, rect.width/2, rect.height/2,
+                        { type: this.eventType, button: 1, clickCount: 1, inputSource: 2, pressure: 0.25, isPrimary: true });
+    },
+    canRun: function () {
+      return true;
+    },
+    todoMismatch: [],
+  },
+  { description: "PointerEvent (pointerup)",
+    targetID: "pointer-target", eventType: "pointerup",
+    dispatchEvent: function () {
+      var elem = document.getElementById(this.targetID);
+      var rect = elem.getBoundingClientRect();
+      synthesizePointer(elem, rect.width/2, rect.height/2,
+                        { type: this.eventType, button: -1, ctrlKey: true, shiftKey: true, altKey: true, isSynthesized: false });
+    },
+    canRun: function () {
+      return true;
+    },
+    todoMismatch: [],
+  },
 ];
 
 function doTest(aTest)
 {
   if (!aTest.canRun()) {
     SimpleTest.executeSoon(runNextTest);
     return;
   }
@@ -633,17 +685,17 @@ function runNextTest()
     return;
   }
   doTest(kTests[gIndex]);
 }
 
 function init()
 {
   SpecialPowers.pushPrefEnv({"set":[["middlemouse.contentLoadURL", false],
-  			            ["middlemouse.paste", false],
+                                    ["middlemouse.paste", false],
                                     ["general.autoScroll", false],
                                     ["mousewheel.default.action", 0],
                                     ["mousewheel.default.action.override_x", -1],
                                     ["mousewheel.with_shift.action", 0],
                                     ["mousewheel.with_shift.action.override_x", -1],
                                     ["mousewheel.with_control.action", 0],
                                     ["mousewheel.with_control.action.override_x", -1],
                                     ["mousewheel.with_alt.action", 0],