Bug 1271125 part 1 - wrap() only for non-chrome; r=jmaher
authorAryeh Gregor <ayg@aryeh.name>
Sat, 29 Oct 2016 22:54:42 +0300
changeset 347291 0f35e2e5b575208e58da7609de573563d072c4c8
parent 347290 6357eaf453b016145325e59c4d1737d17b5d04e5
child 347292 53516fd74efbc2ed9e124eb4bd6345b878d77eca
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1271125
milestone52.0a1
Bug 1271125 part 1 - wrap() only for non-chrome; r=jmaher Checking window.Components is a heuristic already used at the top of the file for initializing _EU_C*, and it seems to work on try. MozReview-Commit-ID: 3nbFAEJMY7h
testing/mochitest/tests/SimpleTest/EventUtils.js
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -1810,17 +1810,20 @@ function synthesizeDragStart(element, ex
     aWindow = window;
   x = x || 2;
   y = y || 2;
   const step = 9;
 
   var result = "trapDrag was not called";
   var trapDrag = function(event) {
     try {
-      var dataTransfer = event.dataTransfer;
+      // We must wrap only in plain mochitests, not chrome
+      var c = Object.getOwnPropertyDescriptor(window, 'Components');
+      var dataTransfer = c.value && !c.writable
+        ? event.dataTransfer : SpecialPowers.wrap(event.dataTransfer);
       result = null;
       if (!dataTransfer)
         throw "no dataTransfer";
       if (expectedDragData == null ||
           dataTransfer.mozItemCount != expectedDragData.length)
         throw dataTransfer;
       for (var i = 0; i < dataTransfer.mozItemCount; i++) {
         var dtTypes = dataTransfer.mozTypesAt(i);