Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | |
| 4 <script src="../../http/tests/inspector/console-test.js"></script> | |
| 5 <script> | |
| 6 | |
| 7 function templateString() | |
| 8 { | |
| 9 console.log("The template string should not run and you should not see this log"); | |
| 10 return { | |
| 11 shouldNotFindThis:56 | |
| 12 }; | |
| 13 } | |
| 14 | |
| 15 function test() | |
| 16 { | |
| 17 function testCompletions(base, prefix, expected) | |
| 18 { | |
| 19 return innerCompletions; | |
|
lushnikov
2016/07/29 01:56:54
Let's nest it less
var div = document.createEleme
einbinder
2016/07/29 20:33:53
Done.
| |
| 20 | |
| 21 function innerCompletions(resolve) | |
| 22 { | |
| 23 var div = document.createElement("div"); | |
| 24 var text = base + prefix; | |
| 25 div.textContent = text; | |
| 26 var range = document.createRange(); | |
| 27 range.setStart(div.childNodes[0], base.length); | |
| 28 range.setEnd(div.childNodes[0], text.length); | |
| 29 WebInspector.ExecutionContextSelector.completionsForTextPromptInCurr entContext(div, text, text.length, range, false, checkExpected); | |
| 30 function checkExpected(completions) | |
| 31 { | |
| 32 InspectorTest.addResult("Checking '" + base + prefix + "'"); | |
| 33 for (var i = 0; i < expected.length; i++) | |
| 34 InspectorTest.addResult(((completions.indexOf(expected[i]) ! == -1) ? "Found" : "Not Found") + ": " + expected[i]); | |
| 35 InspectorTest.addResult(""); | |
| 36 resolve(); | |
| 37 } | |
| 38 } | |
| 39 } | |
| 40 function sequential(tests) | |
| 41 { | |
| 42 return tests.length && new Promise(tests.shift()).then(()=>sequential(te sts)); | |
|
lushnikov
2016/07/29 01:56:55
fun sequential(tests)
{
var promise = Promise.
einbinder
2016/07/29 20:33:53
Done.
| |
| 43 } | |
| 44 | |
| 45 sequential([ | |
| 46 testCompletions("window.", "do", ["document"]), | |
|
lushnikov
2016/07/29 01:56:55
() => testCompletions("window.", "do", ["document"
einbinder
2016/07/29 20:33:53
Done.
| |
| 47 testCompletions("", "win", ["window"]), | |
| 48 testCompletions("window[", '"doc', ['"document"]']), | |
| 49 testCompletions('window["document"].', "bo", ["body"]), | |
| 50 testCompletions('window["document"]["body"].', "textC", ["textContent"]) , | |
| 51 testCompletions('document.body.', "inner", ["innerText", "innerHTML"]), | |
| 52 testCompletions('document["body"][window.', "do", ["document"]), | |
| 53 testCompletions('document["body"][window["document"].body.childNodes[0]. ', "text", ["textContent"]), | |
| 54 testCompletions("templateString`asdf`","should",["shouldNotFindThis"]) | |
|
luoe
2016/07/29 02:03:38
Nit: There should be spaces after the commas.
einbinder
2016/07/29 20:33:53
Done.
| |
| 55 ]).then(InspectorTest.completeTest); | |
| 56 | |
| 57 } | |
| 58 </script> | |
| 59 </head> | |
| 60 <body onload="runTest()"> | |
| 61 <p>Tests that console correctly finds suggestions in complicated cases.</p> | |
| 62 </body> | |
| 63 </html> | |
| OLD | NEW |