Unreviewed, fix test failures after r243269.
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2019 23:34:29 +0000 (23:34 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2019 23:34:29 +0000 (23:34 +0000)
In debug builds, it's possible that the Web Inspector frontend is told to stop a timeline
recording before all of the recorded records have had a chance to be completed/processed.

As an example
```
    setTimeout(() => {
        <stop recording>
    });
```
it may happen that the "stop recording" event will be dispatched before the timeout has
finished executing, meaning that the event that contains the recorded data for that timeout
will be ignored by the frontend.

Rework the tests so that they don't dispatch the "stop recording" event until the expected
record is received by the frontend, rather than having the test code itself say when to stop.

* inspector/timeline/resources/timeline-event-utilities.js:
(savePageData): Added.
(TestPage.registerInitializer.InspectorTest.TimelineEvent.captureTimelineWithScript):
(finishRecording): Deleted.
* inspector/timeline/timeline-event-CancelAnimationFrame.html:
* inspector/timeline/timeline-event-CancelAnimationFrame-expected.txt:
* inspector/timeline/timeline-event-EventDispatch.html:
* inspector/timeline/timeline-event-EventDispatch-expected.txt:
* inspector/timeline/timeline-event-FireAnimationFrame.html:
* inspector/timeline/timeline-event-FireAnimationFrame-expected.txt:
* inspector/timeline/timeline-event-RequestAnimationFrame.html:
* inspector/timeline/timeline-event-RequestAnimationFrame-expected.txt:
* inspector/timeline/timeline-event-TimerFire.html:
* inspector/timeline/timeline-event-TimerFire-expected.txt:
* inspector/timeline/timeline-event-TimerInstall.html:
* inspector/timeline/timeline-event-TimerInstall-expected.txt:
* inspector/timeline/timeline-event-TimerRemove.html:
* inspector/timeline/timeline-event-TimerRemove-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243405 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/timeline/resources/timeline-event-utilities.js
LayoutTests/inspector/timeline/timeline-event-CancelAnimationFrame-expected.txt
LayoutTests/inspector/timeline/timeline-event-CancelAnimationFrame.html
LayoutTests/inspector/timeline/timeline-event-EventDispatch-expected.txt
LayoutTests/inspector/timeline/timeline-event-EventDispatch.html
LayoutTests/inspector/timeline/timeline-event-FireAnimationFrame-expected.txt
LayoutTests/inspector/timeline/timeline-event-FireAnimationFrame.html
LayoutTests/inspector/timeline/timeline-event-RequestAnimationFrame-expected.txt
LayoutTests/inspector/timeline/timeline-event-RequestAnimationFrame.html
LayoutTests/inspector/timeline/timeline-event-TimerFire-expected.txt
LayoutTests/inspector/timeline/timeline-event-TimerFire.html
LayoutTests/inspector/timeline/timeline-event-TimerInstall-expected.txt
LayoutTests/inspector/timeline/timeline-event-TimerInstall.html
LayoutTests/inspector/timeline/timeline-event-TimerRemove-expected.txt
LayoutTests/inspector/timeline/timeline-event-TimerRemove.html

index b7a6ed4..90729d7 100644 (file)
@@ -1,5 +1,44 @@
 2019-03-22  Devin Rousso  <drousso@apple.com>
 
+        Unreviewed, fix test failures after r243269.
+
+        In debug builds, it's possible that the Web Inspector frontend is told to stop a timeline
+        recording before all of the recorded records have had a chance to be completed/processed.
+
+        As an example
+        ```
+            setTimeout(() => {
+                <stop recording>
+            });
+        ```
+        it may happen that the "stop recording" event will be dispatched before the timeout has
+        finished executing, meaning that the event that contains the recorded data for that timeout
+        will be ignored by the frontend.
+
+        Rework the tests so that they don't dispatch the "stop recording" event until the expected
+        record is received by the frontend, rather than having the test code itself say when to stop.
+
+        * inspector/timeline/resources/timeline-event-utilities.js:
+        (savePageData): Added.
+        (TestPage.registerInitializer.InspectorTest.TimelineEvent.captureTimelineWithScript):
+        (finishRecording): Deleted.
+        * inspector/timeline/timeline-event-CancelAnimationFrame.html:
+        * inspector/timeline/timeline-event-CancelAnimationFrame-expected.txt:
+        * inspector/timeline/timeline-event-EventDispatch.html:
+        * inspector/timeline/timeline-event-EventDispatch-expected.txt:
+        * inspector/timeline/timeline-event-FireAnimationFrame.html:
+        * inspector/timeline/timeline-event-FireAnimationFrame-expected.txt:
+        * inspector/timeline/timeline-event-RequestAnimationFrame.html:
+        * inspector/timeline/timeline-event-RequestAnimationFrame-expected.txt:
+        * inspector/timeline/timeline-event-TimerFire.html:
+        * inspector/timeline/timeline-event-TimerFire-expected.txt:
+        * inspector/timeline/timeline-event-TimerInstall.html:
+        * inspector/timeline/timeline-event-TimerInstall-expected.txt:
+        * inspector/timeline/timeline-event-TimerRemove.html:
+        * inspector/timeline/timeline-event-TimerRemove-expected.txt:
+
+2019-03-22  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Safari Canvas Inspector seems to show the canvas being rendered twice per frame.
         https://bugs.webkit.org/show_bug.cgi?id=196082
         <rdar://problem/49113496>
index 8e2e103..b0e4127 100644 (file)
@@ -1,31 +1,47 @@
-function finishRecording(data) {
-    TestPage.addResult("Finish recording...");
-    TestPage.dispatchEventToFrontend("FinishRecording", data);
+function savePageData(data) {
+    TestPage.dispatchEventToFrontend("SavePageData", data);
 }
 
 TestPage.registerInitializer(() => {
     InspectorTest.TimelineEvent = {};
 
-    InspectorTest.TimelineEvent.captureTimelineWithScript = function(expression) {
+    InspectorTest.TimelineEvent.captureTimelineWithScript = function({expression, eventType}) {
         let pageRecordingData = null;
 
-        InspectorTest.log("Starting Capture...");
-        const newRecording = true;
-        WI.timelineManager.startCapturing(newRecording);
+        let promise = new WI.WrappedPromise;
 
-        let promises = [];
+        WI.timelineManager.awaitEvent(WI.TimelineManager.Event.CapturingStopped).then((capturingStoppedEvent) => {
+            InspectorTest.assert(pageRecordingData, "savePageData should have been called in the page before capturing was stopped.");
+            promise.resolve(pageRecordingData);
+        });
 
-        promises.push(WI.timelineManager.awaitEvent(WI.TimelineManager.Event.CapturingStopped));
-
-        promises.push(InspectorTest.awaitEvent("FinishRecording").then((event) => {
-            InspectorTest.log("Stopping Capture...");
+        InspectorTest.awaitEvent("SavePageData").then((event) => {
             pageRecordingData = event.data;
-            WI.timelineManager.stopCapturing();
-        }));
+        });
+
+        WI.timelineManager.awaitEvent(WI.TimelineManager.Event.CapturingStarted).then((capturingStartedEvent) => {
+            let recording = WI.timelineManager.activeRecording;
+            let scriptTimeline = recording.timelines.get(WI.TimelineRecord.Type.Script);
+
+            let recordAddedListener = scriptTimeline.addEventListener(WI.Timeline.Event.RecordAdded, (recordAddedEvent) => {
+                let {record} = recordAddedEvent.data;
+                if (record.eventType !== eventType)
+                    return;
 
-        InspectorTest.log("Evaluating...");
-        promises.push(InspectorTest.evaluateInPage(expression));
+                scriptTimeline.removeEventListener(WI.Timeline.Event.RecordAdded, recordAddedListener);
+
+                InspectorTest.log("Stopping Capture...");
+                WI.timelineManager.stopCapturing();
+            });
+
+            InspectorTest.log("Evaluating...");
+            return InspectorTest.evaluateInPage(expression);
+        });
+
+        InspectorTest.log("Starting Capture...");
+        const newRecording = true;
+        WI.timelineManager.startCapturing(newRecording);
 
-        return Promise.all(promises).then(() => pageRecordingData);
+        return promise.promise;
     }
 });
index 808240b..a18edda 100644 (file)
@@ -5,7 +5,6 @@ Tests 'CancelAnimationFrame' Timeline event records.
 -- Running test case: TimelineEvent.CancelAnimationFrame.requestAnimationFrame
 Starting Capture...
 Evaluating...
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 AnimationFrameCanceled record.
 DETAILS: number
index c475af3..57c60a7 100644 (file)
@@ -10,11 +10,9 @@ function testRequestAnimationFrame() {
         TestPage.addResult("FAIL: requestAnimationFrame fired");
     });
 
-    cancelAnimationFrame(requestAnimationFrameIdentifier);
+    savePageData({requestAnimationFrameIdentifier});
 
-    setTimeout(() => {
-        finishRecording({requestAnimationFrameIdentifier});
-    });
+    cancelAnimationFrame(requestAnimationFrameIdentifier);
 }
 
 function test()
@@ -24,7 +22,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.CancelAnimationFrame.requestAnimationFrame",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testRequestAnimationFrame()`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testRequestAnimationFrame()`,
+                eventType: WI.ScriptTimelineRecord.EventType.AnimationFrameCanceled,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.requestAnimationFrameIdentifier === "number");
 
