blob: f96f8cb1a95aee0f05234c61bec66fa51ab7c209 [file] [log] [blame]
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true experimental:AsyncClipboardAPIEnabled=true domPasteAllowed=false ] -->
<html>
<meta charset="utf8">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="../../resources/js-test.js"></script>
<script src="../../resources/ui-helper.js"></script>
<script src="./resources/async-clipboard-helpers.js"></script>
<style>
button, iframe {
width: 100%;
height: 150px;
display: block;
}
</style>
</head>
<script>
jsTestIsAsync = true;
if (window.testRunner)
testRunner.setJavaScriptCanAccessClipboard(false);
async function runTest() {
description("This test verifies that navigator.clipboard.readText rejects if the contents of the platform pasteboard change while reading. This test requires WebKitTestRunner.");
paste = document.getElementById("paste");
paste.addEventListener("click", async () => {
try {
testFailed(`Should not have been able to read ${await navigator.clipboard.readText()}`);
} catch (exception) {
testPassed(`Failed to read with exception: ${exception.name}`);
} finally {
paste.remove();
finishJSTest();
}
});
await UIHelper.copyText("I should not be able to read this text.");
await triggerProgrammaticPaste(paste, ["ChangePasteboardWhenGrantingAccess"]);
}
addEventListener("load", runTest);
</script>
<body>
<button id="paste">Paste</button>
<p id="description"></p>
<p id="console"></p>
</body>
</html>