blob: ff8f5ae4c1d8cdf52f002176200710253a1aec4b [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<div id="container">
<button onclick="runTest()">1. Copy</button>
<div id="source" oncopy="copy(event)" contenteditable>some text</div>
<div id="destination" onpaste="paste(event)" contenteditable>2. Paste here</div>
</div>
<script>
description('This tests calling getData returns the same malformed URL string set by setData');
jsTestIsAsync = true;
function runTest() {
document.getElementById('source').focus();
document.execCommand('selectAll');
document.execCommand('copy');
document.getElementById('destination').focus();
if (window.testRunner)
document.execCommand('paste');
}
function copy(event) {
event.clipboardData.setData('url', 'some bad URL');
event.preventDefault();
}
function paste(event) {
shouldBeEqualToString('event.clipboardData.getData("text/URI-list")', 'some bad URL');
shouldBeEqualToString('JSON.stringify(event.clipboardData.types)', '["text/uri-list"]');
shouldBeEqualToString('JSON.stringify(Array.from(event.clipboardData.items).map((item) => ({kind: item.kind, type: item.type})))',
'[{"kind":"string","type":"text/uri-list"}]');
document.getElementById('container').remove();
finishJSTest();
}
if (window.testRunner && window.internals) {
internals.settings.setCustomPasteboardDataEnabled(true);
runTest();
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>