blob: b01bca2917d8cad368f4bc6cef4d356569f669f0 [file] [log] [blame]
<p>This tests to make sure that copying/pasting HTML results in URLs being full paths so
pasting between websites works. To test manually, copy the selection and paste it into
the blue box. If this is a file:/// url, the links should be relative. If this is an
http:// url, the links should be absolute.</p>
<div id="test">
<a href="../relative/path/foo.html">link</a><img src="resources/compass.jpg">
</div>
<div id="pastehere" contenteditable="true" style="border: 1px solid blue" onpaste="paste()">
</div>
<div id="results"></div>
<script>
function test()
{
var s = window.getSelection();
var test = document.getElementById("test");
s.selectAllChildren(test);
if (!window.testRunner)
return;
testRunner.dumpAsText();
testRunner.waitUntilDone();
document.execCommand("Copy");
// It looks like on a mac, URLs are resolved only if the page we're pasting
// into is different from the page we copied from.
document.location.href = "http://localhost:8080/misc/copy-resolves-urls.html?paste";
}
function doPaste()
{
var pasteHere = document.getElementById("pastehere");
window.getSelection().collapse(pasteHere, 0);
document.execCommand("Paste");
}
function paste()
{
setTimeout(afterPaste, 0);
}
function afterPaste()
{
var pasteHere = document.getElementById("pastehere");
var results = document.getElementById("results");
results.appendChild(document.createTextNode(pasteHere.innerHTML));
if (window.testRunner)
testRunner.notifyDone();
}
if (document.location.search == "?paste")
doPaste();
else
test();
</script>