| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 | 3 |
| 4 <link rel="stylesheet" href="resources/diff-before.css"> | 4 <link rel="stylesheet" href="resources/diff-before.css"> |
| 5 <link rel="stylesheet" href="resources/diff-after.css"> | 5 <link rel="stylesheet" href="resources/diff-after.css"> |
| 6 | 6 |
| 7 <script src="../../http/tests/inspector/inspector-test.js"></script> | 7 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 8 <script src="../../http/tests/inspector/debugger-test.js"></script> | 8 <script src="../../http/tests/inspector/debugger-test.js"></script> |
| 9 <script src="../../http/tests/inspector/sources-test.js"></script> | 9 <script src="../../http/tests/inspector/sources-test.js"></script> |
| 10 <script> | 10 <script> |
| 11 |
| 11 function test() | 12 function test() |
| 12 { | 13 { |
| 13 Runtime.experiments.enableForTest("sourceDiff"); | 14 Runtime.experiments.enableForTest("sourceDiff"); |
| 14 var textAfter; | 15 var textAfter; |
| 15 InspectorTest.showScriptSource("diff-after.css", onAfter); | 16 InspectorTest.waitForScriptSource("diff-after.css", uiSourceCode => uiSource
Code.requestContent().then(onAfterContent)); |
| 16 | 17 |
| 17 function onAfter(afterFrame) | 18 function onAfterContent(content) |
| 18 { | 19 { |
| 19 textAfter = afterFrame.textEditor.text(); | 20 textAfter = content; |
| 20 InspectorTest.showScriptSource("diff-before.css", onBefore); | 21 InspectorTest.waitForScriptSource("diff-before.css", onBeforeUISourceCod
e); |
| 21 } | 22 } |
| 22 | 23 |
| 23 function onBefore(beforeFrame) | 24 function onBeforeUISourceCode(uiSourceCode){ |
| 24 { | 25 uiSourceCode.setWorkingCopy(textAfter); |
| 25 InspectorTest.addSniffer(SourceFrame.SourceCodeDiff.prototype, "_decorat
ionsSetForTest", decorationsSet); | 26 InspectorTest.addSniffer(SourceFrame.SourceCodeDiff.prototype, "_decorat
ionsSetForTest", decorationsSet); |
| 26 beforeFrame.setContent(textAfter); | 27 InspectorTest.showUISourceCodePromise(uiSourceCode); |
| 27 } | 28 } |
| 28 | 29 |
| 29 function decorationsSet(decorations) | 30 function decorationsSet(decorations) |
| 30 { | 31 { |
| 31 Array.from(decorations).sort((a, b) => a[0] - b[0]).forEach(print); | 32 Array.from(decorations).sort((a, b) => a[0] - b[0]).forEach(print); |
| 32 InspectorTest.completeTest(); | 33 InspectorTest.completeTest(); |
| 33 | 34 |
| 34 function print(decoration) | 35 function print(decoration) |
| 35 { | 36 { |
| 36 var type = decoration[1].type; | 37 var type = decoration[1].type; |
| 37 var name = "Unknown"; | 38 var name = "Unknown"; |
| 38 if (type === SourceFrame.SourceCodeDiff.GutterDecorationType.Insert) | 39 if (type === SourceFrame.SourceCodeDiff.GutterDecorationType.Insert) |
| 39 name = "Insert"; | 40 name = "Insert"; |
| 40 else if (type === SourceFrame.SourceCodeDiff.GutterDecorationType.De
lete) | 41 else if (type === SourceFrame.SourceCodeDiff.GutterDecorationType.De
lete) |
| 41 name = "Delete"; | 42 name = "Delete"; |
| 42 else if (type === SourceFrame.SourceCodeDiff.GutterDecorationType.Mo
dify) | 43 else if (type === SourceFrame.SourceCodeDiff.GutterDecorationType.Mo
dify) |
| 43 name = "Modify"; | 44 name = "Modify"; |
| 44 | 45 |
| 45 InspectorTest.addResult(decoration[0] + ":" + name) | 46 InspectorTest.addResult(decoration[0] + ":" + name) |
| 46 } | 47 } |
| 47 } | 48 } |
| 48 } | 49 } |
| 49 </script> | 50 </script> |
| 50 </head> | 51 </head> |
| 51 | 52 |
| 52 <body onload="runTest()"> | 53 <body onload="runTest()"> |
| 53 <p>Tests that diff markers correctly appear in the gutter.</p> | 54 <p>Tests that diff markers correctly appear in the gutter.</p> |
| 54 </body> | 55 </body> |
| 55 </html> | 56 </html> |
| OLD | NEW |