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 test() | |
| 8 { | |
| 9 function testCompletions(base, prefix, expected) | |
| 10 { | |
| 11 return new Promise(resolve => { | |
| 12 var div = document.createElement("div"); | |
| 13 var text = base + prefix; | |
| 14 div.textContent = text; | |
| 15 var range = document.createRange(); | |
| 16 range.setStart(div.childNodes[0], base.length); | |
| 17 range.setEnd(div.childNodes[0], text.length); | |
| 18 WebInspector.ExecutionContextSelector.completionsForTextPromptInCurr entContext(div, text, text.length, range, false, checkExpected); | |
| 19 function checkExpected(completions) | |
| 20 { | |
| 21 InspectorTest.addResult("Checking '" + base + prefix + "'"); | |
| 22 var found; | |
| 23 for (var i = 0; i < expected.length; i++) { | |
| 24 found = false; | |
| 25 for (var j = 0; j < completions.length; j++) { | |
| 26 if (completions[j] === expected[i]) { | |
| 27 found = true; | |
| 28 break; | |
| 29 } | |
| 30 } | |
| 31 InspectorTest.addResult((found ? "Found" : "Not Found") + ": " + expected[i]); | |
| 32 } | |
| 33 InspectorTest.addResult(""); | |
| 34 resolve(); | |
| 35 } | |
| 36 }); | |
| 37 } | |
| 38 | |
| 39 Promise.all([ | |
| 40 testCompletions("window.", "do", ["document"]), | |
|
lushnikov
2016/07/20 23:37:54
can we evaluate some object in the page and run co
einbinder
2016/07/22 23:26:45
It is a white list so it won't be affected unless
| |
| 41 testCompletions("", "win", ["window"]), | |
| 42 testCompletions("window[", '"doc', ['"document"]']), | |
| 43 testCompletions('window["document"].', "bo", ["body"]), | |
| 44 testCompletions('window["document"]["body"].', "textC", ["textContent"]) , | |
| 45 testCompletions('document.body.', "inner", ["innerText", "innerHTML"]), | |
| 46 testCompletions('document["body"][window.', "do", ["document"]), | |
| 47 testCompletions('document["body"][window["document"].body.childNodes[0]. ', "text", ["textContent"]), | |
| 48 | |
| 49 ]).then(InspectorTest.completeTest); | |
| 50 | |
| 51 } | |
| 52 </script> | |
| 53 </head> | |
| 54 <body onload="runTest()"> | |
| 55 <p>Tests that console correctly finds suggestions in complicated cases.</p> | |
| 56 </body> | |
| 57 </html> | |
| OLD | NEW |