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