Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / source-frame.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
6 <script>
7
8 function addErrorToConsole()
9 {
10     console.error("test error message");
11 }
12
13 function methodForBreakpoint()
14 {
15     alert("Hello world");
16 }
17
18 function test()
19 {
20     WebInspector.showPanel("resources");
21     InspectorTest.runDebuggerTestSuite([
22         function testSetBreakpoint(next)
23         {
24             InspectorTest.showScriptSource("source-frame.html", didShowScriptSource);
25
26             function didShowScriptSource(sourceFrame)
27             {
28                 InspectorTest.addResult("Script source was shown.");
29                 InspectorTest.addSniffer(WebInspector.JavaScriptSourceFrame.prototype, "_addBreakpointDecoration", didAddBreakpoint);
30                 InspectorTest.setBreakpoint(sourceFrame, 14, "", true);
31             }
32
33             function didAddBreakpoint(lineNumber)
34             {
35                 InspectorTest.addResult("Breakpoint added to source frame at line " + lineNumber);
36                 next();
37             }
38         },
39
40         function testConsoleMessage(next)
41         {
42             InspectorTest.showScriptSource("source-frame.html", didShowScriptSource);
43
44             var shownSourceFrame;
45             function didShowScriptSource(sourceFrame)
46             {
47                 InspectorTest.addResult("Script source was shown.");
48                 shownSourceFrame = sourceFrame;
49                 InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "addMessageToSource", didAddMessage);
50                 InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "clearMessages", clearMessages);
51                 InspectorTest.evaluateInPage("addErrorToConsole()");
52             }
53
54             function didAddMessage(lineNumber, message)
55             {
56                 if (this !== shownSourceFrame)
57                     return;
58                 InspectorTest.addResult("Message added to source frame: " + message.message);
59                 WebInspector.console.requestClearMessages();
60             }
61
62             function clearMessages()
63             {
64                 if (this !== shownSourceFrame)
65                     return;
66                 InspectorTest.addResult("Messages cleared in source frame.");
67                 next();
68             }
69         },
70
71         function testShowResource(next)
72         {
73             WebInspector.showPanel("network");
74
75             InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "show", didShowSourceFrame);
76
77             WebInspector.resourceTreeModel.forAllResources(visit);
78             function visit(resource)
79             {
80                 if (resource.url.indexOf("debugger-test.js") !== -1) {
81                     WebInspector.panels.resources.showResource(resource, 1);
82                     return true;
83                 }
84             }
85
86             function didShowSourceFrame()
87             {
88                 next();
89             }
90         }
91     ]);
92 };
93
94 </script>
95
96 </head>
97
98 <body onload="runTest()">
99 <p>Tests that it's possible to set breakpoint in source frame, and that
100 source frame displays breakpoints and console errors.
101 </p>
102
103 </body>
104 </html>