index 218bb02..5115ee3 100644 (file)
@@ -7,7 +7,6 @@ Tests 'EventDispatch' Timeline event records.
 Starting Capture...
 Evaluating...
 PASS: click handler fired
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 EventDispatched record.
 DETAILS: {"type":"click","defaultPrevented":false}
@@ -17,7 +16,6 @@ PASS: ScriptTimelineRecord extraDetails should show default was not prevented.
 Starting Capture...
 Evaluating...
 PASS: click handler fired, will prevent default
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 EventDispatched record.
 DETAILS: {"type":"click","defaultPrevented":true}
@@ -27,7 +25,6 @@ PASS: ScriptTimelineRecord extraDetails should show default was prevented.
 Starting Capture...
 Evaluating...
 PASS: b1 onclick attribute handler fired
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 EventDispatched record.
 DETAILS: {"type":"click","defaultPrevented":false}
@@ -37,7 +34,6 @@ PASS: ScriptTimelineRecord extraDetails should show default was not prevented.
 Starting Capture...
 Evaluating...
 PASS: b2 onclick attribute handler fired, will prevent default
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 EventDispatched record.
 DETAILS: {"type":"click","defaultPrevented":true}
index a2a3a7c..08c5d79 100644 (file)
@@ -6,27 +6,23 @@
 <script>
 
 function testClickEventHandler({preventDefault}) {
+    savePageData({preventDefault});
+
     let button = document.body.appendChild(document.createElement("button"));
     button.addEventListener("click", (event) => {
         TestPage.addResult("PASS: click handler fired" + (preventDefault ? ", will prevent default" : ""));
 
         if (preventDefault)
             event.preventDefault();
-
-        setTimeout(() => {
-            finishRecording({preventDefault});
-        });
-    });
+    }, {once: true});
     button.dispatchEvent(new MouseEvent("click", {bubbles: true, cancelable: true}));
 }
 
 function testClickEventAttributeHandler(id, {preventDefault}) {
+    savePageData({preventDefault});
+
     let button = document.getElementById(id);
     button.dispatchEvent(new MouseEvent("click", {bubbles: true, cancelable: true}));
-
-    setTimeout(() => {
-        finishRecording({preventDefault});
-    });
 }
 
 function test()
