| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../http/tests/inspector/console-test.js"></script> | 4 <script src="../../http/tests/inspector/console-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 function templateString() | 6 function templateString() |
| 7 { | 7 { |
| 8 console.log("The template string should not run and you should not see this
log"); | 8 console.log("The template string should not run and you should not see this
log"); |
| 9 return { | 9 return { |
| 10 shouldNotFindThis:56 | 10 shouldNotFindThis:56 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 function test() | 25 function test() |
| 26 { | 26 { |
| 27 var consoleEditor; | 27 var consoleEditor; |
| 28 function testCompletions(text, expected, force) | 28 function testCompletions(text, expected, force) |
| 29 { | 29 { |
| 30 var cursorPosition = text.indexOf('|'); | 30 var cursorPosition = text.indexOf('|'); |
| 31 if (cursorPosition < 0) | 31 if (cursorPosition < 0) |
| 32 cursorPosition = Infinity; | 32 cursorPosition = Infinity; |
| 33 consoleEditor.setText(text.replace('|', '')); | 33 consoleEditor.setText(text.replace('|', '')); |
| 34 consoleEditor.setSelection(Common.TextRange.createFromLocation(0, cursor
Position)); | 34 consoleEditor.setSelection(TextUtils.TextRange.createFromLocation(0, cur
sorPosition)); |
| 35 consoleEditor._autocompleteController.autocomplete(force); | 35 consoleEditor._autocompleteController.autocomplete(force); |
| 36 return InspectorTest.addSnifferPromise(consoleEditor._autocompleteContro
ller, "_onSuggestionsShownForTest").then(checkExpected); | 36 return InspectorTest.addSnifferPromise(consoleEditor._autocompleteContro
ller, "_onSuggestionsShownForTest").then(checkExpected); |
| 37 | 37 |
| 38 function checkExpected(suggestions) | 38 function checkExpected(suggestions) |
| 39 { | 39 { |
| 40 var completions = new Map(suggestions.map(suggestion => [suggestion.
text, suggestion])); | 40 var completions = new Map(suggestions.map(suggestion => [suggestion.
text, suggestion])); |
| 41 var message = "Checking '" + text.replace('\n', '\\n').replace('\r',
'\\r') + "'"; | 41 var message = "Checking '" + text.replace('\n', '\\n').replace('\r',
'\\r') + "'"; |
| 42 if (force) | 42 if (force) |
| 43 message += " forcefully"; | 43 message += " forcefully"; |
| 44 InspectorTest.addResult(message); | 44 InspectorTest.addResult(message); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 () => testCompletions('complicatedObject["notDangerous();', ['"notDanger
ous();"]']), | 114 () => testCompletions('complicatedObject["notDangerous();', ['"notDanger
ous();"]']), |
| 115 ]).then(InspectorTest.completeTest); | 115 ]).then(InspectorTest.completeTest); |
| 116 | 116 |
| 117 } | 117 } |
| 118 </script> | 118 </script> |
| 119 </head> | 119 </head> |
| 120 <body onload="runTest()"> | 120 <body onload="runTest()"> |
| 121 <p>Tests that console correctly finds suggestions in complicated cases.</p> | 121 <p>Tests that console correctly finds suggestions in complicated cases.</p> |
| 122 </body> | 122 </body> |
| 123 </html> | 123 </html> |
| OLD | NEW |