blob: 3db2bf2940dc04b9eadad2d1f7becb55b03d9fe2 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<div id="container">
<button onclick="runTest()">Copy</button>
<div id="source" contenteditable><a href="javascript:dangerousCode()">hello</a>, <b onmouseover="dangerousCode()">world</b>. WebKit</div>
<div id="destination" onpaste="doPaste(event)" contenteditable>Paste here</div>
</div>
<script src="../../resources/js-test-pre.js"></script>
<script>
description('This tests copying and pasting a markup with an event handler and a javascript URL. WebKit should strip them away upon copy.');
jsTestIsAsync = true;
function dangerousCode() { }
function runTest() {
source.focus();
document.execCommand('selectAll');
document.execCommand('copy');
destination.focus();
document.execCommand('selectAll');
if (window.testRunner)
document.execCommand('paste');
}
function doPaste(event) {
html = event.clipboardData.getData('text/html');
shouldBeTrue('html.includes("hello")');
shouldBeTrue('html.includes("world")');
shouldBeFalse('html.includes("dangerousCode")');
container.remove();
finishJSTest();
}
if (window.testRunner)
window.onload = runTest;
successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>