Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions.html |
| diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions.html b/third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..24303c10b75dab3955a6f4c3f862dc501b29da16 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions.html |
| @@ -0,0 +1,65 @@ |
| +<html> |
| +<head> |
| +<script src="../../http/tests/inspector/inspector-test.js"></script> |
| +<script src="../../http/tests/inspector/console-test.js"></script> |
| +<script> |
| + |
| +function templateString() |
| +{ |
| + console.log("The template string should not run and you should not see this log"); |
| + return { |
| + shouldNotFindThis:56 |
| + }; |
| +} |
| + |
| +function test() |
| +{ |
| + function testCompletions(base, prefix, expected) |
| + { |
| + return new Promise(resolve => { |
|
lushnikov
2016/07/25 18:12:29
style: we don't use multiline arrow functions for
einbinder
2016/07/25 20:11:35
Done.
|
| + var div = document.createElement("div"); |
| + var text = base + prefix; |
| + div.textContent = text; |
| + var range = document.createRange(); |
| + range.setStart(div.childNodes[0], base.length); |
| + range.setEnd(div.childNodes[0], text.length); |
| + WebInspector.ExecutionContextSelector.completionsForTextPromptInCurrentContext(div, text, text.length, range, false, checkExpected); |
| + function checkExpected(completions) |
| + { |
| + InspectorTest.addResult("Checking '" + base + prefix + "'"); |
| + var found; |
|
lushnikov
2016/07/25 18:12:29
no need to declare "found" beforehand
einbinder
2016/07/25 20:11:35
Done.
|
| + for (var i = 0; i < expected.length; i++) { |
| + found = false; |
|
lushnikov
2016/07/25 18:12:29
var found = completions.indexOf(expected[i]) !== -
einbinder
2016/07/25 20:11:35
Done.
|
| + for (var j = 0; j < completions.length; j++) { |
| + if (completions[j] === expected[i]) { |
| + found = true; |
| + break; |
| + } |
| + } |
| + InspectorTest.addResult((found ? "Found" : "Not Found") + ": " + expected[i]); |
| + } |
| + InspectorTest.addResult(""); |
| + resolve(); |
| + } |
| + }); |
| + } |
| + |
| + Promise.all([ |
| + testCompletions("window.", "do", ["document"]), |
|
lushnikov
2016/07/25 18:12:29
it's daunting to write a huge Promise.all, but thi
einbinder
2016/07/25 20:11:35
I misread Promise.all docs, done.
|
| + testCompletions("", "win", ["window"]), |
| + testCompletions("window[", '"doc', ['"document"]']), |
| + testCompletions('window["document"].', "bo", ["body"]), |
| + testCompletions('window["document"]["body"].', "textC", ["textContent"]), |
| + testCompletions('document.body.', "inner", ["innerText", "innerHTML"]), |
| + testCompletions('document["body"][window.', "do", ["document"]), |
| + testCompletions('document["body"][window["document"].body.childNodes[0].', "text", ["textContent"]), |
| + testCompletions("templateString`asdf`","should",["shouldNotFindThis"]) |
| + ]).then(InspectorTest.completeTest); |
| + |
| +} |
| +</script> |
| +</head> |
| +<body onload="runTest()"> |
| +<p>Tests that console correctly finds suggestions in complicated cases.</p> |
| +</body> |
| +</html> |