blob: 6c266dea338cf0a36d54b8aa84d6b94ad436b9ea [file] [log] [blame]
<!DOCTYPE html><!-- webkit-test-runner [ enableEditableImages=true enableAttachmentElement=true ] -->
<head>
<script src="../../resources/ui-helper.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
addEventListener("load", async () => {
const div = document.getElementById("test");
const selection = window.getSelection();
selection.setPosition(div, 0);
testRunner.execCommand("InsertEditableImage");
await UIHelper.drawSquareInEditableImage();
const numberOfStrokesInEditableImageAfterDrawing = (await UIHelper.numberOfStrokesInEditableImage());
const firstImage = document.querySelector("img");
const initialAttachmentID = HTMLAttachmentElement.getAttachmentIdentifier(firstImage);
// We need to make sure that the canvas gets a non-zero size before trying to serialize it.
await UIHelper.ensurePresentationUpdate();
selection.setBaseAndExtent(div.firstChild, 0, div.firstChild, 1);
testRunner.execCommand("Copy");
selection.collapseToEnd();
testRunner.execCommand("Paste");
firstImage.parentElement.removeChild(firstImage);
const numberOfStrokesInEditableImageAfterPasting = (await UIHelper.numberOfStrokesInEditableImage());
await UIHelper.drawSquareInEditableImage();
const numberOfStrokesInEditableImageAfterSecondDrawing = (await UIHelper.numberOfStrokesInEditableImage());
const pastedAttachmentID = HTMLAttachmentElement.getAttachmentIdentifier(document.querySelector("img"));
const attachmentIDsAreDifferent = (initialAttachmentID != pastedAttachmentID) ? "yes" : "no";
document.getElementById("log").innerHTML = `Had ${numberOfStrokesInEditableImageAfterDrawing} stroke in editable image after drawing.<br/>Had ${numberOfStrokesInEditableImageAfterPasting} stroke in editable image after copying and pasting.<br/>Had ${numberOfStrokesInEditableImageAfterSecondDrawing} strokes in editable image after drawing on pasted image.<br/>Pasted image got a new attachment ID: ${attachmentIDsAreDifferent}.`;
testRunner.notifyDone();
});
</script>
</head>
<body contenteditable><div id="log"><br/></div><div id="test"><br/></div></body>