Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / inspector / sources-test.js
blob707fb81d01ec298e4081e830df8d9d859dfb9f63
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));
15 else
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());
31 next();