blob: 472f94d1b8042af7ebac411d51132b5dd81e99aa [file] [log] [blame]
<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] -->
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<script src="./resources/dom-paste-helper.js"></script>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/ui-helper.js"></script>
<style>
body {
margin: 0;
}
#copy {
width: 100%;
height: 50px;
border: 1px dashed black;
}
#editor {
width: 100%;
height: 100px;
border: 1px dashed silver;
text-align: center;
}
</style>
</head>
<body>
<div id="editor" contenteditable></div>
<iframe id="copy" src="data:text/html,<div id='copy' style='font-size: 40px; text-align: center;'>Click here to copy</div>
<script>
copy.addEventListener('click', () => {
getSelection().selectAllChildren(copy);
document.execCommand('Copy');
getSelection().removeAllRanges();
});
</script>"></iframe>
<div id="description"></div>
<div id="console"></div>
<script>
jsTestIsAsync = true;
const editor = document.getElementById("editor");
description("Verifies that a callout is shown when the page programmatically triggers paste, and that tapping the callout allows the paste to happen. To manually test, tap the text on the bottom, tap the editable area above, and then select 'Paste' in the resulting callout menu. The text 'Click here to copy' should be pasted <strong><em>twice</em></strong> in the editable area.");
editor.addEventListener("paste", event => shouldBeEqualToString("event.clipboardData.getData('text/plain')", "Click here to copy"));
editor.addEventListener("click", event => {
getSelection().setPosition(editor);
shouldBe("document.queryCommandSupported('Paste')", "true");
shouldBe("document.queryCommandEnabled('Paste')", "true");
shouldBe("document.execCommand('Paste')", "true");
document.execCommand('InsertParagraph');
shouldBe("document.execCommand('Paste')", "true");
shouldBeEqualToString("editor.textContent", "Click here to copyClick here to copy");
event.preventDefault();
editor.blur();
});
addEventListener("load", async () => {
if (!window.testRunner)
return;
await UIHelper.activateAt(160, 125);
await triggerPasteMenuAfterTapAt(160, 50);
finishJSTest();
});
</script>
</body>
</html>