1 var initialize_SourcesTest = function() {
3 InspectorTest
.preloadPanel("sources");
5 function testSourceMapping(text1
, text2
, mapping
, testToken
)
7 var originalPosition
= text1
.indexOf(testToken
);
8 InspectorTest
.assertTrue(originalPosition
!== -1);
9 var originalLocation
= WebInspector
.Formatter
.positionToLocation(text1
.lineEndings(), originalPosition
);
10 var formattedLocation
= mapping
.originalToFormatted(originalLocation
[0], originalLocation
[1]);
11 var formattedPosition
= WebInspector
.Formatter
.locationToPosition(text2
.lineEndings(), formattedLocation
[0], formattedLocation
[1]);
12 var expectedFormattedPosition
= text2
.indexOf(testToken
);
13 if (expectedFormattedPosition
=== formattedPosition
)
14 InspectorTest
.addResult(String
.sprintf("Correct mapping for <%s>", testToken
));
16 InspectorTest
.addResult(String
.sprintf("ERROR: Wrong mapping for <%s>", testToken
));
19 InspectorTest
.testPrettyPrint = function(mimeType
, text
, mappingQueries
, next
)
21 new WebInspector
.ScriptFormatter(mimeType
, text
, didFormatContent
);
23 function didFormatContent(formattedSource
, mapping
)
25 InspectorTest
.addResult("====== 8< ------");
26 InspectorTest
.addResult(formattedSource
);
27 InspectorTest
.addResult("------ >8 ======");
28 while (mappingQueries
&& mappingQueries
.length
)
29 testSourceMapping(text
, formattedSource
, mapping
, mappingQueries
.shift());