2011-04-12 Pavel Podivilov <podivilov@chromium.org>
[WebKit-https.git] / LayoutTests / inspector / 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 test()
14 {
15     InspectorTest.runDebuggerTestSuite([
16         function testSetBreakpoint(next)
17         {
18             InspectorTest.showScriptSource("source-frame.html", didShowScriptSource);
19
20             function didShowScriptSource(sourceFrame)
21             {
22                 InspectorTest.addResult("Script source was shown.");
23                 InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "addBreakpoint", didAddBreakpoint);
24                 InspectorTest.setBreakpoint(sourceFrame, 17, "", true);
25             }
26
27             function didAddBreakpoint(lineNumber)
28             {
29               InspectorTest.addResult("Breakpoint added to source frame at line " + lineNumber);
30               next();
31             }
32         },
33
34         function testConsoleMessage(next)
35         {
36               InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "addMessage", didAddMessage);
37               InspectorTest.evaluateInPage("addErrorToConsole()");
38
39               function didAddMessage(message)
40               {
41                   InspectorTest.addResult("Message text: " + message.message);
42                   next();
43               }
44         },
45
46         function testShowResource(next)
47         {
48             WebInspector.showPanel("network");
49
50             InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "show", didShowSourceFrame);
51             var resources = WebInspector.resourceTreeModel._resourcesByURL;
52             for (var url in resources) {
53                 if (url.indexOf("debugger-test.js") !== -1) {
54                     WebInspector.panels.network._showResource(resources[url], 1);
55                     break;
56                 }
57             }
58
59             function didShowSourceFrame()
60             {
61                 next();
62             }
63         }
64     ]);
65 };
66
67 </script>
68
69 </head>
70
71 <body onload="runTest()">
72 <p>Tests that it's possible to set breakpoint in source frame, and that
73 source frame displays breakpoints and console errors.
74 </p>
75
76 </body>
77 </html>