Do not create a shape object outside of the layout context
[WebKit-https.git] / LayoutTests / inspector / timeline / debugger-paused-while-recording.html
1 <!doctype html>
2 <html>
3 <head>
4 <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'">
5 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
6 <script src="./resources/timeline-helper.js"></script>
7 <script>
8 function installTimer()
9 {
10     setTimeout(function() {
11         callFunction(mul, add(1, 3), 3);
12         hook();
13     });
14 }
15
16 function add(a, b)
17 {
18     TestPage.addResult("Calling add(): " + a + " + " + b);
19     return a + b;
20 }
21
22 function mul(a, b)
23 {
24     TestPage.addResult("Calling mul(): " + a + " * " + b);
25     return a * b;
26 }
27
28 function test()
29 {
30     // First, set up the breakpoint, start timeline capturing, and trigger execution of installTimer().
31     WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ScriptAdded, function(event) {
32         var scriptObject = event.data.script;
33
34         if (!/timeline-helper\.js$/.test(scriptObject.url))
35             return;
36
37         var location = scriptObject.createSourceCodeLocation(17, 0);  // Inside timeline-helper.js:hook()
38         var breakpoint = new WI.Breakpoint(location);
39         WI.debuggerManager.addBreakpoint(breakpoint);
40         InspectorTest.addResult("Added a breakpoint inside hook().")
41
42         WI.timelineManager.startCapturing();
43         InspectorTest.evaluateInPage("installTimer()");
44     });
45
46     // Second, the debugger will pause during timeline capturing. Resume, then stop timeline capturing.
47     WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, function(event) {
48             InspectorTest.addResult("Debugger paused; resuming...");
49
50             WI.debuggerManager.resume().then(function() {
51                 InspectorTest.addResult("Debugger resumed; stopping timeline capture.");
52                 WI.timelineManager.stopCapturing();
53             })
54     });
55
56     // When timeline capturing stops, inspect the resulting timeline records for a profile.
57     WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, (event) => {
58         if (WI.timelineManager.capturingState !== WI.TimelineManager.CapturingState.Inactive)
59             return;
60
61         var recording = WI.timelineManager.activeRecording;
62         var scriptTimeline = recording.timelines.get(WI.TimelineRecord.Type.Script);
63         console.assert(scriptTimeline);
64
65         InspectorTest.addResult("Timeline capturing stopped. Inspecting the active recording....");
66
67         for (var record of scriptTimeline.records) {
68             if (record.eventType !== WI.ScriptTimelineRecord.EventType.TimerFired)
69                 continue;
70
71             var result = record.profile ? "TRUE" : "FALSE";
72             InspectorTest.addResult("TimerFired timeline record has profile attached: " + result);
73         }
74
75         InspectorTest.completeTest();
76     });
77
78     InspectorTest.reloadPage();
79 }
80 </script>
81 </head>
82 <body onload="runTest()">
83     <p>Testing that profiling data is correctly generated and attached to Timeline records when the debugger pauses and resumes while capturing timelines.</p>
84 </body>
85 </html>