@@ -36,7 +32,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.EventDispatch.Handler.Regular",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testClickEventHandler({preventDefault: false})`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testClickEventHandler({preventDefault: false})`,
+                eventType: WI.ScriptTimelineRecord.EventType.EventDispatched,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
 
@@ -54,7 +53,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.EventDispatch.Handler.DefaultPrevented",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testClickEventHandler({preventDefault: true})`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testClickEventHandler({preventDefault: true})`,
+                eventType: WI.ScriptTimelineRecord.EventType.EventDispatched,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
 
@@ -72,7 +74,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.EventDispatch.AttributeHandler.Regular",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testClickEventAttributeHandler("b1", {preventDefault: false})`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testClickEventAttributeHandler("b1", {preventDefault: false})`,
+                eventType: WI.ScriptTimelineRecord.EventType.EventDispatched,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
 
@@ -90,7 +95,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.EventDispatch.AttributeHandler.DefaultPrevented",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testClickEventAttributeHandler("b2", {preventDefault: true})`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testClickEventAttributeHandler("b2", {preventDefault: true})`,
+                eventType: WI.ScriptTimelineRecord.EventType.EventDispatched,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
 
index 41995da..c196504 100644 (file)
@@ -6,7 +6,6 @@ Tests 'FireAnimationFrame' Timeline event records.
 Starting Capture...
 Evaluating...
 PASS: requestAnimationFrame fired
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 AnimationFrameFired record.
 DETAILS: number
