3 <script src="../../http/tests/inspector/inspector-test.js"></script>
9 function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, mapping)
11 var sourceLocation = mapping.compiledLocationToSourceLocation(compiledLineNumber, compiledColumnNumber);
12 InspectorTest.assertEquals(sourceURL, sourceLocation.sourceURL);
13 InspectorTest.assertEquals(sourceLineNumber, sourceLocation.lineNumber);
14 InspectorTest.assertEquals(sourceColumnNumber, sourceLocation.columnNumber);
17 function checkReverseMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, mapping)
19 var compiledLocation = mapping.sourceLocationToCompiledLocation(sourceURL, sourceLineNumber);
20 InspectorTest.assertEquals(compiledLineNumber, compiledLocation.lineNumber);
21 InspectorTest.assertEquals(compiledColumnNumber, compiledLocation.columnNumber);
24 InspectorTest.runTestSuite([
25 function testSimpleMapping(next)
30 012345678901234567890123456789012345
31 function add(variable_x, variable_y)
33 return variable_x + variable_y;
37 ----------------------------------------
40 012345678901234567890123456789012345
41 function add(a,b){return a+b}var global="foo";
43 var mappingPayload = {
44 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAAOD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;",
45 "sources":["example.js"]
47 var mapping = new WebInspector.ClosureCompilerSourceMapping(mappingPayload);
49 checkMapping(0, 9, "example.js", 0, 9, mapping);
50 checkMapping(0, 13, "example.js", 0, 13, mapping);
51 checkMapping(0, 15, "example.js", 0, 25, mapping);
52 checkMapping(0, 18, "example.js", 2, 4, mapping);
53 checkMapping(0, 25, "example.js", 2, 11, mapping);
54 checkMapping(0, 27, "example.js", 2, 24, mapping);
56 checkReverseMapping(0, 0, "example.js", 0, mapping);
57 checkReverseMapping(0, 17, "example.js", 1, mapping);
58 checkReverseMapping(0, 18, "example.js", 2, mapping);
59 checkReverseMapping(0, 29, "example.js", 4, mapping);
60 checkReverseMapping(0, 29, "example.js", 5, mapping);
61 InspectorTest.assertTrue(!mapping.sourceLocationToCompiledLocation("example.js", 6));
72 <body onload="runTest()">
73 <p>Tests ClosureCompilerSourceMapping.</p>