Bug 1016184 - part 3f - Fix test_paste_selection.html. r=ehsan
☠☠ backed out by 1f216e2e339e ☠ ☠
authorTing-Yu Lin <tlin@mozilla.com>
Sun, 27 Jul 2014 00:20:00 +0200
changeset 196990 ca2fd0f41a122dfb0c1e6a046abe9adcaf9b5638
parent 196989 84dacf014e392358660a7d22d7d8a20f64b04d04
child 196991 a52c9d67492739fbf71e391bcecf5671db9b16c5
push id47020
push usercbook@mozilla.com
push dateThu, 31 Jul 2014 06:41:00 +0000
treeherdermozilla-inbound@0893f2ef4b9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1016184
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1016184 - part 3f - Fix test_paste_selection.html. r=ehsan Thank Olli Pettay <bugs@pettay.fi> for suggesting sendMouseEventToWindow(). This is a tremendous help!
dom/tests/mochitest/general/test_paste_selection.html
--- a/dom/tests/mochitest/general/test_paste_selection.html
+++ b/dom/tests/mochitest/general/test_paste_selection.html
@@ -55,25 +55,31 @@ function selectArea()
 }
 
 var selectionPasted = false;
 var globalPasted = false;
 
 function pasteArea()
 {
   var pasteArea = document.getElementById("paste-selection-area");
+  var pasteAreaRect = pasteArea.getBoundingClientRect();
+  var pasteAreaCenterX = pasteAreaRect.left + pasteAreaRect.width/2;
+  var pasteAreaCenterY = pasteAreaRect.top + pasteAreaRect.height/2;
+  var util = SpecialPowers.getDOMWindowUtils(window);
+
   pasteArea.focus();
-  synthesizeMouse(pasteArea, 8, 8, { button: 1 });
+  util.sendMouseEventToWindow("mousedown", pasteAreaCenterX, pasteAreaCenterY, 1, 1, 0, true);
+  util.sendMouseEventToWindow("mouseup",   pasteAreaCenterX, pasteAreaCenterY, 1, 1, 0, true);
 
   var usesMouseButtonPaste = SpecialPowers.getBoolPref("middlemouse.paste");
   if (usesMouseButtonPaste) {
     // The data transfer should contain the selection data when the selection clipboard is supported,
     // not the global clipboard data.
     var expectedText = supportsSelectionClipboard ? "COPY TEXT" : "CLIPBOARD";
-    is(document.getElementById("paste-selection-area").value, expectedText, "data pasted properly from selection");
+    is(document.getElementById("paste-selection-area").value, expectedText, "In pasteArea(): data pasted properly from selection");
     ok(selectionPasted, "selection event fired");
   }
   else {
     is(pasteArea.value, "", "data not pasted when middle click not supported");
   }
 
   var pasteArea = document.getElementById("paste-global-area");
   pasteArea.focus();
@@ -87,17 +93,17 @@ function pasteArea()
 function pastedSelection(event)
 {
   ok(SpecialPowers.getBoolPref("middlemouse.paste"), "paste on middle click is valid");
 
   // Mac and Windows shouldn't get here as the middle mouse preference is false by default
   ok(navigator.platform.indexOf("Mac") == -1 && navigator.platform.indexOf("Win") == -1, "middle click enabled on right platforms");
 
   var expectedText = supportsSelectionClipboard ? "COPY TEXT" : "CLIPBOARD";
-  is(event.clipboardData.getData("text/plain"), expectedText, "data pasted properly from selection");
+  is(event.clipboardData.getData("text/plain"), expectedText, "In pastedSelection(): data pasted properly from selection");
 
   selectionPasted = true;
 }
 
 function pastedGlobal(event)
 {
   // The data transfer should contain the global data.
   is(event.clipboardData.getData("text/plain"), "CLIPBOARD", "data correct in global clipboard data transfer");