Skip to content

Commit

Permalink
Bug 1881760 [wpt PR 44744] - UIEvents: Tentative test for textInput w…
Browse files Browse the repository at this point in the history
…ith drag and drop, a=testonly

Automatic update from web-platform-tests
UIEvents: Tentative test for textInput with drag and drop

See w3c/uievents#367
--

wpt-commits: ee2fe53bf4b960b90a072d65a57b56b797a61289
wpt-pr: 44744
  • Loading branch information
zcorpan authored and moz-wptsync-bot committed Apr 10, 2024
1 parent b845676 commit 4e4fbaf
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<meta charset=utf-8>
<title>Selection drag and drop: events for contenteditable</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
[data-placeholder]:empty::before { content: attr(data-placeholder); }
</style>
<body data-expected-events="
b:drop:,
a:beforeinput:deleteByDrag,
a:input:deleteByDrag,
b:beforeinput:insertFromDrop,
b:textInput:,
b:input:insertFromDrop">
<div><input id=a data-select="0,7" value="Drag me"></div>
<div contenteditable=true id=b data-placeholder="...to here"></div>
<script src="/uievents/textInput/support/common.js"></script>
<script src="support/events.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<meta charset=utf-8>
<title>Selection drag and drop: events for contenteditable (same element)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body data-expected-events="
b:drop:,
b:beforeinput:deleteByDrag,
b:input:deleteByDrag,
b:beforeinput:insertFromDrop,
b:textInput:,
b:input:insertFromDrop">
<div contenteditable=true id=b data-select="0,7">Drag me ...to here:</div>
<script src="/uievents/textInput/support/common.js"></script>
<script src="support/events.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<meta charset=utf-8>
<title>Selection drag and drop: events for &lt;input></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body data-expected-events="
b:drop:,
a:beforeinput:deleteByDrag,
a:input:deleteByDrag,
b:beforeinput:insertFromDrop,
b:textInput:,
b:input:insertFromDrop">
<div><input id=a data-select="0,7" value="Drag me"></div>
<div><input id=b placeholder="...to here"></div>
<script src="/uievents/textInput/support/common.js"></script>
<script src="support/events.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<meta charset=utf-8>
<title>Selection drag and drop: events for &lt;input> (same element)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body data-expected-events="
b:drop:,
b:beforeinput:deleteByDrag,
b:input:deleteByDrag,
b:beforeinput:insertFromDrop,
b:textInput:,
b:input:insertFromDrop">
<input id=b data-select="0,7" value="Drag me ...to here:">
<script src="/uievents/textInput/support/common.js"></script>
<script src="support/events.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<meta charset=utf-8>
<title>Selection drag and drop: events for &lt;textarea></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body data-expected-events="
b:drop:,
a:beforeinput:deleteByDrag,
a:input:deleteByDrag,
b:beforeinput:insertFromDrop,
b:textInput:,
b:input:insertFromDrop">
<div><input id=a data-select="0,7" value="Drag me"></div>
<div><textarea id=b placeholder="...to here"></textarea></div>
<script src="/uievents/textInput/support/common.js"></script>
<script src="support/events.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<meta charset=utf-8>
<title>Selection drag and drop: events for &lt;textarea> (same element)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body data-expected-events="
b:drop:,
b:beforeinput:deleteByDrag,
b:input:deleteByDrag,
b:beforeinput:insertFromDrop,
b:textInput:,
b:input:insertFromDrop">
<textarea id=b data-select="0,7">Drag me ...to here:</textarea>
<script src="/uievents/textInput/support/common.js"></script>
<script src="support/events.js"></script>
31 changes: 31 additions & 0 deletions testing/web-platform/tests/html/editing/dnd/drop/support/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
setup({ explicit_timeout: true, single_test: true });
function rAF() {
return new Promise(resolve => {
requestAnimationFrame(resolve);
});
}
const a = document.getElementById('a');
const b = document.getElementById('b');
const actualEvents = [];
const expectedEvents = document.body.dataset.expectedEvents.replace(/\s+/g, '').split(',');
const eventTypes = new Set(expectedEvents.map(s => s.split(':')[1]));
for (const eventType of eventTypes) {
if (a) {
a.addEventListener(eventType, e => {
actualEvents.push(`a:${e.type}:${e.inputType || ''}`);
});
}
b.addEventListener(eventType, async (e) => {
actualEvents.push(`b:${e.type}:${e.inputType || ''}`);
if (e.type === "input") {
await rAF();
await rAF();
assert_array_equals(actualEvents, expectedEvents);
done();
}
});
}
const dragMeElement = document.querySelector('[data-select]');
const [selectionStart, selectionEnd] = dragMeElement.dataset.select.split(',').map(s => parseInt(s, 10));
setSelection(dragMeElement, selectionStart, selectionEnd);
dragMeElement.focus();

0 comments on commit 4e4fbaf

Please sign in to comment.