Skip to content

Commit

Permalink
Convert Image Tests 1-5 to use Actions API.
Browse files Browse the repository at this point in the history
Bug: 1302171
Change-Id: I8f244da023d23c5f77957e63bd322f1fd8a3aa69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3858858
Commit-Queue: Suyash Nayan <[email protected]>
Reviewed-by: Andrew Williams <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1045281}
  • Loading branch information
7suyash7 authored and chromium-wpt-export-bot committed Sep 9, 2022
1 parent 65d9403 commit d2a2a57
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 4 deletions.
22 changes: 21 additions & 1 deletion html/editing/dnd/images/001.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../resources/test-helper.js"></script>
<head>
<title>Image drag and drop</title>
<style type="text/css">
Expand All @@ -25,7 +31,21 @@
<div
ondragenter="event.preventDefault()"
ondragover="return false"
ondrop="addImage(event)"
/>
<script>
async function test() {
await new Promise(loaded => window.addEventListener("load", loaded));
const img = document.querySelector('img');
const div = document.querySelector('div');
function onDropCallBack(event) {
addImage(event);
assert_equals(img.src, event.dataTransfer.getData('text/uri-list').replace(/\r\n$/,''));
return true;
}

dragDropTest(img, div, onDropCallBack, 'Dragging the image to the bottom div should copy the image there"');
}
test();
</script>
</body>
</html>
22 changes: 21 additions & 1 deletion html/editing/dnd/images/002.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../resources/test-helper.js"></script>
<head>
<title>dataURL image drag and drop</title>
<style type="text/css">
Expand All @@ -25,7 +31,21 @@
<div
ondragenter="event.preventDefault()"
ondragover="return false"
ondrop="addImage(event)"
/>
<script>
async function test(){
await new Promise(loaded => window.addEventListener("load", loaded));
const img = document.querySelector('img');
const div = document.querySelector('div');
function onDropCallBack(event) {
addImage(event);
assert_equals(img.src, event.dataTransfer.getData('text/uri-list').replace(/\r\n$/,''));
return true;
}

dragDropTest(img, div, onDropCallBack, 'Dragging the dataURL PNG image to the bottom div should copy the image there');
}
test();
</script>
</body>
</html>
21 changes: 20 additions & 1 deletion html/editing/dnd/images/004.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../resources/test-helper.js"></script>
<head>
<title>Object with image drag and drop</title>
<style type="text/css">
Expand Down Expand Up @@ -28,7 +34,20 @@
<div
ondragenter="event.preventDefault()"
ondragover="return false"
ondrop="addImage(event)"
/>
</body>
<script>
async function test() {
const object = document.querySelector('object');
const div = document.querySelector('div');
function onDropCallBack(event) {
addImage(event);
assert_equals(object.getAttribute('data'), event.dataTransfer.getData('text/uri-list').replace(/\r\n$/,''));
return true;
}

dragDropTest(object, div, onDropCallBack, 'Dragging the object to the bottom div should copy the image there');
}
test();
</script>
</html>
21 changes: 20 additions & 1 deletion html/editing/dnd/images/005.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../resources/test-helper.js"></script>
<head>
<title>JPG image drag and drop</title>
<style type="text/css">
Expand All @@ -25,7 +31,20 @@
<div
ondragenter="event.preventDefault()"
ondragover="return false"
ondrop="addImage(event)"
/>
</body>
<script>
async function test() {
const img = document.querySelector('img');
const div = document.querySelector('div');
function onDropCallBack(event) {
addImage(event);
assert_equals(img.src, event.dataTransfer.getData('text/uri-list').replace(/\r\n$/,''));
return true;
}

dragDropTest(img, div, onDropCallBack, 'Dragging the dataURL JPG image to the bottom div should copy the image there');
}
test();
</script>
</html>

0 comments on commit d2a2a57

Please sign in to comment.