| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/ui-helper.js"></script> |
| <script> |
| function runTest() |
| { |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| if (window.internals) |
| internals.setAutomaticLinkDetectionEnabled(true); |
| |
| var testTypeSpaceDiv = document.getElementById('testTypeSpace'); |
| var targetText = testTypeSpaceDiv.firstChild; |
| window.getSelection().setPosition(targetText, 15); |
| UIHelper.keyDown(" "); |
| var expectedContents = "The <a href=\"http://www.foo.com\">www.foo.com</a> should be underlined and there is an anchor node created for it."; |
| if (expectedContents == testTypeSpaceDiv.innerHTML) |
| document.getElementById('log').textContent = "PASS: the anchor for 'www.foo.com' has been created.\n" |
| else |
| document.getElementById('log').textContent = "Failed: the expected content was '" + expectedContents + "', but the actual result was '" + testTypeSpaceDiv.innerHTML + "'.\n" |
| |
| var testTypeLinkDiv = document.getElementById('testTypeLink'); |
| targetText = testTypeLinkDiv.firstChild; |
| window.getSelection().setPosition(targetText, 4); |
| UIHelper.keyDown("w"); |
| UIHelper.keyDown("w"); |
| UIHelper.keyDown("w"); |
| UIHelper.keyDown("."); |
| UIHelper.keyDown("b"); |
| UIHelper.keyDown("a"); |
| UIHelper.keyDown("r"); |
| UIHelper.keyDown("."); |
| UIHelper.keyDown("c"); |
| UIHelper.keyDown("o"); |
| UIHelper.keyDown("m"); |
| UIHelper.keyDown(" "); |
| expectedContents = "The <a href=\"http://www.bar.com\">www.bar.com</a> should be underlined and there is an anchor node created for it."; |
| if (expectedContents == testTypeLinkDiv.innerHTML) |
| document.getElementById('log').textContent += "PASS: the anchor for 'www.bar.com' has been created." |
| else |
| document.getElementById('log').textContent += "Failed: the expected content was '" + expectedContents + "', but the actual result was '" + testTypeLinkDiv.innerHTML + "'." |
| |
| if (window.internals) |
| internals.setAutomaticLinkDetectionEnabled(false); |
| } |
| </script> |
| </head> |
| <body> |
| <div id="testTypeSpace" contenteditable>The www.foo.comshould be underlined and there is an anchor node created for it.</div> |
| <div id="testTypeLink" contenteditable>The should be underlined and there is an anchor node created for it.</div> |
| <pre id="log"></pre> |
| </body> |
| <script> |
| runTest() |
| </script> |
| </html> |