| 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/debugger-test.js"></script> | 4 <script src="../../http/tests/inspector/debugger-test.js"></script> |
| 5 <script src="debugger/resources/obfuscated.js"></script> | 5 <script src="debugger/resources/obfuscated.js"></script> |
| 6 | 6 |
| 7 <script> | 7 <script> |
| 8 async function test() | 8 async function test() |
| 9 { | 9 { |
| 10 var uiSourceCode = await InspectorTest.waitForUISourceCode("obfuscated.js"); | 10 var uiSourceCode = await InspectorTest.waitForUISourceCode("obfuscated.js"); |
| 11 var formatData = await Sources.sourceFormatter.format(uiSourceCode); | 11 var formatData = await Sources.sourceFormatter.format(uiSourceCode); |
| 12 var targetContent = await formatData.formattedSourceCode.requestContent(); | 12 var targetContent = await formatData.formattedSourceCode.requestContent(); |
| 13 | 13 |
| 14 InspectorTest.addResult(`Formatted:\n${targetContent}`); | 14 InspectorTest.addResult(`Formatted:\n${targetContent}`); |
| 15 | 15 |
| 16 var originalContent = await uiSourceCode.requestContent(); | 16 var originalContent = await uiSourceCode.requestContent(); |
| 17 var text = new TextUtils.Text(originalContent); | 17 var text = new TextUtils.Text(originalContent); |
| 18 var positions = []; | 18 var positions = []; |
| 19 for (var offset = originalContent.indexOf("{"); offset >= 0; offset = origin
alContent.indexOf("{", offset + 1)) | 19 for (var offset = originalContent.indexOf("{"); offset >= 0; offset = origin
alContent.indexOf("{", offset + 1)) |
| 20 positions.push(text.positionFromOffset(offset)); | 20 positions.push(text.positionFromOffset(offset)); |
| 21 var script = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSou
rceCode, 0, 0).script(); | 21 var script = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSo
urceCode, 0, 0)[0].script(); |
| 22 | 22 |
| 23 InspectorTest.addResult("Location mapping with formatted source:"); | 23 InspectorTest.addResult("Location mapping with formatted source:"); |
| 24 dumpLocations(positions); | 24 dumpLocations(positions); |
| 25 | 25 |
| 26 Sources.sourceFormatter.discardFormattedUISourceCode(formatData.formattedSou
rceCode); | 26 Sources.sourceFormatter.discardFormattedUISourceCode(formatData.formattedSou
rceCode); |
| 27 | 27 |
| 28 InspectorTest.addResult("Location mapping without formatted source:"); | 28 InspectorTest.addResult("Location mapping without formatted source:"); |
| 29 dumpLocations(positions); | 29 dumpLocations(positions); |
| 30 | 30 |
| 31 InspectorTest.completeTest(); | 31 InspectorTest.completeTest(); |
| 32 | 32 |
| 33 function dumpLocations(positions) { | 33 function dumpLocations(positions) { |
| 34 for (var position of positions) { | 34 for (var position of positions) { |
| 35 var rawLocation = InspectorTest.debuggerModel.createRawLocation(script,
position.lineNumber, position.columnNumber); | 35 var rawLocation = InspectorTest.debuggerModel.createRawLocation(script,
position.lineNumber, position.columnNumber); |
| 36 var uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocati
on(rawLocation); | 36 var uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocati
on(rawLocation); |
| 37 InspectorTest.addResult(`${rawLocation.lineNumber}:${rawLocation.columnN
umber} -> ${uiLocation.lineNumber}:${uiLocation.columnNumber}`); | 37 InspectorTest.addResult(`${rawLocation.lineNumber}:${rawLocation.columnN
umber} -> ${uiLocation.lineNumber}:${uiLocation.columnNumber}`); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 </script> | 41 </script> |
| 42 | 42 |
| 43 </head> | 43 </head> |
| 44 <body onload="runTest()"> | 44 <body onload="runTest()"> |
| 45 <p>Tests how SourceFormatter handles JS sources</p> | 45 <p>Tests how SourceFormatter handles JS sources</p> |
| 46 </body> | 46 </body> |
| 47 </html> | 47 </html> |
| OLD | NEW |