Smart quoting could move the caret backwards in some configurations
[WebKit-https.git] / LayoutTests / editing / inserting / smart-quote-with-all-configurations.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <div id="editor" contenteditable><br></div>
5 <script src="../../resources/js-test-pre.js"></script>
6 <script>
7 if (window.testRunner)
8     testRunner.dumpAsText();
9
10 function config(config) {
11     editor.textContent = '';
12     internals.setContinuousSpellCheckingEnabled(config.continuousSpellchecking);
13     internals.setAutomaticQuoteSubstitutionEnabled(config.smartQuote);
14     internals.setAutomaticLinkDetectionEnabled(config.smartLink);
15     internals.setAutomaticDashSubstitutionEnabled(config.smartDash);
16     internals.setAutomaticTextReplacementEnabled(config.textReplacement);
17     internals.setAutomaticSpellingCorrectionEnabled(config.autocorrection);
18 }
19
20 function type(text) {
21     document.execCommand('InsertText', false, text);
22 }
23
24 function tryAllCombinations(configOptions, config) {
25     if (!configOptions.length) {
26         debug('');
27         evalAndLog('config(' + JSON.stringify(config) + ')');
28         shouldBe('type("We\'re"); type(" "); type("good"); editor.textContent', '"We\u2019re good"');
29         return;
30     }
31     var firstConfigOption = configOptions[0];
32     var remainingOptions = configOptions.slice(1);
33     config[firstConfigOption] = true;
34     tryAllCombinations(remainingOptions, config);
35
36     config[firstConfigOption] = false;
37     tryAllCombinations(remainingOptions, config);
38 }
39
40 var editor = document.getElementById('editor');
41 editor.focus();
42
43 if (!window.internals)
44     testFailed("This test requires internals to be ran manually. To test manually, type \"We're good\" with all combinations of spellchecking and substitutions options.");
45 else
46     tryAllCombinations(['continuousSpellchecking', 'smartLink', 'smartDash', 'textReplacement', 'autocorrection'], {smartQuote: true});
47
48 </script>
49 </body>
50 </html>