OLD | NEW |
1 TestRunner.addResult("This tests if the TextPrompt autocomplete works properly."
); | 1 TestRunner.addResult("This tests if the TextPrompt autocomplete works properly."
); |
2 | 2 |
3 var suggestions = ["heyoo", "hey it's a suggestion", "hey another suggestion"].m
ap(s => ({text: s})); | 3 var suggestions = ["heyoo", "hey it's a suggestion", "hey another suggestion"].m
ap(s => ({text: s})); |
4 var prompt = new UI.TextPrompt(); | 4 var prompt = new UI.TextPrompt(); |
5 prompt.initialize(() => Promise.resolve(suggestions)); | 5 prompt.initialize(() => Promise.resolve(suggestions)); |
6 var div = document.createElement("div"); | 6 var div = document.createElement("div"); |
7 UI.inspectorView.element.appendChild(div); | 7 UI.inspectorView.element.appendChild(div); |
8 prompt.attachAndStartEditing(div); | 8 prompt.attachAndStartEditing(div); |
9 prompt.setText("hey"); | 9 prompt.setText("hey"); |
10 TestRunner.addSniffer(prompt, "_completionsReady").then(step2); | 10 TestRunner.addSnifferPromise(prompt, "_completionsReady").then(step2); |
11 prompt.complete(); | 11 prompt.complete(); |
12 function step2() { | 12 function step2() { |
13 TestRunner.addResult("Text:" + prompt.text()); | 13 TestRunner.addResult("Text:" + prompt.text()); |
14 TestRunner.addResult("TextWithCurrentSuggestion:" + prompt.textWithCurrentSu
ggestion()); | 14 TestRunner.addResult("TextWithCurrentSuggestion:" + prompt.textWithCurrentSu
ggestion()); |
15 | 15 |
16 TestRunner.addResult("Test with inexact match:"); | 16 TestRunner.addResult("Test with inexact match:"); |
17 prompt.clearAutocomplete(); | 17 prompt.clearAutocomplete(); |
18 prompt.setText("inexactmatch"); | 18 prompt.setText("inexactmatch"); |
19 TestRunner.addSniffer(prompt, "_completionsReady").then(step3); | 19 TestRunner.addSnifferPromise(prompt, "_completionsReady").then(step3); |
20 prompt.complete(); | 20 prompt.complete(); |
21 } | 21 } |
22 function step3() { | 22 function step3() { |
23 TestRunner.addResult("Text:" + prompt.text()); | 23 TestRunner.addResult("Text:" + prompt.text()); |
24 TestRunner.addResult("TextWithCurrentSuggestion:" + prompt.textWithCurrentSu
ggestion()); | 24 TestRunner.addResult("TextWithCurrentSuggestion:" + prompt.textWithCurrentSu
ggestion()); |
25 TestRunner.completeTest(); | 25 TestRunner.completeTest(); |
26 } | 26 } |
OLD | NEW |