Unreviewed, fix test failures after r243119.
[WebKit-https.git] / LayoutTests / inspector / timeline / line-column.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/resources/protocol-test.js"></script>
5 <script>
6
7 function bar(x)
8 {
9     return x * 10;
10 }
11
12 function foo() {
13     bar(42);
14 }
15
16 function load() {
17     document.querySelector("#button").addEventListener("click", (event) => {
18         foo();
19     });
20
21     runTest();
22 }
23
24 function willCallFunctionTest() {
25     console.profile();
26     document.querySelector("#button").click();
27     console.profileEnd();
28 }
29
30 function willEvaluateScriptTest() {
31     console.profile();
32     foo();
33     console.profileEnd();
34 }
35
36 function test() {
37     ProtocolTest.debug();
38
39     InspectorProtocol.sendCommand("Page.enable");
40
41     let suite = ProtocolTest.createAsyncSuite("Timeline.LineColumn");
42
43     function replacer(key, value) {
44         if (key === "startTime" || key === "endTime" || key === "scriptId" || key === "frameId")
45             return "<filtered>";
46         if (key === "url" || key === "scriptName")
47             return value.replace(/^.+LayoutTests\/inspector\//, "");
48         return value;
49     }
50
51     const tests = [
52         {
53             name: "Timeline.LineColumn.willCallFunction",
54             description: "Test that column numbers are passed through the willCallFunction instrumentation point.",
55             expression: `willCallFunctionTest()`,
56         },
57         {
58             name: "Timeline.LineColumn.willEvaluateScript",
59             description: "Test that column numbers are passed through the willEvaluateScript instrumentation point.",
60             expression: `willEvaluateScriptTest()`,
61         },
62     ];
63
64     for (let {name, description, expression} of tests) {
65         suite.addTestCase({
66             name,
67             description,
68             test(resolve, reject) {
69                 let eventNames = [];
70
71                 function handleEvent(eventName, handler) {
72                     eventNames.push(eventName);
73                     InspectorProtocol.eventHandler[eventName] = handler;
74                 }
75
76                 handleEvent("Timeline.eventRecorded", (event) => {
77                     ProtocolTest.log(JSON.stringify(event.params.record, replacer, 2));
78                 });
79
80                 handleEvent("Timeline.programmaticCaptureStarted", () => {
81                     ProtocolTest.pass("Capturing started.");
82                 });
83
84                 handleEvent("Timeline.programmaticCaptureStopped", () => {
85                     ProtocolTest.pass("Capturing stopped.");
86
87                     for (let eventName of eventNames)
88                         delete InspectorProtocol.eventHandler[eventName];
89
90                     resolve();
91                 });
92
93                 ProtocolTest.log("Evaluating in page...");
94                 ProtocolTest.evaluateInPage(expression)
95                 .catch(reject);
96             },
97         });
98     }
99
100     suite.runTestCasesAndFinish();
101 }
102
103 </script>
104 </head>
105 <body onload="load()">
106     <p>Test that script Timeline records have column numbers.</p>
107     <button id="button"></button>
108 </body>
109 </html>