Add a test that inserting a character inside a URL doesn't move caret per auto correction
[WebKit-https.git] / LayoutTests / editing / inserting / inserting-slash-inside-url-with-smart-link.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <textarea id="editor" cols="50" rows="5">
5 </textarea>
6 <script src="../../fast/js/resources/js-test-pre.js"></script>
7 <script>
8
9 if (window.testRunner) {
10     testRunner.dumpAsText();
11     internals.setAutomaticLinkDetectionEnabled(true);
12     internals.setAutomaticQuoteSubstitutionEnabled(true);
13 }
14
15 description('Test inserting a character inside a URL with both smart quote and smart link doesn\'t move the caret to the end of text\n'
16     + 'To manually run this test, enable "Check Spelling While Typing", "Smart Link", and "Smart Quotes", and insert a character inside the URL');
17
18 var editor = document.getElementById('editor');
19 editor.focus();
20 document.execCommand('InsertText', false, 'Why don\u2019t you take a look at https:/webkit.org/');
21 for (var i = 0; i < 'webkit.org/'.length; i++)
22     getSelection().modify('move', 'backward', 'character');
23 shouldBe('caretOffset = editor.selectionStart; caretOffset', 'editor.selectionEnd');
24
25 document.execCommand('InsertText', false, '/');
26
27 shouldBe('editor.selectionStart', 'caretOffset + 1');
28 shouldBe('editor.selectionEnd', 'caretOffset + 1');
29
30 editor.style.display = 'none';
31
32 </script>
33 </body>
34 </html>