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 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.
| |
| 20 var div = document.createElement("div"); | |
| 21 var text = base + prefix; | |
| 22 div.textContent = text; | |
| 23 var range = document.createRange(); | |
| 24 range.setStart(div.childNodes[0], base.length); | |
| 25 range.setEnd(div.childNodes[0], text.length); | |
| 26 WebInspector.ExecutionContextSelector.completionsForTextPromptInCurr entContext(div, text, text.length, range, false, checkExpected); | |
| 27 function checkExpected(completions) | |
| 28 { | |
| 29 InspectorTest.addResult("Checking '" + base + prefix + "'"); | |
| 30 var found; | |
|
lushnikov
2016/07/25 18:12:29
no need to declare "found" beforehand
einbinder
2016/07/25 20:11:35
Done.
| |
| 31 for (var i = 0; i < expected.length; i++) { | |
| 32 found = false; | |
|
lushnikov
2016/07/25 18:12:29
var found = completions.indexOf(expected[i]) !== -
einbinder
2016/07/25 20:11:35
Done.
| |
| 33 for (var j = 0; j < completions.length; j++) { | |
| 34 if (completions[j] === expected[i]) { | |
| 35 found = true; | |
| 36 break; | |
| 37 } | |
| 38 } | |
| 39 InspectorTest.addResult((found ? "Found" : "Not Found") + ": " + expected[i]); | |
| 40 } | |
| 41 InspectorTest.addResult(""); | |
| 42 resolve(); | |
| 43 } | |
| 44 }); | |
| 45 } | |
| 46 | |
| 47 Promise.all([ | |
| 48 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.
| |
| 49 testCompletions("", "win", ["window"]), | |
| 50 testCompletions("window[", '"doc', ['"document"]']), | |
| 51 testCompletions('window["document"].', "bo", ["body"]), | |
| 52 testCompletions('window["document"]["body"].', "textC", ["textContent"]) , | |
| 53 testCompletions('document.body.', "inner", ["innerText", "innerHTML"]), | |
| 54 testCompletions('document["body"][window.', "do", ["document"]), | |
| 55 testCompletions('document["body"][window["document"].body.childNodes[0]. ', "text", ["textContent"]), | |
| 56 testCompletions("templateString`asdf`","should",["shouldNotFindThis"]) | |
| 57 ]).then(InspectorTest.completeTest); | |
| 58 | |
| 59 } | |
| 60 </script> | |
| 61 </head> | |
| 62 <body onload="runTest()"> | |
| 63 <p>Tests that console correctly finds suggestions in complicated cases.</p> | |
| 64 </body> | |
| 65 </html> | |
| OLD | NEW |