Web Inspector: Remove recompileAllJSFunctions timer in ScriptDebugServer
[WebKit-https.git] / LayoutTests / inspector-protocol / debugger / didSampleProbe-multiple-probes.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/probe-helper.js");
9
10     InspectorTest.sendCommand("Debugger.enable", {});
11
12     var samples = [];
13     const expectedSampleCount = 2;
14
15     function receivedAllExpectedSamples() {
16         return samples.length === expectedSampleCount;
17     }
18
19     function dumpSamples()
20     {
21         InspectorTest.log("Sample 1: " + JSON.stringify(samples[0]));
22         InspectorTest.log("Sample 2: " + JSON.stringify(samples[1]));
23     }
24
25     var tests = [
26         {
27             message: "Samples from probe actions on the same breakpoint should have unique action identifiers.",
28             predicate: function samplesHaveUniqueActionIds() {
29                 return samples[0].probeId !== samples[1].probeId;
30             },
31             error: dumpSamples
32         },
33         {
34             message: "Samples from probe actions on the same breakpoint should have the same batch identifiers.",
35             predicate: function samplesHaveEqualBatchIds() {
36                 return samples[0].batchId === samples[1].batchId;
37             },
38             error: dumpSamples
39         },
40     ];
41
42     InspectorTest.eventHandler["Debugger.scriptParsed"] = function(messageObject)
43     {
44         if (/resources\/breakpoint\.js$/.test(messageObject.params.url)) {
45             InspectorTest.log("Found breakpoint.js");
46             var scriptIdentifier = messageObject.params.scriptId;
47             var location = {scriptId: scriptIdentifier, lineNumber: 18, columnNumber: 0};
48             var options = {
49                 autoContinue: true,
50                 actions: [
51                     {"type": "probe", "data": "a"},
52                     {"type": "probe", "data": "a"}
53                 ]
54             };
55
56             InspectorTest.sendCommand("Debugger.setBreakpoint", {location: location, options: options}, function(responseObject) {
57                 InspectorTest.checkForError(responseObject);
58                 var actionIdentifiers = responseObject.result.breakpointActionIdentifiers;
59                 InspectorTest.assert(actionIdentifiers instanceof Array && actionIdentifiers.length === 2,
60                                      "Should receive two breakpoint action identifiers on Debugger.setBreakpoint callback.");
61
62                 // FIXME: should we use the Breakpoint/BreakpointAction model objects to manage this?
63                 if (actionIdentifiers.length === 2) {
64                     options.actions[0].identifier = actionIdentifiers[0];
65                     options.actions[1].identifier = actionIdentifiers[1];
66                 }
67                 InspectorTest.log("Running breakpointActions to trigger probe samples.");
68                 InspectorTest.sendCommand("Runtime.evaluate", {expression: "breakpointActions(12, {x:1,y:2})"});
69             });
70         }
71     }
72
73     InspectorTest.eventHandler["Debugger.didSampleProbe"] = function(messageObject)
74     {
75         var sample = ProbeHelper.simplifiedProbeSample(messageObject);
76         samples.push(sample);
77         InspectorTest.log("Received probe sample payload: " + JSON.stringify(sample.payload));
78
79         if (receivedAllExpectedSamples()) {
80             tests.forEach(function(test) {
81                 var result = test.predicate();
82                 InspectorTest.assert(result, test.message);
83                 if (!result)
84                     test.error();
85             });
86             InspectorTest.completeTest();
87         }
88     }
89 }
90 </script>
91 </head>
92 <body onload="runTest()">
93 <p>Debugger.setBreakpoint with multiple probe actions at the same breakpoint. Test Debugger.didSampleProbe events for the probe samples.</p>
94 </body>
95 </html>