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..cb3a887385e29a7325469c2a673d840490c460c4 |
| --- /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(innerCompletions); |
| + |
| + function innerCompletions(resolve) |
| + { |
| + 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 + "'"); |
| + for (var i = 0; i < expected.length; i++) |
| + InspectorTest.addResult(((completions.indexOf(expected[i]) !== -1) ? "Found" : "Not Found") + ": " + expected[i]); |
| + InspectorTest.addResult(""); |
| + resolve(); |
| + } |
| + } |
| + } |
| + function sequential(tests) |
| + { |
| + if (tests.length > 1) |
| + return tests.pop().then(sequential(tests)); |
| + return tests.pop(); |
| + } |
| + |
| + sequential([ |
| + testCompletions("window.", "do", ["document"]), |
|
lushnikov
2016/07/25 22:48:20
still, not really sequential ;)
|
| + 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> |