Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector-unit/text-prompt-hint.html

Issue 2285993002: DevTools: Fix flickering hint when typing in TextPrompt (Closed)
Patch Set: fix test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/text-prompt-hint-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <html>
2 <head>
3 <base href="/inspector-debug/"></base>
4 <script src="/inspector-debug/Runtime.js"></script>
5 <script src="/inspector-unit/inspector-unit-test.js"></script>
6 <script type="text/javascript">
7
8 function test()
9 {
10 var suggestions = ["testTextPrompt"];
11 var waitingForAutocomplete = null;
12 var completionsDone = function () {
13 console.error("completionsDone called too early!");
14 UnitTest.completeTest();
15 }
16 var prompt = new WebInspector.TextPrompt(completions);
17 var element = createElement("div");
18 WebInspector.inspectorView.element.appendChild(element);
19 var proxy = prompt.attachAndStartEditing(element);
20 prompt.setText("testT");
21 prompt.complete();
22 dumpTextPrompt();
23 completionsDone();
24 dumpTextPrompt();
25
26 typeCharacter("e");
27 dumpTextPrompt();
28
29 waitForAutocomplete(step2)
30 function step2()
31 {
32 completionsDone();
33 dumpTextPrompt();
34
35 typeCharacter("z");
36 waitForAutocomplete(step3);
37 }
38
39 function step3()
40 {
41 completionsDone();
42 dumpTextPrompt();
43 typeCharacter(null);
44 waitForAutocomplete(step4);
45 }
46
47 function step4()
48 {
49 completionsDone();
50 dumpTextPrompt();
51 typeCharacter(null);
52 waitForAutocomplete(step5);
53 }
54 function step5()
55 {
56 completionsDone();
57 dumpTextPrompt();
58 UnitTest.completeTest();
59 }
60
61 function completions(element, range, force, callback)
62 {
63 UnitTest.addResult("Requesting completions");
64 completionsDone = () => callback(suggestions.filter(s => s.startsWith(ra nge.toString())));
65 var temp = waitingForAutocomplete;
66 waitingForAutocomplete = null;
67 if (temp)
68 temp();
69 }
70
71 function waitForAutocomplete(fn)
72 {
73 waitingForAutocomplete = fn;
74 }
75
76 function dumpTextPrompt()
77 {
78 UnitTest.addResult("");
79 UnitTest.addResult("Text:" + prompt.text());
80 UnitTest.addResult("UserEnteredText:" + prompt.userEnteredText());
81 }
82
83 function typeCharacter(character)
84 {
85 var keyboardEvent = new KeyboardEvent("keydown", {
86 key: character || "Backspace",
87 charCode: character ? character.charCodeAt(0) : ""
88 });
89 element.dispatchEvent(keyboardEvent);
90
91 var selection = element.getComponentSelection();
92 var range = selection.getRangeAt(0);
93 var textNode = prompt._autocompleteElement ? prompt._autocompleteElement .previousSibling : element.childTextNodes()[element.childTextNodes().length-1];
94 if (!character)
95 textNode.textContent = textNode.textContent.substring(0,textNode.tex tContent.length-1);
96 else
97 textNode.textContent += character;
98 range.setStart(range.startContainer, range.startContainer.textContent.le ngth);
99 selection.removeAllRanges();
100 selection.addRange(range);
101 element.dispatchEvent(new Event("input", {bubbles: true, cancelable: fal se}));
102 }
103 }
104
105
106 </script>
107 </head>
108 <body>
109 <p>Tests that the hint displays properly on a WebInspector.TextPrompt with autoc omplete.</p>
110 </body>
111 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/text-prompt-hint-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698