tony@chromium.org | c046160 | 2010-06-15 08:03:14 +0000 | [diff] [blame] | 1 | <p>This tests to make sure that copying/pasting HTML results in URLs being full paths so |
| 2 | pasting between websites works. To test manually, copy the selection and paste it into |
| 3 | the blue box. If this is a file:/// url, the links should be relative. If this is an |
| 4 | http:// url, the links should be absolute.</p> |
| 5 | <div id="test"> |
| 6 | <a href="../relative/path/foo.html">link</a><img src="resources/abe.png"> |
| 7 | </div> |
| 8 | <div id="pastehere" contenteditable="true" style="border: 1px solid blue" onpaste="paste()"> |
| 9 | </div> |
| 10 | <div id="results"></div> |
| 11 | <script> |
| 12 | function test() |
| 13 | { |
| 14 | var s = window.getSelection(); |
| 15 | var test = document.getElementById("test"); |
| 16 | s.selectAllChildren(test); |
| 17 | |
rniwa@webkit.org | 14f6b5b | 2012-06-13 08:51:53 +0000 | [diff] [blame] | 18 | if (!window.testRunner) |
tony@chromium.org | c046160 | 2010-06-15 08:03:14 +0000 | [diff] [blame] | 19 | return; |
rniwa@webkit.org | 14f6b5b | 2012-06-13 08:51:53 +0000 | [diff] [blame] | 20 | testRunner.dumpAsText(); |
| 21 | testRunner.waitUntilDone(); |
tony@chromium.org | c046160 | 2010-06-15 08:03:14 +0000 | [diff] [blame] | 22 | |
| 23 | document.execCommand("Copy"); |
| 24 | var pasteHere = document.getElementById("pastehere"); |
| 25 | s.setPosition(pasteHere, 0); |
| 26 | document.execCommand("Paste"); |
| 27 | } |
| 28 | |
| 29 | function paste() |
| 30 | { |
| 31 | setTimeout(afterPaste, 0); |
| 32 | } |
| 33 | |
| 34 | function afterPaste() |
| 35 | { |
| 36 | var pasteHere = document.getElementById("pastehere"); |
| 37 | var results = document.getElementById("results"); |
| 38 | results.appendChild(document.createTextNode(pasteHere.innerHTML)); |
rniwa@webkit.org | 14f6b5b | 2012-06-13 08:51:53 +0000 | [diff] [blame] | 39 | if (window.testRunner) |
| 40 | testRunner.notifyDone(); |
tony@chromium.org | c046160 | 2010-06-15 08:03:14 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | test(); |
| 44 | </script> |