blob: bf2ff2bea7b5c6798346022cbafd3acfbb553419 [file] [log] [blame]
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true AsyncClipboardAPIEnabled=true JavaScriptCanAccessClipboard=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>
</head>
<script>
jsTestIsAsync = true;
async function runTest() {
description("This test verifies that navigator.clipboard.writeText requires a user gesture.");
try {
await navigator.clipboard.writeText("This should not be written.");
testFailed("Wrote to the clipboard without user gesture.");
} catch (clipboardException) {
window.clipboardException = clipboardException;
testPassed("Did not write to the clipboard.");
shouldBeEqualToString("clipboardException.name", "NotAllowedError");
}
finishJSTest();
}
addEventListener("load", runTest);
</script>
<body></body>
</html>