4a45f70226a3f8613b3eda962c40c26c946bb03e
[WebKit.git] / LayoutTests / inspector / debugger / compiler-source-mapping.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4
5 <script>
6
7 function test()
8 {
9     function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, mapping)
10     {
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);
15     }
16
17     InspectorTest.runTestSuite([
18         function testSimpleMapping(next)
19         {
20             // example.js:
21             // 0         1         2         3
22             // 012345678901234567890123456789012345
23             // function add(variable_x, variable_y)
24             // {
25             //     return variable_x + variable_y;
26             // }
27             // example-compiled.js:
28             // 0         1         2         3
29             // 012345678901234567890123456789012345
30             // function add(a,b){return a+b};
31             var mappingPayload = {
32                 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAAOD,EAAP,CAAoBC,CADxB;",
33                 "sources":["example.js"]
34             };
35             var mapping = new WebInspector.ClosureCompilerSourceMapping(mappingPayload);
36             checkMapping(0, 9, "example.js", 0, 9, mapping);
37             checkMapping(0, 13, "example.js", 0, 13, mapping);
38             checkMapping(0, 15, "example.js", 0, 25, mapping);
39             checkMapping(0, 18, "example.js", 2, 4, mapping);
40             checkMapping(0, 25, "example.js", 2, 11, mapping);
41             checkMapping(0, 27, "example.js", 2, 24, mapping);
42             next();
43         }
44     ]);
45 };
46
47 </script>
48
49 </head>
50
51 <body onload="runTest()">
52 <p>Tests ClosureCompilerSourceMapping.</p>
53 </body>
54 </html>