Bug 1055040 - Send mouse events base on canvas position and enable this test case on all B2G builds. r=ehsan, a=test-only
authorC.J. Ku <cku@mozilla.com>
Tue, 19 Aug 2014 19:38:00 -0400
changeset 208346 fadc34768c8b
parent 208345 b554afc480aa
child 208347 023ef0541072
push id3835
push userryanvm@gmail.com
push date2014-08-20 22:04 +0000
treeherdermozilla-beta@54949d681a14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, test-only
bugs1055040
milestone32.0
Bug 1055040 - Send mouse events base on canvas position and enable this test case on all B2G builds. r=ehsan, a=test-only
layout/generic/test/mochitest.ini
layout/generic/test/test_bug470212.html
--- a/layout/generic/test/mochitest.ini
+++ b/layout/generic/test/mochitest.ini
@@ -48,17 +48,16 @@ skip-if = (toolkit == 'gonk' && debug) #
 [test_bug448987.html]
 skip-if = true # Bug 932296
 support-files = file_bug448987.html file_bug448987_ref.html file_bug448987_notref.html
 [test_bug449653.html]
 support-files = file_bug449653_1.html file_bug449653_1_ref.html
 [test_bug460532.html]
 [test_bug468167.html]
 [test_bug470212.html]
-skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(shift mouse select not working in b2g) b2g-desktop(shift mouse select not working in b2g)
 [test_bug488417.html]
 skip-if = true # Bug 489560
 [test_bug496275.html]
 skip-if = toolkit == 'android' #CRASH_DUMP
 [test_bug503813.html]
 skip-if = toolkit == 'android' #CRASH_DUMP
 [test_bug507902.html]
 skip-if = true # Bug 510001
--- a/layout/generic/test/test_bug470212.html
+++ b/layout/generic/test/test_bug470212.html
@@ -6,31 +6,44 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 470212 -  crash [@ nsContentUtils::ComparePoints]</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=470212">Mozilla Bug 470212</a>
 <div style="width: 200px;">
 <ca>
-<canvas style="border: 1px solid black;"></canvas>
+<canvas style="border: 1px solid black;" id="dragSource"></canvas>
 </ca>
 </div>
 
 <pre id="test">
 <script>
 function doShiftDrag(){
   setTimeout(function() {
     var wu = SpecialPowers.DOMWindowUtils;
-    wu.sendMouseEvent('mousedown',  0, 0, 0, 1, 4);
-    wu.sendMouseEvent('mousemove',  60, 10, 0, 0, 4);
-    wu.sendMouseEvent('mousemove',  70, 250, 0, 0, 4);
+    var canvas = document.getElementById("dragSource");
+    var canvasRect = canvas.getBoundingClientRect();
+
+    // Drag canvas element starts with a mouse down event, combine with shift
+    // key, follows by two mouse move events.
+
+    // Press on left-top corner of the canvas element.
+    wu.sendMouseEvent('mousedown',  canvasRect.left, canvasRect.top, 0, 1, 4);
+    // Move to the center of this cavas element.
+    wu.sendMouseEvent('mousemove',  canvasRect.left + (canvasRect.width / 2),
+                      canvasRect.top + (canvasRect.height / 2), 0, 0, 4);
+    // move out of cavas's region.
+    wu.sendMouseEvent('mousemove',  canvasRect.left + (canvasRect.width / 2),
+                      canvasRect.bottom + 10, 0, 0, 4);
 
     is(window.getSelection().rangeCount, 0, "rangeCount should be 0");
-    wu.sendMouseEvent('mouseup',  70, 250, 0, 0, 4);
+
+    wu.sendMouseEvent('mouseup', canvasRect.left + (canvasRect.width / 2),
+                      canvasRect.bottom + 10, 0, 0, 4);
 
     SimpleTest.finish();
   }, 0);
 }
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(doShiftDrag);
 </script>