Bug 1199729 - Part 5: Update tests for new DataTransfer behaviour, r=baku
authorMichael Layzell <michael@thelayzells.com>
Wed, 06 Sep 2017 11:38:30 -0400
changeset 429271 83f49da70519de37b7af25f89dcd2883bf4ee441
parent 429270 5d920dc2ba45a84ab6b3b9fcb5f0a43390bb3c77
child 429272 0ee09b4795cbfc759db5ea7bd0deb2e9674f8c13
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1199729
milestone57.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 1199729 - Part 5: Update tests for new DataTransfer behaviour, r=baku
dom/events/test/test_DataTransferItemList.html
dom/events/test/test_bug1327798.html
dom/events/test/test_bug508479.html
dom/tests/mochitest/general/test_clipboard_events.html
--- a/dom/events/test/test_DataTransferItemList.html
+++ b/dom/events/test/test_DataTransferItemList.html
@@ -125,16 +125,19 @@
     var dragenterFired = 0;
     over.addEventListener('dragenter', onDragEnter);
     function onDragEnter(e) {
       over.removeEventListener('dragenter', onDragEnter);
 
       var dt = e.dataTransfer;
       dragenterFired++;
 
+      // NOTE: This test is run with chrome privileges.
+      // For back-compat reasons, protected mode acts like readonly mode for
+      // chrome documents.
       readOnly(e);
     }
 
     var dropFired = 0;
     over.addEventListener('drop', onDrop);
     function onDrop(e) {
       over.removeEventListener('drop', onDrop);
 
--- a/dom/events/test/test_bug1327798.html
+++ b/dom/events/test/test_bug1327798.html
@@ -29,18 +29,18 @@ SimpleTest.waitForFocus(() => {
   // does the clipboard contain text/unicode data ?
   ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1, clipboard.kGlobalClipboard),
      "clipboard contains unicode text");
   // does the clipboard contain text/html data ?
   ok(clipboard.hasDataMatchingFlavors(["text/html"], 1, clipboard.kGlobalClipboard),
      "clipboard contains html text");
 
   window.addEventListener("paste", (e) => {
-    ok(e.clipboardData.types.indexOf('text/html'), -1, "clipboardData shouldn't have text/html");
-    ok(e.clipboardData.getData('text/plain'), "Formatted Text",  "getData(text/plain) should return plain text");
+    is(e.clipboardData.types.indexOf('text/html'), -1, "clipboardData shouldn't have text/html");
+    is(e.clipboardData.getData('text/plain'), "Formatted Text",  "getData(text/plain) should return plain text");
     SimpleTest.finish();
   });
 
   SpecialPowers.doCommand(window, "cmd_pasteNoFormatting");
 });
 </script>
 </pre>
 </body>
--- a/dom/events/test/test_bug508479.html
+++ b/dom/events/test/test_bug508479.html
@@ -69,17 +69,17 @@ function runTests()
   is(gGotNotHandlingDrop, false, "Didn't get drop on unaccepting element (1)");
 
   // reset
   gGotHandlingDrop = false;
   gGotNotHandlingDrop = false;
 
   SpecialPowers.addChromeEventListener("drop", chromeListener, true, false);
   var targetNotHandling = document.getElementById("nothandling_target");
-  fireDrop(targetNotHandling, true, true);
+  fireDrop(targetNotHandling, false, true);
   SpecialPowers.removeChromeEventListener("drop", chromeListener, true);
   ok(chromeGotEvent, "Chrome should have got drop event!");
   is(gGotHandlingDrop, false, "Didn't get drop on accepting element (2)");
   is(gGotNotHandlingDrop, false, "Didn't get drop on unaccepting element (2)");
 
   SimpleTest.finish();
 }
 
--- a/dom/tests/mochitest/general/test_clipboard_events.html
+++ b/dom/tests/mochitest/general/test_clipboard_events.html
@@ -654,32 +654,29 @@ function compareSynthetic(event, eventty
 
 function checkCachedDataTransfer(cd, eventtype)
 {
   var testprefix = "cached " + eventtype + " dataTransfer";
 
   setClipboardText("Some Clipboard Text");
 
   var oldtext = cd.getData("text/plain");
-  ok(oldtext != "Some Clipboard Text", "clipboard get using " + testprefix);
+  ok(!oldtext, "clipboard get using " + testprefix);
 
-  var exh = false;
-  try { cd.mozSetDataAt("text/plain", "Test Cache Data", 0); } catch (ex) { exh = true; }
-  ok(eventtype == "paste" ? exh : !exh, "exception occured setting " + testprefix);
-
-  var newtext = (eventtype == "paste") ? cd.getData("text/plain") :
-                                         cd.mozGetDataAt("text/plain", 0);
-  is(newtext, (eventtype == "paste") ? oldtext : "Test Cache Data",
-     " clipboardData not changed using " + testprefix);
+  try {
+    cd.mozSetDataAt("text/plain", "Test Cache Data", 0);
+  } catch (ex) {}
+  ok(!cd.getData("text/plain"), "clipboard set using " + testprefix);
 
   is(getClipboardText(), "Some Clipboard Text", "clipboard not changed using " + testprefix);
 
-  var exh = false;
-  try { cd.mozClearDataAt("text/plain", 0); } catch (ex) { exh = true; }
-  ok(eventtype == "paste" ? exh : !exh, "exception occured clearing " + testprefix);
+  try {
+    cd.mozClearDataAt("text/plain", 0);
+  } catch (ex) {}
+  ok(!cd.getData("text/plain"), "clipboard clear using " + testprefix);
 
   is(getClipboardText(), "Some Clipboard Text", "clipboard not changed using " + testprefix);
 }
 
 function test_input_cut_disallowed_types_dataTransfer() {
   selectContentInput();
   let oncutExecuted = false;
   contentInput.oncut = function(event) {