Editing tests should use testRunner instead of layoutTestController
[WebKit-https.git] / LayoutTests / editing / inserting / typing-space-to-trigger-smart-link.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script>
5 function runTest()
6 {
7     if (window.testRunner) {
8         testRunner.dumpAsText();
9         testRunner.setAutomaticLinkDetectionEnabled(true);
10     }
11
12     var targetDiv = document.getElementById('test');
13     var targetText = targetDiv.firstChild;
14     window.getSelection().setPosition(targetText, 15);
15     pressKey(" ");
16     document.getElementById('log').textContent = targetDiv.innerHTML;
17     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.";
18     if (expectedContents == targetDiv.innerHTML)
19         document.getElementById('log').textContent = "PASS: the anchor for 'www.foo.com' has been created."
20     else
21         document.getElementById('log').textContent = "Failed: the expected content was '" + expectedContents + "', but the actual result was '" + targetDiv.innerHTML + "'."
22
23     if (window.testRunner)
24         testRunner.setAutomaticLinkDetectionEnabled(false);
25 }
26
27 function pressKey(key)
28 {
29     if (window.KeyEvent) {
30         var ev = document.createEvent("KeyboardEvent");
31         ev.initKeyEvent("keypress", true, true, window,  0,0,0,0, 0, key.charCodeAt(0));
32         document.body.dispatchEvent(ev);
33     } else {
34         var ev = document.createEvent("TextEvent");
35         ev.initTextEvent('textInput', true, true, null, key.charAt(0));
36         document.body.dispatchEvent(ev);
37     }
38 }
39 </script>
40 </head>
41 <body>
42 <div id="test" contenteditable>The www.foo.comshould be underlined and there is an anchor node created for it.</div>
43 <pre id="log"></pre>
44 </body>
45 <script>
46 runTest()
47 </script>
48 </html>