| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../http/tests/inspector/sources-test.js"></script> |
| 5 <script src="../../http/tests/inspector/console-test.js"></script> |
| 6 <script> |
| 7 |
| 8 function test() |
| 9 { |
| 10 InspectorTest.addSniffer(WebInspector.UISourceCode.prototype, "addLineMessag
e", dumpLineMessage, true); |
| 11 |
| 12 InspectorTest.runTestSuite([ |
| 13 function testConsoleLogAndReturnMessageLocation(next) |
| 14 { |
| 15 InspectorTest.waitUntilNthMessageReceivedPromise(2) |
| 16 .then(() => InspectorTest.dumpConsoleMessages()) |
| 17 .then(() => WebInspector.ConsoleView.clearConsole()) |
| 18 .then(() => next()); |
| 19 |
| 20 createSnippetPromise("console.log(239);42") |
| 21 .then(uiSourceCode => selectSourceCode(uiSourceCode)) |
| 22 .then(uiSourceCode => renameSourceCodePromise("name1", uiSourceC
ode)) |
| 23 .then(() => runSelectedSnippet()); |
| 24 }, |
| 25 |
| 26 function testSnippetSyntaxError(next) |
| 27 { |
| 28 InspectorTest.waitUntilNthMessageReceivedPromise(1) |
| 29 .then(() => InspectorTest.dumpConsoleMessages()) |
| 30 .then(() => WebInspector.ConsoleView.clearConsole()) |
| 31 .then(() => next()); |
| 32 |
| 33 createSnippetPromise("\n }") |
| 34 .then(uiSourceCode => selectSourceCode(uiSourceCode)) |
| 35 .then(uiSourceCode => renameSourceCodePromise("name2", uiSourceC
ode)) |
| 36 .then(() => runSelectedSnippet()); |
| 37 }, |
| 38 |
| 39 function testConsoleErrorHighlight(next) |
| 40 { |
| 41 InspectorTest.waitUntilNthMessageReceivedPromise(1) |
| 42 .then(() => InspectorTest.dumpConsoleMessages()) |
| 43 .then(() => WebInspector.ConsoleView.clearConsole()) |
| 44 .then(() => next()); |
| 45 |
| 46 createSnippetPromise("\n console.error(42);") |
| 47 .then(uiSourceCode => selectSourceCode(uiSourceCode)) |
| 48 .then(uiSourceCode => renameSourceCodePromise("name3", uiSourceC
ode)) |
| 49 .then(() => runSelectedSnippet()); |
| 50 } |
| 51 ]); |
| 52 |
| 53 function createSnippetPromise(content) |
| 54 { |
| 55 var callback; |
| 56 var promise = new Promise(fullfill => callback = fullfill); |
| 57 WebInspector.scriptSnippetModel._project.createFile("", null, content, c
allback); |
| 58 return promise; |
| 59 } |
| 60 |
| 61 function renameSourceCodePromise(newName, uiSourceCode) |
| 62 { |
| 63 var callback; |
| 64 var promise = new Promise(fullfill => callback = fullfill); |
| 65 uiSourceCode.rename(newName, () => callback(uiSourceCode)); |
| 66 return promise; |
| 67 } |
| 68 |
| 69 function selectSourceCode(uiSourceCode) |
| 70 { |
| 71 WebInspector.SourcesPanel.instance()._sourceSelected({ data: { uiSourceC
ode: uiSourceCode }}); |
| 72 return uiSourceCode; |
| 73 } |
| 74 |
| 75 function dumpLineMessage(level, text, lineNumber, columnNumber) |
| 76 { |
| 77 InspectorTest.addResult(`Line Message was added: ${this.url()} ${level}
'${text}':${lineNumber}:${columnNumber}`); |
| 78 } |
| 79 |
| 80 function runSelectedSnippet() |
| 81 { |
| 82 WebInspector.SourcesPanel.instance()._runSnippet(); |
| 83 } |
| 84 } |
| 85 </script> |
| 86 </head> |
| 87 <body onload="runTest()"> |
| 88 <p>Test that link to snippet works.</p> |
| 89 </body> |
| 90 </html> |
| OLD | NEW |