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="resources/obfuscated.js"></script> | 5 <script src="resources/obfuscated.js"></script> |
6 | 6 |
7 <script> | 7 <script> |
8 | 8 |
9 var test = function() | 9 var test = function() |
10 { | 10 { |
11 var panel = WebInspector.panels.scripts; | 11 var panel = WebInspector.panels.sources; |
12 var worker = new Worker("ScriptFormatterWorker.js"); | 12 var worker = new Worker("ScriptFormatterWorker.js"); |
13 | 13 |
14 InspectorTest.runDebuggerTestSuite([ | 14 InspectorTest.runDebuggerTestSuite([ |
15 function testScriptFormatterWorker(next) | 15 function testScriptFormatterWorker(next) |
16 { | 16 { |
17 worker.onmessage = InspectorTest.safeWrap(function(event) | 17 worker.onmessage = InspectorTest.safeWrap(function(event) |
18 { | 18 { |
19 InspectorTest.assertEquals("var x = 0\n", event.data.content); | 19 InspectorTest.assertEquals("var x = 0\n", event.data.content); |
20 next(); | 20 next(); |
21 }); | 21 }); |
(...skipping 12 matching lines...) Expand all Loading... |
34 var formatter = new WebInspector.ScriptFormatter(); | 34 var formatter = new WebInspector.ScriptFormatter(); |
35 | 35 |
36 InspectorTest.showScriptSource("obfuscated.js", didShowScriptSource)
; | 36 InspectorTest.showScriptSource("obfuscated.js", didShowScriptSource)
; |
37 function didShowScriptSource(sourceFrame) | 37 function didShowScriptSource(sourceFrame) |
38 { | 38 { |
39 formatter.formatContent("text/javascript", sourceFrame._textEdit
or.text(), didFormatContent); | 39 formatter.formatContent("text/javascript", sourceFrame._textEdit
or.text(), didFormatContent); |
40 } | 40 } |
41 | 41 |
42 function didFormatContent(content, mapping) | 42 function didFormatContent(content, mapping) |
43 { | 43 { |
44 var source = WebInspector.panels.scripts.visibleView._textEditor
.text(); | 44 var source = WebInspector.panels.sources.visibleView._textEditor
.text(); |
45 var formattedSource = content; | 45 var formattedSource = content; |
46 | 46 |
47 function testMapping(string) | 47 function testMapping(string) |
48 { | 48 { |
49 var originalPosition = source.indexOf(string); | 49 var originalPosition = source.indexOf(string); |
50 InspectorTest.assertTrue(originalPosition !== -1); | 50 InspectorTest.assertTrue(originalPosition !== -1); |
51 var originalLocation = WebInspector.Formatter.positionToLoca
tion(source.lineEndings(), originalPosition); | 51 var originalLocation = WebInspector.Formatter.positionToLoca
tion(source.lineEndings(), originalPosition); |
52 var formattedLocation = mapping.originalToFormatted(original
Location[0], originalLocation[1]); | 52 var formattedLocation = mapping.originalToFormatted(original
Location[0], originalLocation[1]); |
53 var formattedPosition = WebInspector.Formatter.locationToPos
ition(formattedSource.lineEndings(), formattedLocation[0], formattedLocation[1])
; | 53 var formattedPosition = WebInspector.Formatter.locationToPos
ition(formattedSource.lineEndings(), formattedLocation[0], formattedLocation[1])
; |
54 var expectedFormattedPosition = formattedSource.indexOf(stri
ng); | 54 var expectedFormattedPosition = formattedSource.indexOf(stri
ng); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 </script> | 97 </script> |
98 | 98 |
99 </head> | 99 </head> |
100 | 100 |
101 <body onload="runTest()"> | 101 <body onload="runTest()"> |
102 <p>Tests the script formatting functionality. | 102 <p>Tests the script formatting functionality. |
103 </p> | 103 </p> |
104 | 104 |
105 </body> | 105 </body> |
106 </html> | 106 </html> |
OLD | NEW |