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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/inspector-unit/text-prompt-hint.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/text-prompt-hint.html b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/text-prompt-hint.html
new file mode 100644
index 0000000000000000000000000000000000000000..b79f7029707304bbc04fb56988eb6756aa86d364
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/text-prompt-hint.html
@@ -0,0 +1,111 @@
+<html>
+<head>
+<base href="/inspector-debug/"></base>
+<script src="/inspector-debug/Runtime.js"></script>
+<script src="/inspector-unit/inspector-unit-test.js"></script>
+<script type="text/javascript">
+
+function test()
+{
+ var suggestions = ["testTextPrompt"];
+ var waitingForAutocomplete = null;
+ var completionsDone = function () {
+ console.error("completionsDone called too early!");
+ UnitTest.completeTest();
+ }
+ var prompt = new WebInspector.TextPrompt(completions);
+ var element = createElement("div");
+ WebInspector.inspectorView.element.appendChild(element);
+ var proxy = prompt.attachAndStartEditing(element);
+ prompt.setText("testT");
+ prompt.complete();
+ dumpTextPrompt();
+ completionsDone();
+ dumpTextPrompt();
+
+ typeCharacter("e");
+ dumpTextPrompt();
+
+ waitForAutocomplete(step2)
+ function step2()
+ {
+ completionsDone();
+ dumpTextPrompt();
+
+ typeCharacter("z");
+ waitForAutocomplete(step3);
+ }
+
+ function step3()
+ {
+ completionsDone();
+ dumpTextPrompt();
+ typeCharacter(null);
+ waitForAutocomplete(step4);
+ }
+
+ function step4()
+ {
+ completionsDone();
+ dumpTextPrompt();
+ typeCharacter(null);
+ waitForAutocomplete(step5);
+ }
+ function step5()
+ {
+ completionsDone();
+ dumpTextPrompt();
+ UnitTest.completeTest();
+ }
+
+ function completions(element, range, force, callback)
+ {
+ UnitTest.addResult("Requesting completions");
+ completionsDone = () => callback(suggestions.filter(s => s.startsWith(range.toString())));
+ var temp = waitingForAutocomplete;
+ waitingForAutocomplete = null;
+ if (temp)
+ temp();
+ }
+
+ function waitForAutocomplete(fn)
+ {
+ waitingForAutocomplete = fn;
+ }
+
+ function dumpTextPrompt()
+ {
+ UnitTest.addResult("");
+ UnitTest.addResult("Text:" + prompt.text());
+ UnitTest.addResult("UserEnteredText:" + prompt.userEnteredText());
+ }
+
+ function typeCharacter(character)
+ {
+ var keyboardEvent = new KeyboardEvent("keydown", {
+ key: character || "Backspace",
+ charCode: character ? character.charCodeAt(0) : ""
+ });
+ element.dispatchEvent(keyboardEvent);
+
+ var selection = element.getComponentSelection();
+ var range = selection.getRangeAt(0);
+ var textNode = prompt._autocompleteElement ? prompt._autocompleteElement.previousSibling : element.childTextNodes()[element.childTextNodes().length-1];
+ if (!character)
+ textNode.textContent = textNode.textContent.substring(0,textNode.textContent.length-1);
+ else
+ textNode.textContent += character;
+ range.setStart(range.startContainer, range.startContainer.textContent.length);
+ selection.removeAllRanges();
+ selection.addRange(range);
+ element.dispatchEvent(new Event("input", {bubbles: true, cancelable: false}));
+ }
+}
+
+
+</script>
+</head>
+<body>
+<p>Tests that the hint displays properly on a WebInspector.TextPrompt with autocomplete.</p>
+</body>
+</html>
« 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