Bug 1199729 - Part 7: Add manual web-platform-tests for Drag Data Store status, r=baku
authorMichael Layzell <michael@thelayzells.com>
Wed, 06 Sep 2017 12:47:22 -0400
changeset 429273 5a69e957b1986e6c2e8ae073dce7c8db5c2f5d9d
parent 429272 0ee09b4795cbfc759db5ea7bd0deb2e9674f8c13
child 429274 cb242f1774a5845a104b6d3482232bc6d1bdf21f
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 7: Add manual web-platform-tests for Drag Data Store status, r=baku
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/editing/dnd/the-datatransfer-interface/protectedDragDataTransfer-manual.html
testing/web-platform/tests/html/editing/dnd/the-datatransfer-interface/protectedPasteDataTransfer-manual.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -11480,16 +11480,28 @@
     ]
    ],
    "html/editing/dnd/the-datatransfer-interface/dndTransferCases-manual.html": [
     [
      "/html/editing/dnd/the-datatransfer-interface/dndTransferCases-manual.html",
      {}
     ]
    ],
+   "html/editing/dnd/the-datatransfer-interface/protectedDragDataTransfer-manual.html": [
+    [
+     "/html/editing/dnd/the-datatransfer-interface/protectedDragDataTransfer-manual.html",
+     {}
+    ]
+   ],
+   "html/editing/dnd/the-datatransfer-interface/protectedPasteDataTransfer-manual.html": [
+    [
+     "/html/editing/dnd/the-datatransfer-interface/protectedPasteDataTransfer-manual.html",
+     {}
+    ]
+   ],
    "html/editing/dnd/the-dragevent-interface/dragevent-manual.html": [
     [
      "/html/editing/dnd/the-dragevent-interface/dragevent-manual.html",
      {}
     ]
    ],
    "html/editing/dnd/the-dropzone-attribute/dropzone_attribute_data_item_file_type-manual.html": [
     [
@@ -590392,16 +590404,24 @@
   "html/editing/dnd/target-origin/HELPER-showorigin.html": [
    "3d88c7724fdca8e5432181c066b3f228a8fb823b",
    "support"
   ],
   "html/editing/dnd/the-datatransfer-interface/dndTransferCases-manual.html": [
    "78d645a13235dbed9cdca67814221dac80fd7788",
    "manual"
   ],
+  "html/editing/dnd/the-datatransfer-interface/protectedDragDataTransfer-manual.html": [
+   "1a057539ebd15f5d89fc44ee82641df16d9e111d",
+   "manual"
+  ],
+  "html/editing/dnd/the-datatransfer-interface/protectedPasteDataTransfer-manual.html": [
+   "f8ff466d4f98f34e12e037045034fc7d908abf94",
+   "manual"
+  ],
   "html/editing/dnd/the-dragevent-interface/dragevent-manual.html": [
    "d68dd91a57379388797a557e64d6ed553cd02a6e",
    "manual"
   ],
   "html/editing/dnd/the-draggable-attribute/draggable_attribute.html": [
    "d5ef1e42f71f1e5f4713b9feabf63234f6016000",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/editing/dnd/the-datatransfer-interface/protectedDragDataTransfer-manual.html
@@ -0,0 +1,142 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset='utf-8'>
+    <title>HTML Test: drag DataTransfer protected status</title>
+    <link rel='author' title='Michael Layzell' href='mailto:michael@thelayzells.com'>
+    <link rel='help' href='https://html.spec.whatwg.org/multipage/#the-datatransfer-interface'>
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+    <style>
+      #drag {
+        width: 100px;
+        height: 100px;
+        display: inline-block;
+        color: #fff;
+        background-color: #f00;
+      }
+      #drop {
+        width: 100px;
+        height: 100px;
+        display: inline-block;
+        color: #fff;
+        background-color: #00f;
+      }
+    </style>
+  </head>
+
+  <body>
+    <h3>Instructions</h3>
+    <p>
+      Drag the box labeled "drag" to the box labeled "drop" and release.
+    </p>
+
+    <div id="drag" draggable="true">drag</div>
+    <div id="drop">drop</div>
+
+    <div id="log"> </div>
+
+    <script>
+      var MIME = "text/plain";
+
+      var drop;
+      setup(function() {
+        drop = document.querySelector("#drop");
+      }, {explicit_done: true, explicit_timeout: true});
+
+      var STATUS_PROTECTED = "protected";
+      var STATUS_READONLY = "readonly";
+      var STATUS_READWRITE = "readwrite";
+      var STATUS_DISCONNECTED = "disconnected";
+      function status(dt) {
+        // Check if we can write to it.
+        try {
+          dt.setData("text/html", "_test");
+
+          if (dt.getData("text/html") == "_test") {
+            dt.clearData("text/html");
+            assert_true(!dt.getData("text/html"), "ClearData should work...");
+            return STATUS_READWRITE;
+          }
+        } catch(e) {}
+
+        // If we can read the data then we're readonly
+        if (dt.getData(MIME)) {
+          return STATUS_READONLY;
+        }
+
+        // If we can see that items exist (and read types) then we're protected
+        if (dt.items.length > 0) {
+          return STATUS_PROTECTED;
+        }
+
+        // Otherwise we've been disconnected.
+        return STATUS_DISCONNECTED;
+      };
+
+      var drag_dt = null;
+      var over_dt = null;
+      var drop_dt = null;
+      on_event(document.body, "dragstart", function(e) {
+        drag_dt = e.dataTransfer;
+        over_dt = null;
+        drop_dt = null;
+        drag_dt.setData(MIME, "b");
+        test(function() {
+          assert_equals(status(drag_dt), STATUS_READWRITE,
+                        "drag_dt must be readwrite during dragstart");
+        }, "dragstart event status");
+      });
+      on_event(drop, "dragover", function(e) {
+        if (!over_dt) {
+          over_dt = e.dataTransfer;
+          test(function() {
+            assert_equals(status(drag_dt), STATUS_DISCONNECTED,
+                          "drag_dt mustbe disconnected during dragover");
+            assert_equals(status(over_dt), STATUS_PROTECTED,
+                          "over_dt mustbe protected during dragover");
+          }, "dragover event status");
+          test(function() {
+            assert_true(drag_dt != over_dt,
+                        "drag_dt must be a different DataTransfer object than over_dt");
+          }, "dragover event identity");
+        }
+        e.preventDefault();
+      });
+      on_event(drop, "drop", function(e) {
+        drop_dt = e.dataTransfer;
+        test(function() {
+          assert_equals(status(drag_dt), STATUS_DISCONNECTED,
+                        "drag_dt mustbe disconnected during drop");
+          assert_equals(status(over_dt), STATUS_DISCONNECTED,
+                        "over_dt mustbe disconnected during drop");
+          assert_equals(status(drop_dt), STATUS_READONLY,
+                        "drop_dt mustbe readonly during drop");
+        }, "drop event status");
+        test(function() {
+          assert_not_equals(drop_dt, over_dt,
+                            "drop_dt must be a different DataTransfer object than over_dt");
+          assert_not_equals(drop_dt, drag_dt,
+                            "drop_dt must be a different DataTransfer object than drag_dt");
+        }, "drop event identity");
+        test(function() {
+          assert_equals(drop_dt.getData(MIME), "b",
+                        "the data should have been persisted");
+        }, "drop event data");
+        e.preventDefault();
+
+        setTimeout(function() {
+          test(function() {
+            assert_equals(status(drag_dt), STATUS_DISCONNECTED,
+                          "drag_dt mustbe disconnected after drop");
+            assert_equals(status(over_dt), STATUS_DISCONNECTED,
+                          "over_dt mustbe disconnected after drop");
+            assert_equals(status(drop_dt), STATUS_DISCONNECTED,
+                          "drop_dt mustbe disconnected after drop");
+          }, "after drop event status");
+          done();
+        }, 0);
+      });
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/editing/dnd/the-datatransfer-interface/protectedPasteDataTransfer-manual.html
@@ -0,0 +1,106 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset='utf-8'>
+    <title>HTML Test: paste DataTransfer protected status</title>
+    <link rel='author' title='Michael Layzell' href='mailto:michael@thelayzells.com'>
+    <link rel='help' href='https://html.spec.whatwg.org/multipage/#the-datatransfer-interface'>
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+  </head>
+
+  <body>
+    <h3>Instructions</h3>
+    <p>
+      Select the text in the text box and press Ctrl-C followed by Ctrl-V.
+    </p>
+
+    <input type="text" id="input" value="text">
+
+    <div id="log"> </div>
+
+    <script>
+      var MIME = "text/plain";
+
+      var input;
+      setup(function() {
+        input = document.querySelector("#input");
+      }, {explicit_done: true, explicit_timeout: true});
+
+      var STATUS_PROTECTED = "protected";
+      var STATUS_READONLY = "readonly";
+      var STATUS_READWRITE = "readwrite";
+      var STATUS_DISCONNECTED = "disconnected";
+      function status(dt) {
+        // Check if we can write to it.
+        try {
+          dt.setData("text/html", "_test");
+
+          if (dt.getData("text/html") == "_test") {
+            dt.clearData("text/html");
+            assert_true(!dt.getData("text/html"), "ClearData should work...");
+            return STATUS_READWRITE;
+          }
+        } catch(e) {}
+
+        // If we can read the data then we're readonly
+        if (dt.getData(MIME)) {
+          return STATUS_READONLY;
+        }
+
+        // If we can see that items exist (and read types) then we're protected
+        if (dt.items.length > 0) {
+          return STATUS_PROTECTED;
+        }
+
+        // Otherwise we've been disconnected.
+        return STATUS_DISCONNECTED;
+      };
+
+      let copy_dt = null;
+      let paste_dt = null;
+      on_event(input, "copy", function(e) {
+        copy_dt = e.clipboardData;
+        paste_dt = null;
+        copy_dt.setData(MIME, "b");
+
+        test(function() {
+          assert_equals(status(copy_dt), STATUS_READWRITE,
+                        "copy_dt must be readwrite during copy");
+        }, "copy event status");
+
+        e.preventDefault();
+      });
+      on_event(input, "paste", function(e) {
+        paste_dt = e.clipboardData;
+
+        test(function() {
+          assert_equals(status(copy_dt), STATUS_DISCONNECTED,
+                        "copy_dt mustbe disconnected during paste");
+          assert_equals(status(paste_dt), STATUS_READONLY,
+                        "paste_dt mustbe readonly during paste");
+        }, "paste event status");
+        test(function() {
+          assert_not_equals(copy_dt != paste_dt,
+                            "copy_dt must be a different DataTransfer object than paste_dt");
+        }, "paste event identity");
+        test(function() {
+          assert_equals(paste_dt.getData(MIME), "b",
+                        "the data should have been persisted");
+        }, "paste event data");
+
+        e.preventDefault();
+
+        setTimeout(function() {
+          test(function() {
+            assert_equals(status(copy_dt), STATUS_DISCONNECTED,
+                          "copy_dt mustbe disconnected after paste");
+            assert_equals(status(paste_dt), STATUS_DISCONNECTED,
+                          "paste_dt mustbe disconnected after paste");
+          }, "after paste event status");
+          done();
+        }, 0);
+      });
+    </script>
+  </body>
+</html>