| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../http/tests/inspector/resources/inspector-test.js"></script> |
| <script src="./resources/timeline-event-utilities.js"></script> |
| <script> |
| |
| function testSetTimeout() { |
| let setTimeoutIdentifier = setTimeout(() => { |
| TestPage.addResult("FAIL: setTimeout fired"); |
| }, 10); |
| |
| savePageData({setTimeoutIdentifier}); |
| |
| clearTimeout(setTimeoutIdentifier); |
| } |
| |
| function testSetInterval() { |
| let count = 0; |
| |
| let setIntervalIdentifier = setInterval(() => { |
| count++; |
| |
| TestPage.addResult("PASS: setInterval fired: " + count); |
| |
| if (count === 3) |
| clearInterval(setIntervalIdentifier); |
| }, 5); |
| |
| savePageData({setIntervalIdentifier}); |
| } |
| |
| function test() |
| { |
| let suite = InspectorTest.createAsyncSuite("TimelineEvent.TimerRemove"); |
| |
| let timeoutIdentifier = undefined; |
| let intervalIdentifier = undefined; |
| |
| suite.addTestCase({ |
| name: "TimelineEvent.TimerRemove.setTimeout", |
| async test() { |
| let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({ |
| expression: `testSetTimeout()`, |
| eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved, |
| }); |
| |
| InspectorTest.assert(typeof pageRecordingData.setTimeoutIdentifier === "number"); |
| timeoutIdentifier = pageRecordingData.setTimeoutIdentifier; |
| |
| let recording = WI.timelineManager.activeRecording; |
| let scriptTimeline = recording.timelines.get(WI.TimelineRecord.Type.Script); |
| let records = scriptTimeline.records.filter((x) => x.eventType === WI.ScriptTimelineRecord.EventType.TimerRemoved); |
| InspectorTest.expectEqual(records.length, 1, "Should be 1 TimerRemoved record."); |
| for (let record of records) { |
| InspectorTest.log("DETAILS: " + typeof record.details); |
| InspectorTest.expectEqual(record.details, timeoutIdentifier, "ScriptTimelineRecord details should be the setTimeout identifier."); |
| } |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "TimelineEvent.TimerRemove.setInterval", |
| async test() { |
| let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({ |
| expression: `testSetInterval()`, |
| eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved, |
| }); |
| |
| InspectorTest.assert(typeof pageRecordingData.setIntervalIdentifier === "number"); |
| intervalIdentifier = pageRecordingData.setIntervalIdentifier; |
| |
| let recording = WI.timelineManager.activeRecording; |
| let scriptTimeline = recording.timelines.get(WI.TimelineRecord.Type.Script); |
| let records = scriptTimeline.records.filter((x) => x.eventType === WI.ScriptTimelineRecord.EventType.TimerRemoved); |
| InspectorTest.expectEqual(records.length, 1, "Should be 1 TimerRemoved record."); |
| for (let record of records) { |
| InspectorTest.log("DETAILS: " + typeof record.details); |
| InspectorTest.expectEqual(record.details, pageRecordingData.setIntervalIdentifier, "ScriptTimelineRecord details should be the setInterval identifier."); |
| } |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "SanityCheck", |
| async test() { |
| InspectorTest.expectThat(timeoutIdentifier !== intervalIdentifier, "The setTimeout identifier and setInterval identifiers should be different."); |
| } |
| }); |
| |
| suite.runTestCasesAndFinish(); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Tests 'TimerRemove' Timeline event records.</p> |
| </body> |
| </html> |