index a7a8fe3..dfba6ff 100644 (file)
@@ -8,11 +8,9 @@
 function testRequestAnimationFrame() {
     let requestAnimationFrameIdentifier = requestAnimationFrame(() => {
         TestPage.addResult("PASS: requestAnimationFrame fired");
-
-        setTimeout(() => {
-            finishRecording({requestAnimationFrameIdentifier});
-        });
     });
+
+    savePageData({requestAnimationFrameIdentifier});
 }
 
 function test()
@@ -22,7 +20,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.FireAnimationFrame.requestAnimationFrame",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testRequestAnimationFrame()`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testRequestAnimationFrame()`,
+                eventType: WI.ScriptTimelineRecord.EventType.AnimationFrameFired,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.requestAnimationFrameIdentifier === "number");
 
index 04713ad..c41c82c 100644 (file)
@@ -6,7 +6,6 @@ Tests 'RequestAnimationFrame' Timeline event records.
 Starting Capture...
 Evaluating...
 PASS: requestAnimationFrame fired
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 AnimationFrameRequested record.
 DETAILS: number
index 7b44f40..6fdf17b 100644 (file)
@@ -8,11 +8,9 @@
 function testRequestAnimationFrame() {
     let requestAnimationFrameIdentifier = requestAnimationFrame(() => {
         TestPage.addResult("PASS: requestAnimationFrame fired");
-
-        setTimeout(() => {
-            finishRecording({requestAnimationFrameIdentifier});
-        });
     });
+
+    savePageData({requestAnimationFrameIdentifier});
 }
 
 function test()
@@ -22,7 +20,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.RequestAnimationFrame.requestAnimationFrame",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testRequestAnimationFrame()`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testRequestAnimationFrame()`,
+                eventType: WI.ScriptTimelineRecord.EventType.AnimationFrameFired,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.requestAnimationFrameIdentifier === "number");
 
index ee3451b..c02655c 100644 (file)
@@ -6,7 +6,6 @@ Tests 'TimerFire' Timeline event records.
 Starting Capture...
 Evaluating...
 PASS: setTimeout fired
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 TimerFired record.
 DETAILS: number
@@ -18,7 +17,6 @@ Evaluating...
 PASS: setInterval fired: 1
 PASS: setInterval fired: 2
 PASS: setInterval fired: 3
-Finish recording...
 Stopping Capture...
 PASS: Should be 3 TimerFired records.
 DETAILS: number
index 075f0a1..cc3507c 100644 (file)
@@ -8,11 +8,9 @@
 function testSetTimeout() {
     let setTimeoutIdentifier = setTimeout(() => {
         TestPage.addResult("PASS: setTimeout fired");
+    }, 10);
 
-        requestAnimationFrame(() => {
-            finishRecording({setTimeoutIdentifier});
-        });
-    });
+    savePageData({setTimeoutIdentifier});
 }
 
 function testSetInterval() {
@@ -23,14 +21,11 @@ function testSetInterval() {
 
         TestPage.addResult("PASS: setInterval fired: " + count);
 
-        if (count === 3) {
+        if (count === 3)
             clearInterval(setIntervalIdentifier);
+    }, 5);
 
-            requestAnimationFrame(() => {
-                finishRecording({setIntervalIdentifier});
-            });
-        }
-    });
+    savePageData({setIntervalIdentifier});
 }
 
 function test()
@@ -43,7 +38,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.TimerFire.setTimeout",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetTimeout()`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testSetTimeout()`,
+                eventType: WI.ScriptTimelineRecord.EventType.TimerFired,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.setTimeoutIdentifier === "number");
             timeoutIdentifier = pageRecordingData.setTimeoutIdentifier;
@@ -62,7 +60,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.TimerFire.setInterval",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetInterval()`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testSetInterval()`,
+                eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.setIntervalIdentifier === "number");
             intervalIdentifier = pageRecordingData.setIntervalIdentifier;
