Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger-breakpoints / set-conditional-breakpoint.html
blobd34fa81934a4ba37ca059019be3561083259f6f1
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
6 <script>
7 function oneLineTestFunction() { return 0; }
8 </script>
10 <script>
11 function oneLineTestFunction2() { return 0; }</script>
13 <script>
15 function testFunction()
17 var x = Math.sqrt(10);
18 console.log("Done.");
19 return x;
22 var test = function()
24 var currentSourceFrame;
25 InspectorTest.setQuiet(true);
26 InspectorTest.runDebuggerTestSuite([
27 function testSetConditionalBreakpointThatBreaks(next)
29 InspectorTest.showScriptSource("set-conditional-breakpoint.html", didShowScriptSource);
31 function didShowScriptSource(sourceFrame)
33 currentSourceFrame = sourceFrame;
34 InspectorTest.addResult("Script source was shown.");
35 setBreakpointAndWaitUntilPaused(currentSourceFrame, 16, "true", didPause);
36 InspectorTest.runTestFunction();
39 function didPause(callFrames)
41 InspectorTest.addResult("Script execution paused.");
42 InspectorTest.captureStackTrace(callFrames);
43 InspectorTest.dumpBreakpointSidebarPane();
44 InspectorTest.addSniffer(currentSourceFrame, "_removeBreakpointDecoration", breakpointRemoved);
45 InspectorTest.removeBreakpoint(currentSourceFrame, 16);
48 function breakpointRemoved()
50 InspectorTest.resumeExecution(didResume);
53 function didResume()
55 InspectorTest.dumpBreakpointSidebarPane()
56 InspectorTest.addResult("Script execution resumed.");
57 next();
61 function testSetConditionalBreakpointThatDoesNotBreak(next)
63 InspectorTest.showScriptSource("set-conditional-breakpoint.html", didShowScriptSource);
65 function didShowScriptSource(sourceFrame)
67 currentSourceFrame = sourceFrame;
68 InspectorTest.addResult("Script source was shown.");
69 setBreakpoint(currentSourceFrame, 16, "false");
70 InspectorTest.runTestFunction();
71 InspectorTest.addConsoleSniffer(testFunctionFinished);
75 function testFunctionFinished(callFrames)
77 InspectorTest.addResult("Test function finished.");
78 InspectorTest.dumpBreakpointSidebarPane();
79 InspectorTest.addSniffer(currentSourceFrame, "_removeBreakpointDecoration", breakpointRemoved);
80 InspectorTest.removeBreakpoint(currentSourceFrame, 16);
83 function breakpointRemoved()
85 InspectorTest.addResult("Breakpoints removed.");
86 InspectorTest.dumpBreakpointSidebarPane();
87 next();
90 ]);
92 function setBreakpoint(sourceFrame, lineNumber, condition, callback)
94 var expectedBreakpointId;
95 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.prototype, "_didSetBreakpointInDebugger", didSetBreakpointInDebugger);
96 InspectorTest.setBreakpoint(sourceFrame, lineNumber, condition, true);
98 function didSetBreakpointInDebugger(breakpointManagerCallback, breakpointId)
100 if (callback)
101 callback(breakpointId);
105 function setBreakpointAndWaitUntilPaused(sourceFrame, lineNumber, condition, pausedCallback)
107 setBreakpoint(sourceFrame, lineNumber, condition, didSetBreakpointInDebugger);
108 var expectedBreakpointId;
110 function didSetBreakpointInDebugger(breakpointId)
112 expectedBreakpointId = breakpointId;
113 InspectorTest.waitUntilPaused(didPause);
116 function didPause(callFrames, reason, breakpointIds)
118 InspectorTest.assertEquals(breakpointIds.length, 1);
119 InspectorTest.assertEquals(breakpointIds[0], expectedBreakpointId);
120 InspectorTest.assertEquals(reason, "other");
122 pausedCallback(callFrames);
127 </script>
128 </head>
130 <body onload="runTest()">
132 Tests setting breakpoints.
133 </p>
135 </body>
136 </html>