Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector-enabled / sources / debugger / script-formatter-breakpoints-1.html
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
5 <script src="../../../inspector/sources/debugger/resources/unformatted.js"></script>
6
7 <script>
8
9 function f1()
10 {
11     var a=0;var b=1;var c=3;var d=4;var e=5;
12     var f=0;
13     return 0;
14 }
15
16 function onload()
17 {
18     if (window.testRunner) {
19         testRunner.waitUntilDone();
20         testRunner.showWebInspector();
21     }
22     runTest();
23 }
24
25 var test = function()
26 {
27     WebInspector.breakpointManager._storage._breakpoints = {};
28     var panel = WebInspector.panels.sources;
29     var scriptFormatter;
30     var sourceFrame;
31
32     InspectorTest.runDebuggerTestSuite([
33         function testSetup(next)
34         {
35             InspectorTest.scriptFormatter().then(function(sf) {
36                 scriptFormatter = sf;
37                 next();
38             });
39         },
40
41         function testBreakpointsInOriginalAndFormattedSource(next)
42         {
43             InspectorTest.showScriptSource("script-formatter-breakpoints-1.html", didShowScriptSource);
44
45             function didShowScriptSource(frame)
46             {
47                 sourceFrame = frame;
48                 InspectorTest.setBreakpoint(sourceFrame, 11, "", true);
49                 InspectorTest.waitUntilPaused(pausedInF1);
50                 InspectorTest.evaluateInPageWithTimeout("f1()");
51             }
52
53             function pausedInF1(callFrames)
54             {
55                 InspectorTest.dumpBreakpointSidebarPane("while paused in raw");
56                 InspectorTest.resumeExecution(resumed);
57             }
58
59             function resumed()
60             {
61                 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorAction.prototype, "_updateButton", uiSourceCodeScriptFormatted);
62                 scriptFormatter._toggleFormatScriptSource();
63             }
64
65             function uiSourceCodeScriptFormatted()
66             {
67                 // There should be a breakpoint in f1 although script is pretty-printed.
68                 InspectorTest.waitUntilPaused(pausedInF1Again);
69                 InspectorTest.evaluateInPageWithTimeout("f1()");
70             }
71
72             function pausedInF1Again(callFrames)
73             {
74                 InspectorTest.dumpBreakpointSidebarPane("while paused in pretty printed");
75                 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibleView.uiSourceCode());
76                 InspectorTest.dumpBreakpointSidebarPane("while paused in raw");
77                 InspectorTest.removeBreakpoint(sourceFrame, 11);
78                 InspectorTest.resumeExecution(next);
79             }
80         }
81     ]);
82
83 }
84 </script>
85 </head>
86 <body onload="onload()">
87 <p>Tests the script formatting is working fine with breakpoints.
88 </p>
89 </body>
90 </html>