diff --git a/editor/libeditor/tests/test_dragdrop.html b/editor/libeditor/tests/test_dragdrop.html index 988f691fa91b..8a5b21fa5703 100644 --- a/editor/libeditor/tests/test_dragdrop.html +++ b/editor/libeditor/tests/test_dragdrop.html @@ -66,8 +66,8 @@ function checkInputEvent(aEvent, aExpectedTarget, aInputType, aData, aDataTransf // eslint-disable-next-line complexity async function doTest() { - let container = document.getElementById("container"); - let dropZone = document.getElementById("dropZone"); + const container = document.getElementById("container"); + const dropZone = document.getElementById("dropZone"); let beforeinputEvents = []; let inputEvents = []; @@ -92,7 +92,7 @@ async function doTest() { } } - let selection = window.getSelection(); + const selection = window.getSelection(); const kIsMac = navigator.platform.includes("Mac"); const kIsWin = navigator.platform.includes("Win"); @@ -121,169 +121,526 @@ async function doTest() { } } - // Don't define variables which are used by multiple tests below. Otherwise, - // it's definitely troublesome to comment out unnecessary tests for debug. - // For same reason, don't use multiline comment. - let description, selectionContainers, span, b, lastTextNode, input, otherInput, textarea, otherTextarea, contenteditable, otherContenteditable, onDrop, onDragStart; - // -------- Test dragging regular text - description = "dragging part of non-editable element"; - container.innerHTML = 'Some Text'; - span = document.querySelector("div#container > span"); - selection.setBaseAndExtent(span.firstChild, 4, span.firstChild, 6); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), - span.textContent.substring(4, 6), - `${description}: dataTransfer should have selected text as "text/plain"`); - compareHTML(aEvent.dataTransfer.getData("text/html"), - span.outerHTML.replace(/>.+${span.textContent.substring(4, 6)}<`), - `${description}: dataTransfer should have the parent inline element and only selected text as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: selection, - destElement: dropZone, - } - ) - ) { - is(beforeinputEvents.length, 0, - `${description}: No "beforeinput" event should be fired when dragging non-editable selection to non-editable drop zone`); - is(inputEvents.length, 0, - `${description}: No "input" event should be fired when dragging non-editable selection to non-editable drop zone`); - is(dragEvents.length, 1, - `${description}: only one "drop" event should be fired`); - } - document.removeEventListener("drop", onDrop); + await (async function test_dragging_regular_text() { + const description = "dragging part of non-editable element"; + container.innerHTML = 'Some Text'; + const span = document.querySelector("div#container > span"); + selection.setBaseAndExtent(span.firstChild, 4, span.firstChild, 6); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), + span.textContent.substring(4, 6), + `${description}: dataTransfer should have selected text as "text/plain"`); + compareHTML(aEvent.dataTransfer.getData("text/html"), + span.outerHTML.replace(/>.+${span.textContent.substring(4, 6)}<`), + `${description}: dataTransfer should have the parent inline element and only selected text as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: selection, + destElement: dropZone, + } + ) + ) { + is(beforeinputEvents.length, 0, + `${description}: No "beforeinput" event should be fired when dragging non-editable selection to non-editable drop zone`); + is(inputEvents.length, 0, + `${description}: No "input" event should be fired when dragging non-editable selection to non-editable drop zone`); + is(dragEvents.length, 1, + `${description}: only one "drop" event should be fired`); + } + document.removeEventListener("drop", onDrop); + })(); // -------- Test dragging text from an - description = "dragging part of text in element"; - container.innerHTML = ''; - input = document.querySelector("div#container > input"); - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - input.setSelectionRange(1, 4); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), - input.value.substring(1, 4), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should not have data as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(input).editor.selection, - destElement: dropZone, - } - ) - ) { - is(beforeinputEvents.length, 0, - `${description}: No "beforeinput" event should be fired when dragging value to non-editable drop zone`); - is(inputEvents.length, 0, - `${description}: No "input" event should be fired when dragging value to non-editable drop zone`); - is(dragEvents.length, 1, - `${description}: only one "drop" event should be fired`); - } - document.removeEventListener("drop", onDrop); + await (async function test_dragging_text_from_input_element() { + const description = "dragging part of text in element"; + container.innerHTML = ''; + const input = document.querySelector("div#container > input"); + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + input.setSelectionRange(1, 4); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), + input.value.substring(1, 4), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should not have data as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(input).editor.selection, + destElement: dropZone, + } + ) + ) { + is(beforeinputEvents.length, 0, + `${description}: No "beforeinput" event should be fired when dragging value to non-editable drop zone`); + is(inputEvents.length, 0, + `${description}: No "input" event should be fired when dragging value to non-editable drop zone`); + is(dragEvents.length, 1, + `${description}: only one "drop" event should be fired`); + } + document.removeEventListener("drop", onDrop); + })(); // -------- Test dragging text from an "; - textarea = document.querySelector("div#container > textarea"); - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea.setSelectionRange(1, 7); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), - textarea.value.substring(1, 7), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should not have data as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: dropZone, - } - ) - ) { - is(beforeinputEvents.length, 0, - `${description}: No "beforeinput" event should be fired when dragging "; + const textarea = document.querySelector("div#container > textarea"); + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + textarea.setSelectionRange(1, 7); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), + textarea.value.substring(1, 7), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should not have data as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: dropZone, + } + ) + ) { + is(beforeinputEvents.length, 0, + `${description}: No "beforeinput" event should be fired when dragging "; + const span = document.querySelector("div#container > span"); + const textarea = document.querySelector("div#container > textarea"); selection.setBaseAndExtent(span.firstChild, 2, span.firstChild, 5); beforeinputEvents = []; inputEvents = []; dragEvents = []; - onDrop = aEvent => { + const onDrop = aEvent => { dragEvents.push(aEvent); comparePlainText(aEvent.dataTransfer.getData("text/plain"), - span.textContent.substring(2, 5), - `${description}: dataTransfer should have selected text as "text/plain"`); + span.textContent.substring(2, 5), + `${description}: dataTransfer should have selected text as "text/plain"`); compareHTML(aEvent.dataTransfer.getData("text/html"), span.outerHTML.replace(/>.+${span.textContent.substring(2, 5)}<`), `${description}: dataTransfer should have selected nodes as "text/html"`); @@ -372,114 +766,42 @@ async function doTest() { description, { srcSelection: selection, - destElement: input, + destElement: textarea, } ) ) { - is(input.value, "", - `${description}: .value should not be modified`); - is(beforeinputEvents.length, 0, - `${description}: no "beforeinput" event should be fired on `); - is(inputEvents.length, 0, - `${description}: no "input" event should be fired on `); - is(dragEvents.length, 0, - `${description}: no "drop" event should be fired on `); + is(textarea.value, span.textContent.substring(2, 5), + `${description}: "; + const contenteditable = document.querySelector("div#container > div"); + const textarea = document.querySelector("div#container > textarea"); + const selectionContainers = [contenteditable.firstChild, contenteditable.firstChild.nextSibling.nextSibling]; selection.setBaseAndExtent(selectionContainers[0], 2, selectionContainers[1], 2); beforeinputEvents = []; inputEvents = []; dragEvents = []; - onDrop = aEvent => { + const onDrop = aEvent => { dragEvents.push(aEvent); is(aEvent.dataTransfer.getData("text/plain"), "me bold t", - `${description}: dataTransfer should have selected text as "text/plain"`); + `${description}: dataTransfer should have selected text as "text/plain"`); is(aEvent.dataTransfer.getData("text/html"), "me bold t", - `${description}: dataTransfer should have selected nodes as "text/html"`); + `${description}: dataTransfer should have selected nodes as "text/html"`); }; document.addEventListener("drop", onDrop); if ( @@ -487,46 +809,48 @@ async function doTest() { description, { srcSelection: selection, - destElement: input, + destElement: textarea, } ) ) { is(contenteditable.innerHTML, "Soext", `${description}: Dragged range should be removed from contenteditable`); - is(input.value, "me bold t", - `${description}: .value should be modified`); + is(textarea.value, "me bold t", + `${description}: "; + const contenteditable = document.querySelector("div#container > div"); + const textarea = document.querySelector("div#container > textarea"); + const selectionContainers = [contenteditable.firstChild, contenteditable.firstChild.nextSibling.nextSibling]; selection.setBaseAndExtent(selectionContainers[0], 2, selectionContainers[1], 2); beforeinputEvents = []; inputEvents = []; dragEvents = []; - onDrop = aEvent => { + const onDrop = aEvent => { dragEvents.push(aEvent); is(aEvent.dataTransfer.getData("text/plain"), "me bold t", - `${description}: dataTransfer should have selected text as "text/plain"`); + `${description}: dataTransfer should have selected text as "text/plain"`); is(aEvent.dataTransfer.getData("text/html"), "me bold t", - `${description}: dataTransfer should have selected nodes as "text/html"`); + `${description}: dataTransfer should have selected nodes as "text/html"`); }; document.addEventListener("drop", onDrop); document.addEventListener("beforeinput", preventDefaultDeleteByDrag); @@ -535,46 +859,48 @@ async function doTest() { description, { srcSelection: selection, - destElement: input, + destElement: textarea, } ) ) { is(contenteditable.innerHTML, "Some bold text", `${description}: Dragged range shouldn't be removed from contenteditable`); - is(input.value, "me bold t", - `${description}: .value should be modified`); + is(textarea.value, "me bold t", + `${description}: "; + const contenteditable = document.querySelector("div#container > div"); + const textarea = document.querySelector("div#container > textarea"); + const selectionContainers = [contenteditable.firstChild, contenteditable.firstChild.nextSibling.nextSibling]; selection.setBaseAndExtent(selectionContainers[0], 2, selectionContainers[1], 2); beforeinputEvents = []; inputEvents = []; dragEvents = []; - onDrop = aEvent => { + const onDrop = aEvent => { dragEvents.push(aEvent); is(aEvent.dataTransfer.getData("text/plain"), "me bold t", - `${description}: dataTransfer should have selected text as "text/plain"`); + `${description}: dataTransfer should have selected text as "text/plain"`); is(aEvent.dataTransfer.getData("text/html"), "me bold t", - `${description}: dataTransfer should have selected nodes as "text/html"`); + `${description}: dataTransfer should have selected nodes as "text/html"`); }; document.addEventListener("drop", onDrop); document.addEventListener("beforeinput", preventDefaultInsertFromDrop); @@ -583,53 +909,2017 @@ async function doTest() { description, { srcSelection: selection, - destElement: input, + destElement: textarea, } ) ) { is(contenteditable.innerHTML, "Soext", `${description}: Dragged range should be removed from contenteditable`); - is(input.value, "", - `${description}: .value shouldn't be modified`); + is(textarea.value, "", + `${description}:

'; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const contenteditable = document.querySelector("div#container > div"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: contenteditable, + } + ) + ) { + is(textarea.value, "Linne2", + `${description}: dragged range should be removed from

'; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const contenteditable = document.querySelector("div#container > div"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: contenteditable, + dragEvent: kModifiersToCopy, + } + ) + ) { + is(textarea.value, "Line1\nLine2", + `${description}: dragged range should be removed from '; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const input = document.querySelector("div#container > input"); + const textarea = document.querySelector("div#container > textarea"); + input.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), input.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(input).editor.selection, + destElement: textarea, + } + ) + ) { + is(input.value, "Somt", + `${description}: dragged range should be removed from `); + is(textarea.value, "e Tex", + `${description}: dragged content should be inserted into '; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const input = document.querySelector("div#container > input"); + const textarea = document.querySelector("div#container > textarea"); + input.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), input.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + document.addEventListener("beforeinput", preventDefaultDeleteByDrag); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(input).editor.selection, + destElement: textarea, + } + ) + ) { + is(input.value, "Some Text", + `${description}: dragged range shouldn't be removed from `); + is(textarea.value, "e Tex", + `${description}: dragged content should be inserted into '; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const input = document.querySelector("div#container > input"); + const textarea = document.querySelector("div#container > textarea"); + input.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), input.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + document.addEventListener("beforeinput", preventDefaultInsertFromDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(input).editor.selection, + destElement: textarea, + } + ) + ) { + is(input.value, "Somt", + `${description}: dragged range should be removed from `); + is(textarea.value, "", + `${description}: dragged content shouldn't be inserted into '; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const input = document.querySelector("div#container > input"); + const textarea = document.querySelector("div#container > textarea"); + input.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), input.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(input).editor.selection, + destElement: textarea, + dragEvent: kModifiersToCopy, + } + ) + ) { + is(input.value, "Some Text", + `${description}: dragged range shouldn't be removed from `); + is(textarea.value, "e Tex", + `${description}: dragged content should be inserted into "; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const input = document.querySelector("div#container > input"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: input, + } + ) + ) { + is(textarea.value, "Linne2", + `${description}: dragged range should be removed from "; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const input = document.querySelector("div#container > input"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + document.addEventListener("beforeinput", preventDefaultDeleteByDrag); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: input, + } + ) + ) { + is(textarea.value, "Line1\nLine2", + `${description}: dragged range shouldn't be removed from "; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const input = document.querySelector("div#container > input"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + document.addEventListener("beforeinput", preventDefaultInsertFromDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: input, + } + ) + ) { + is(textarea.value, "Linne2", + `${description}: dragged range should be removed from "; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const input = document.querySelector("div#container > input"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: input, + dragEvent: kModifiersToCopy, + } + ) + ) { + is(textarea.value, "Line1\nLine2", + `${description}: dragged range shouldn't be removed from "; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const otherTextarea = document.querySelector("div#container > textarea + textarea"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: otherTextarea, + } + ) + ) { + is(textarea.value, "Linne2", + `${description}: dragged range should be removed from "; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const otherTextarea = document.querySelector("div#container > textarea + textarea"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + document.addEventListener("beforeinput", preventDefaultDeleteByDrag); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: otherTextarea, + } + ) + ) { + is(textarea.value, "Line1\nLine2", + `${description}: dragged range shouldn't be removed from "; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const otherTextarea = document.querySelector("div#container > textarea + textarea"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + document.addEventListener("beforeinput", preventDefaultInsertFromDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: otherTextarea, + } + ) + ) { + is(textarea.value, "Linne2", + `${description}: dragged range should be removed from "; + document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. + const textarea = document.querySelector("div#container > textarea"); + const otherTextarea = document.querySelector("div#container > textarea + textarea"); + textarea.setSelectionRange(3, 8); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "", + `${description}: dataTransfer should have not have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: SpecialPowers.wrap(textarea).editor.selection, + destElement: otherTextarea, + dragEvent: kModifiersToCopy, + } + ) + ) { + is(textarea.value, "Line1\nLine2", + `${description}: dragged range shouldn't be removed from "; - span = document.querySelector("div#container > span"); - textarea = document.querySelector("div#container > textarea"); - selection.setBaseAndExtent(span.firstChild, 2, span.firstChild, 5); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), - span.textContent.substring(2, 5), - `${description}: dataTransfer should have selected text as "text/plain"`); - compareHTML(aEvent.dataTransfer.getData("text/html"), - span.outerHTML.replace(/>.+${span.textContent.substring(2, 5)}<`), - `${description}: dataTransfer should have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: selection, - destElement: textarea, - } - ) - ) { - is(textarea.value, span.textContent.substring(2, 5), - `${description}: "; - contenteditable = document.querySelector("div#container > div"); - textarea = document.querySelector("div#container > textarea"); - selectionContainers = [contenteditable.firstChild, contenteditable.firstChild.nextSibling.nextSibling]; - selection.setBaseAndExtent(selectionContainers[0], 2, selectionContainers[1], 2); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - is(aEvent.dataTransfer.getData("text/plain"), "me bold t", - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "me bold t", - `${description}: dataTransfer should have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: selection, - destElement: textarea, - } - ) - ) { - is(contenteditable.innerHTML, "Soext", - `${description}: Dragged range should be removed from contenteditable`); - is(textarea.value, "me bold t", - `${description}: "; - contenteditable = document.querySelector("div#container > div"); - textarea = document.querySelector("div#container > textarea"); - selectionContainers = [contenteditable.firstChild, contenteditable.firstChild.nextSibling.nextSibling]; - selection.setBaseAndExtent(selectionContainers[0], 2, selectionContainers[1], 2); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - is(aEvent.dataTransfer.getData("text/plain"), "me bold t", - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "me bold t", - `${description}: dataTransfer should have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - document.addEventListener("beforeinput", preventDefaultDeleteByDrag); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: selection, - destElement: textarea, - } - ) - ) { - is(contenteditable.innerHTML, "Some bold text", - `${description}: Dragged range shouldn't be removed from contenteditable`); - is(textarea.value, "me bold t", - `${description}: "; - contenteditable = document.querySelector("div#container > div"); - textarea = document.querySelector("div#container > textarea"); - selectionContainers = [contenteditable.firstChild, contenteditable.firstChild.nextSibling.nextSibling]; - selection.setBaseAndExtent(selectionContainers[0], 2, selectionContainers[1], 2); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - is(aEvent.dataTransfer.getData("text/plain"), "me bold t", - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "me bold t", - `${description}: dataTransfer should have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - document.addEventListener("beforeinput", preventDefaultInsertFromDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: selection, - destElement: textarea, - } - ) - ) { - is(contenteditable.innerHTML, "Soext", - `${description}: Dragged range should be removed from contenteditable`); - is(textarea.value, "", - `${description}:

'; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - contenteditable = document.querySelector("div#container > div"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: contenteditable, - } - ) - ) { - is(textarea.value, "Linne2", - `${description}: dragged range should be removed from

'; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - contenteditable = document.querySelector("div#container > div"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: contenteditable, - dragEvent: kModifiersToCopy, - } - ) - ) { - is(textarea.value, "Line1\nLine2", - `${description}: dragged range should be removed from '; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - input = document.querySelector("div#container > input"); - textarea = document.querySelector("div#container > textarea"); - input.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), input.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(input).editor.selection, - destElement: textarea, - } - ) - ) { - is(input.value, "Somt", - `${description}: dragged range should be removed from `); - is(textarea.value, "e Tex", - `${description}: dragged content should be inserted into '; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - input = document.querySelector("div#container > input"); - textarea = document.querySelector("div#container > textarea"); - input.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), input.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - document.addEventListener("beforeinput", preventDefaultDeleteByDrag); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(input).editor.selection, - destElement: textarea, - } - ) - ) { - is(input.value, "Some Text", - `${description}: dragged range shouldn't be removed from `); - is(textarea.value, "e Tex", - `${description}: dragged content should be inserted into '; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - input = document.querySelector("div#container > input"); - textarea = document.querySelector("div#container > textarea"); - input.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), input.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - document.addEventListener("beforeinput", preventDefaultInsertFromDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(input).editor.selection, - destElement: textarea, - } - ) - ) { - is(input.value, "Somt", - `${description}: dragged range should be removed from `); - is(textarea.value, "", - `${description}: dragged content shouldn't be inserted into '; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - input = document.querySelector("div#container > input"); - textarea = document.querySelector("div#container > textarea"); - input.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), input.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(input).editor.selection, - destElement: textarea, - dragEvent: kModifiersToCopy, - } - ) - ) { - is(input.value, "Some Text", - `${description}: dragged range shouldn't be removed from `); - is(textarea.value, "e Tex", - `${description}: dragged content should be inserted into "; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - input = document.querySelector("div#container > input"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: input, - } - ) - ) { - is(textarea.value, "Linne2", - `${description}: dragged range should be removed from "; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - input = document.querySelector("div#container > input"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - document.addEventListener("beforeinput", preventDefaultDeleteByDrag); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: input, - } - ) - ) { - is(textarea.value, "Line1\nLine2", - `${description}: dragged range shouldn't be removed from "; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - input = document.querySelector("div#container > input"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - document.addEventListener("beforeinput", preventDefaultInsertFromDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: input, - } - ) - ) { - is(textarea.value, "Linne2", - `${description}: dragged range should be removed from "; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - input = document.querySelector("div#container > input"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: input, - dragEvent: kModifiersToCopy, - } - ) - ) { - is(textarea.value, "Line1\nLine2", - `${description}: dragged range shouldn't be removed from "; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - otherTextarea = document.querySelector("div#container > textarea + textarea"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: otherTextarea, - } - ) - ) { - is(textarea.value, "Linne2", - `${description}: dragged range should be removed from "; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - otherTextarea = document.querySelector("div#container > textarea + textarea"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - document.addEventListener("beforeinput", preventDefaultDeleteByDrag); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: otherTextarea, - } - ) - ) { - is(textarea.value, "Line1\nLine2", - `${description}: dragged range shouldn't be removed from "; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - otherTextarea = document.querySelector("div#container > textarea + textarea"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - document.addEventListener("beforeinput", preventDefaultInsertFromDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: otherTextarea, - } - ) - ) { - is(textarea.value, "Linne2", - `${description}: dragged range should be removed from "; - document.documentElement.scrollTop; // Need reflow to create TextControlState and its colleagues. - textarea = document.querySelector("div#container > textarea"); - otherTextarea = document.querySelector("div#container > textarea + textarea"); - textarea.setSelectionRange(3, 8); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), textarea.value.substring(3, 8), - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "", - `${description}: dataTransfer should have not have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: SpecialPowers.wrap(textarea).editor.selection, - destElement: otherTextarea, - dragEvent: kModifiersToCopy, - } - ) - ) { - is(textarea.value, "Line1\nLine2", - `${description}: dragged range shouldn't be removed from '; - contenteditable = document.querySelector("div#container > div"); - textarea = document.querySelector("div#container > textarea"); - selectionContainers = [contenteditable.firstChild.firstChild, contenteditable.firstChild.nextSibling.firstChild]; - selection.setBaseAndExtent(selectionContainers[0], 3, selectionContainers[1], 2); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), `e1\nLi`, - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "
e1
Li
", - `${description}: dataTransfer should have have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: selection, - destElement: textarea, - } - ) - ) { - is(contenteditable.innerHTML, "
Linne2
", - `${description}: dragged content should be removed from contenteditable`); - is(textarea.value, "e1\nLi", - `${description}: dragged range should be inserted into '; + const contenteditable = document.querySelector("div#container > div"); + const textarea = document.querySelector("div#container > textarea"); + const selectionContainers = [contenteditable.firstChild.firstChild, contenteditable.firstChild.nextSibling.firstChild]; + selection.setBaseAndExtent(selectionContainers[0], 3, selectionContainers[1], 2); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), `e1\nLi`, + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "
e1
Li
", + `${description}: dataTransfer should have have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: selection, + destElement: textarea, + } + ) + ) { + is(contenteditable.innerHTML, "
Linne2
", + `${description}: dragged content should be removed from contenteditable`); + is(textarea.value, "e1\nLi", + `${description}: dragged range should be inserted into '; - contenteditable = document.querySelector("div#container > div"); - textarea = document.querySelector("div#container > textarea"); - selection.setBaseAndExtent(contenteditable.firstChild.firstChild, 3, - contenteditable.firstChild.nextSibling.firstChild, 2); - beforeinputEvents = []; - inputEvents = []; - dragEvents = []; - onDrop = aEvent => { - dragEvents.push(aEvent); - comparePlainText(aEvent.dataTransfer.getData("text/plain"), `e1\nLi`, - `${description}: dataTransfer should have selected text as "text/plain"`); - is(aEvent.dataTransfer.getData("text/html"), "
e1
Li
", - `${description}: dataTransfer should have have selected nodes as "text/html"`); - }; - document.addEventListener("drop", onDrop); - if ( - await trySynthesizePlainDragAndDrop( - description, - { - srcSelection: selection, - destElement: textarea, - dragEvent: kModifiersToCopy, - } - ) - ) { - is(contenteditable.innerHTML, "
Line1
Line2
", - `${description}: dragged content should be removed from contenteditable`); - is(textarea.value, "e1\nLi", - `${description}: dragged range should be inserted into '; + const contenteditable = document.querySelector("div#container > div"); + const textarea = document.querySelector("div#container > textarea"); + selection.setBaseAndExtent(contenteditable.firstChild.firstChild, 3, + contenteditable.firstChild.nextSibling.firstChild, 2); + beforeinputEvents = []; + inputEvents = []; + dragEvents = []; + const onDrop = aEvent => { + dragEvents.push(aEvent); + comparePlainText(aEvent.dataTransfer.getData("text/plain"), `e1\nLi`, + `${description}: dataTransfer should have selected text as "text/plain"`); + is(aEvent.dataTransfer.getData("text/html"), "
e1
Li
", + `${description}: dataTransfer should have have selected nodes as "text/html"`); + }; + document.addEventListener("drop", onDrop); + if ( + await trySynthesizePlainDragAndDrop( + description, + { + srcSelection: selection, + destElement: textarea, + dragEvent: kModifiersToCopy, + } + ) + ) { + is(contenteditable.innerHTML, "
Line1
Line2
", + `${description}: dragged content should be removed from contenteditable`); + is(textarea.value, "e1\nLi", + `${description}: dragged range should be inserted into