blob: a95fa46d0f69e93acaf8c6fdfb12cf6a22b75b38 [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().setPosition(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.replace(/blob\:http\:\/\/localhost\:8080\/[a-z0-9\-]+/, 'blob://localhost:8080/...')));
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = () => {
if (document.location.search == "?paste")
doPaste();
else
test();
}
</script>