Convert drag-drop-url-with-style.html to utilize w3c test harness

This patch converts "drag-drop-url-with-style.html" in
"LayoutTests/editing/pasteboard" to utilize |assert_selection()| with w3c test
harness to simplify test case and more readable for improving code helath.

BUG=679977
TEST=n/a; no behavior changes

Review-Url: https://codereview.chromium.org/2696083003
Cr-Commit-Position: refs/heads/master@{#450675}
diff --git a/third_party/WebKit/LayoutTests/editing/pasteboard/drag-drop-url-with-style-expected.txt b/third_party/WebKit/LayoutTests/editing/pasteboard/drag-drop-url-with-style-expected.txt
deleted file mode 100644
index 8de3641a..0000000
--- a/third_party/WebKit/LayoutTests/editing/pasteboard/drag-drop-url-with-style-expected.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-This tests dragging and dropping a URL. The content before and after the drag and drop should match.
-
-before:
-| <a>
-|   href="http://webkit.org/"
-|   style="color:orange"
-|   target="_blank"
-|   title="some title"
-|   "<#selection-anchor>drag me<#selection-focus>"
-
-after:
-| <a>
-|   href="http://webkit.org/"
-|   style="color: orange;"
-|   target="_blank"
-|   title="some title"
-|   "<#selection-anchor>drag me<#selection-focus>"
-| <br>
diff --git a/third_party/WebKit/LayoutTests/editing/pasteboard/drag-drop-url-with-style.html b/third_party/WebKit/LayoutTests/editing/pasteboard/drag-drop-url-with-style.html
index 9bdcca8..91e5f11d 100644
--- a/third_party/WebKit/LayoutTests/editing/pasteboard/drag-drop-url-with-style.html
+++ b/third_party/WebKit/LayoutTests/editing/pasteboard/drag-drop-url-with-style.html
@@ -1,40 +1,50 @@
-<!DOCTYPE html>
-<html>
-<body>
-<p id="description">This tests dragging and dropping a URL. The content before and after the drag and drop should match.</p>
-<div contenteditable><a href="http://webkit.org/" title="some title" target="_blank" style="color:orange">drag me</a></div>
-<p>to the box blow:</p>
-<div id="destination" contenteditable ondrop="setTimeout(dump, 0);" style="border: solid 2px blue; padding: 5px;"><br></div>
-<script src="../../resources/dump-as-markup.js"></script>
+<!doctype html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../assert_selection.js"></script>
 <script>
-
-Markup.waitUntilDone();
-
-Markup.description(document.getElementById('description').textContent);
-
-var target = document.getElementsByTagName("a")[0];
-getSelection().selectAllChildren(target);
-Markup.dump(target.parentNode, 'before');
-
-function dump() {
-    Markup.dump('destination', 'after');
-    Markup.notifyDone();
+function computePoint(selection, target) {
+  const x = selection.document.offsetLeft + target.offsetLeft +
+      target.offsetWidth / 2;
+  const y = selection.document.offsetTop + target.offsetTop +
+      target.offsetHeight / 2;
+  return {x, y};
 }
 
-if (window.eventSender) {
-    var x = target.offsetLeft + target.offsetWidth / 2;
-    var y = target.offsetTop + target.offsetHeight / 2;
-    eventSender.mouseMoveTo(x, y);
-    eventSender.mouseDown();
+test(() => {
+  if (!window.eventSender) {
+    assert_unreached('This test requires eventSender.');
+    return;
+  }
 
-    var destination = document.getElementById("destination");
-    eventSender.leapForward(300);
-    eventSender.mouseMoveTo(destination.offsetLeft + 10, destination.offsetTop + destination.offsetHeight / 2);
-    eventSender.mouseUp();
+  assert_selection(
+    [
+      '<div contenteditable>',
+        '<a href="http://dev.chromium.org/"',
+          ' title="some title" style="color:orange">^drag me|</a>',
+      '</div>',
+      '<p>to the box blow:</p>',
+      '<div contenteditable id="drop"><br></div>',
+    ].join(''),
+    selection => {
+      const source = selection.document.querySelector('a');
+      const sourcePoint = computePoint(selection, source);
+      eventSender.mouseMoveTo(sourcePoint.x, sourcePoint.y);
+      eventSender.mouseDown();
 
-    setTimeout(function () { destination.innerHTML = 'FAIL'; dump(); }, 100);
-}
-
+      const drop = selection.document.getElementById('drop');
+      const dropPoint = computePoint(selection, drop);
+      eventSender.leapForward(300);
+      eventSender.mouseMoveTo(dropPoint.x, dropPoint.y);
+      eventSender.mouseUp();
+    },
+    [
+      '<div contenteditable></div>',
+      '<p>to the box blow:</p>',
+      '<div contenteditable id="drop">',
+        '<a href="http://dev.chromium.org/"',
+          ' style="color: orange;" title="some title">^drag me|</a>',
+      '</div>',
+    ].join(''));
+}, 'Drag-and-Drop should keep attributes of A');
 </script>
-</body>
-</html>