index c039ee5..780c02b 100644 (file)
@@ -6,7 +6,6 @@ Tests 'TimerInstall' Timeline event records.
 Starting Capture...
 Evaluating...
 PASS: setTimeout fired
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 TimerInstalled record.
 DETAILS: {"timerId":"<filtered>","timeout":10,"repeating":false}
@@ -18,7 +17,6 @@ Evaluating...
 PASS: setInterval fired: 1
 PASS: setInterval fired: 2
 PASS: setInterval fired: 3
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 TimerInstalled record.
 DETAILS: {"timerId":"<filtered>","timeout":5,"repeating":true}
index e0694df..3fc6f33 100644 (file)
@@ -8,11 +8,9 @@
 function testSetTimeout() {
     let setTimeoutIdentifier = setTimeout(() => {
         TestPage.addResult("PASS: setTimeout fired");
-
-        requestAnimationFrame(() => {
-            finishRecording({setTimeoutIdentifier});
-        });
     }, 10);
+
+    savePageData({setTimeoutIdentifier});
 }
 
 function testSetInterval() {
@@ -23,14 +21,11 @@ function testSetInterval() {
 
         TestPage.addResult("PASS: setInterval fired: " + count);
 
-        if (count === 3) {
+        if (count === 3)
             clearInterval(setIntervalIdentifier);
-
-            requestAnimationFrame(() => {
-                finishRecording({setIntervalIdentifier});
-            });
-        }
     }, 5);
+
+    savePageData({setIntervalIdentifier});
 }
 
 function test()
@@ -49,7 +44,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.TimerInstall.setTimeout",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetTimeout()`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testSetTimeout()`,
+                eventType: WI.ScriptTimelineRecord.EventType.TimerFired,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.setTimeoutIdentifier === "number");
             timeoutIdentifier = pageRecordingData.setTimeoutIdentifier;
@@ -68,7 +66,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.TimerInstall.setInterval",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetInterval()`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testSetInterval()`,
+                eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.setIntervalIdentifier === "number");
             intervalIdentifier = pageRecordingData.setIntervalIdentifier;
index 64fb973..9ae338f 100644 (file)
@@ -5,7 +5,6 @@ Tests 'TimerRemove' Timeline event records.
 -- Running test case: TimelineEvent.TimerRemove.setTimeout
 Starting Capture...
 Evaluating...
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 TimerRemoved record.
 DETAILS: number
@@ -17,7 +16,6 @@ Evaluating...
 PASS: setInterval fired: 1
 PASS: setInterval fired: 2
 PASS: setInterval fired: 3
-Finish recording...
 Stopping Capture...
 PASS: Should be 1 TimerRemoved record.
 DETAILS: number
index 6c765fd..cb6f93d 100644 (file)
@@ -8,13 +8,11 @@
 function testSetTimeout() {
     let setTimeoutIdentifier = setTimeout(() => {
         TestPage.addResult("FAIL: setTimeout fired");
-    });
+    }, 10);
 
-    clearTimeout(setTimeoutIdentifier);
+    savePageData({setTimeoutIdentifier});
 
-    requestAnimationFrame(() => {
-        finishRecording({setTimeoutIdentifier});
-    });
+    clearTimeout(setTimeoutIdentifier);
 }
 
 function testSetInterval() {
@@ -25,14 +23,11 @@ function testSetInterval() {
 
         TestPage.addResult("PASS: setInterval fired: " + count);
 
-        if (count === 3) {
+        if (count === 3)
             clearInterval(setIntervalIdentifier);
+    }, 5);
 
-            requestAnimationFrame(() => {
-                finishRecording({setIntervalIdentifier});
-            });
-        }
-    });
+    savePageData({setIntervalIdentifier});
 }
 
 function test()
@@ -45,7 +40,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.TimerRemove.setTimeout",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetTimeout()`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testSetTimeout()`,
+                eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.setTimeoutIdentifier === "number");
             timeoutIdentifier = pageRecordingData.setTimeoutIdentifier;
@@ -64,7 +62,10 @@ function test()
     suite.addTestCase({
         name: "TimelineEvent.TimerRemove.setInterval",
         async test() {
-            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetInterval()`);
+            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
+                expression: `testSetInterval()`,
+                eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved,
+            });
 
             InspectorTest.assert(typeof pageRecordingData.setIntervalIdentifier === "number");
             intervalIdentifier = pageRecordingData.setIntervalIdentifier;