Web Inspector: Remove recompileAllJSFunctions timer in ScriptDebugServer
[WebKit-https.git] / LayoutTests / inspector-protocol / debugger / setBreakpoint-actions.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
4 <script src="resources/breakpoint.js"></script>
5 <script>
6 function test()
7 {
8     InspectorTest.importScript("../../../../inspector-protocol/resources/console-helper.js");
9     InspectorTest.importScript("../../../../inspector-protocol/resources/probe-helper.js");
10
11     InspectorTest.sendCommand("Console.enable", {});
12     InspectorTest.sendCommand("Debugger.enable", {});
13
14     var isExpectingLogs = false;
15     var isExpectingSamples = false;
16     var logCount = 0;
17     var sampleCount = 0;
18     const expectedLogCount = 6;
19     const expectedSampleCount = 2;
20
21     function receivedAllExpectedOutput() {
22         return logCount === expectedLogCount && sampleCount === expectedSampleCount;
23     }
24
25     InspectorTest.eventHandler["Debugger.scriptParsed"] = function(messageObject)
26     {
27         if (/resources\/breakpoint\.js$/.test(messageObject.params.url)) {
28             InspectorTest.log("Found breakpoint.js");
29             var scriptIdentifier = messageObject.params.scriptId;
30             var location = {scriptId: scriptIdentifier, lineNumber: 18, columnNumber: 0};
31             var options = {
32                 condition: "a > 10",
33                 autoContinue: true,
34                 actions: [
35                     {"type": "log", "data": "log-action-before"},
36                     {"type": "sound"},
37                     {"type": "evaluate", "data": "(function() { console.log('eval-action', a, b); })()"},
38                     {"type": "log", "data": "log-action-after"},
39                     {"type": "probe", "data": "a"}
40                 ]
41             };
42
43             InspectorTest.sendCommand("Debugger.setBreakpoint", {location: location, options: options}, function(responseObject) {
44                 InspectorTest.checkForError(responseObject);
45                 breakpointIdentifier = responseObject.result.breakpointId;
46                 InspectorTest.log("Running breakpointActions a few times that should not trigger");
47                 InspectorTest.sendCommand("Runtime.evaluate", {expression: "breakpointActions(1)"});
48                 InspectorTest.sendCommand("Runtime.evaluate", {expression: "breakpointActions(2, 12)"});
49                 InspectorTest.sendCommand("Runtime.evaluate", {expression: "breakpointActions(2, {x:1,y:2})"}, function() {
50                     isExpectingLogs = true;
51                     isExpectingSamples = true;
52                     InspectorTest.log("Running breakpointActions to triggering the breakpoint actions");
53                     InspectorTest.sendCommand("Runtime.evaluate", {expression: "breakpointActions(12, {x:1,y:2})"}, function() {
54                         InspectorTest.sendCommand("Runtime.evaluate", {expression: "breakpointActions(100, document.body)"});
55                     });
56                 });
57             });
58         }
59     }
60
61     InspectorTest.eventHandler["Debugger.paused"] = function(messageObject)
62     {
63         InspectorTest.log("Hit Breakpoint!");
64
65         InspectorTest.log("FAIL: should not have hit breakpoint, autoContinue was true");
66         InspectorTest.completeTest();
67     }
68
69     InspectorTest.eventHandler["Debugger.didSampleProbe"] = function(messageObject)
70     {
71         if (!isExpectingSamples) {
72             InspectorTest.log("FAIL: unexpected probe sample, probe samples should only have come from breakpoint actions.");
73             InspectorTest.completeTest();
74             return;
75         }
76
77         var simplifiedSample = ProbeHelper.simplifiedProbeSample(messageObject);
78         InspectorTest.log("PASS: Probe sample payload: " + JSON.stringify(simplifiedSample.payload));
79
80         ++sampleCount;
81
82         if (receivedAllExpectedOutput())
83             InspectorTest.completeTest();
84     }
85
86     InspectorTest.eventHandler["Console.messageAdded"] = function(messageObject)
87     {
88         if (!isExpectingLogs) {
89             InspectorTest.log("FAIL: unexpected log, logs should only have come from breakpoint actions.");
90             InspectorTest.completeTest();
91             return;
92         }
93
94         var simplifiedMessage = ConsoleHelper.simplifiedConsoleMessage(messageObject);
95         InspectorTest.log("PASS: Console Message: " + JSON.stringify(simplifiedMessage));
96
97         ++logCount;
98
99         if (receivedAllExpectedOutput())
100             InspectorTest.completeTest();
101     }
102 }
103 </script>
104 </head>
105 <body onload="runTest()">
106 <p>Debugger.setBreakpoint options.actions</p>
107 </body>
108 </html>