Commit dc972314 authored by Joel Einbinder's avatar Joel Einbinder Committed by Commit Bot

DevTools: Fix TextPrompt expression calculation

Without shadow dom, the shadow-TextPrompt, the _proxyElement now contains a <style> tag

Bug: 934813
Change-Id: I5e3c9f33b94bae244587e549d6869055f08ee833
Reviewed-on: https://chromium-review.googlesource.com/c/1490193
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Reviewed-by: default avatarErik Luo <luoe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635806}
parent 91265887
......@@ -415,7 +415,7 @@ UI.TextPrompt = class extends Common.Object {
const expressionRange = wordQueryRange.cloneRange();
expressionRange.collapse(true);
expressionRange.setStartBefore(this._proxyElement);
expressionRange.setStartBefore(this._element);
const completionRequestId = ++this._completionRequestId;
const completions = await this._loadCompletions(expressionRange.toString(), wordQueryRange.toString(), !!force);
this._completionsReady(completionRequestId, selection, wordQueryRange, !!force, completions);
......
......@@ -15,3 +15,8 @@ Test with disableDefaultSuggestionForEmptyInput
Text:
TextWithCurrentSuggestion:
Test expression and query
Text:the expression and query
Expression:the expression and
Query:query
......@@ -3,7 +3,12 @@
var suggestions = ["heyoo", "hey it's a suggestion", "hey another suggestion"].map(s => ({text: s}));
var prompt = new UI.TextPrompt();
prompt.initialize(() => Promise.resolve(suggestions));
let expression, query;
prompt.initialize(async (e, q) => {
expression = e;
query = q;
return suggestions;
});
var div = document.createElement("div");
UI.inspectorView.element.appendChild(div);
prompt.attachAndStartEditing(div);
......@@ -32,5 +37,13 @@
TestRunner.addResult("Text:" + prompt.text());
TestRunner.addResult("TextWithCurrentSuggestion:" + prompt.textWithCurrentSuggestion());
TestRunner.addResult("\nTest expression and query")
prompt.setText("the expression and query");
await prompt.complete();
TestRunner.addResult("Text:" + prompt.text());
TestRunner.addResult("Expression:" + expression);
TestRunner.addResult("Query:" + query);
TestRunner.completeTest();
})();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment