⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243405 in webkit


Ignore:
Timestamp:
Mar 22, 2019, 4:34:29 PM (7 years ago)
Author:
Devin Rousso
Message:

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:
Location:
trunk/LayoutTests
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r243400 r243405  
     12019-03-22  Devin Rousso  <drousso@apple.com>
     2
     3        Unreviewed, fix test failures after r243269.
     4
     5        In debug builds, it's possible that the Web Inspector frontend is told to stop a timeline
     6        recording before all of the recorded records have had a chance to be completed/processed.
     7
     8        As an example
     9        ```
     10            setTimeout(() => {
     11                <stop recording>
     12            });
     13        ```
     14        it may happen that the "stop recording" event will be dispatched before the timeout has
     15        finished executing, meaning that the event that contains the recorded data for that timeout
     16        will be ignored by the frontend.
     17
     18        Rework the tests so that they don't dispatch the "stop recording" event until the expected
     19        record is received by the frontend, rather than having the test code itself say when to stop.
     20
     21        * inspector/timeline/resources/timeline-event-utilities.js:
     22        (savePageData): Added.
     23        (TestPage.registerInitializer.InspectorTest.TimelineEvent.captureTimelineWithScript):
     24        (finishRecording): Deleted.
     25        * inspector/timeline/timeline-event-CancelAnimationFrame.html:
     26        * inspector/timeline/timeline-event-CancelAnimationFrame-expected.txt:
     27        * inspector/timeline/timeline-event-EventDispatch.html:
     28        * inspector/timeline/timeline-event-EventDispatch-expected.txt:
     29        * inspector/timeline/timeline-event-FireAnimationFrame.html:
     30        * inspector/timeline/timeline-event-FireAnimationFrame-expected.txt:
     31        * inspector/timeline/timeline-event-RequestAnimationFrame.html:
     32        * inspector/timeline/timeline-event-RequestAnimationFrame-expected.txt:
     33        * inspector/timeline/timeline-event-TimerFire.html:
     34        * inspector/timeline/timeline-event-TimerFire-expected.txt:
     35        * inspector/timeline/timeline-event-TimerInstall.html:
     36        * inspector/timeline/timeline-event-TimerInstall-expected.txt:
     37        * inspector/timeline/timeline-event-TimerRemove.html:
     38        * inspector/timeline/timeline-event-TimerRemove-expected.txt:
     39
    1402019-03-22  Devin Rousso  <drousso@apple.com>
    241
  • trunk/LayoutTests/inspector/timeline/resources/timeline-event-utilities.js

    r243269 r243405  
    1 function finishRecording(data) {
    2     TestPage.addResult("Finish recording...");
    3     TestPage.dispatchEventToFrontend("FinishRecording", data);
     1function savePageData(data) {
     2    TestPage.dispatchEventToFrontend("SavePageData", data);
    43}
    54
     
    76    InspectorTest.TimelineEvent = {};
    87
    9     InspectorTest.TimelineEvent.captureTimelineWithScript = function(expression) {
     8    InspectorTest.TimelineEvent.captureTimelineWithScript = function({expression, eventType}) {
    109        let pageRecordingData = null;
     10
     11        let promise = new WI.WrappedPromise;
     12
     13        WI.timelineManager.awaitEvent(WI.TimelineManager.Event.CapturingStopped).then((capturingStoppedEvent) => {
     14            InspectorTest.assert(pageRecordingData, "savePageData should have been called in the page before capturing was stopped.");
     15            promise.resolve(pageRecordingData);
     16        });
     17
     18        InspectorTest.awaitEvent("SavePageData").then((event) => {
     19            pageRecordingData = event.data;
     20        });
     21
     22        WI.timelineManager.awaitEvent(WI.TimelineManager.Event.CapturingStarted).then((capturingStartedEvent) => {
     23            let recording = WI.timelineManager.activeRecording;
     24            let scriptTimeline = recording.timelines.get(WI.TimelineRecord.Type.Script);
     25
     26            let recordAddedListener = scriptTimeline.addEventListener(WI.Timeline.Event.RecordAdded, (recordAddedEvent) => {
     27                let {record} = recordAddedEvent.data;
     28                if (record.eventType !== eventType)
     29                    return;
     30
     31                scriptTimeline.removeEventListener(WI.Timeline.Event.RecordAdded, recordAddedListener);
     32
     33                InspectorTest.log("Stopping Capture...");
     34                WI.timelineManager.stopCapturing();
     35            });
     36
     37            InspectorTest.log("Evaluating...");
     38            return InspectorTest.evaluateInPage(expression);
     39        });
    1140
    1241        InspectorTest.log("Starting Capture...");
     
    1443        WI.timelineManager.startCapturing(newRecording);
    1544
    16         let promises = [];
    17 
    18         promises.push(WI.timelineManager.awaitEvent(WI.TimelineManager.Event.CapturingStopped));
    19 
    20         promises.push(InspectorTest.awaitEvent("FinishRecording").then((event) => {
    21             InspectorTest.log("Stopping Capture...");
    22             pageRecordingData = event.data;
    23             WI.timelineManager.stopCapturing();
    24         }));
    25 
    26         InspectorTest.log("Evaluating...");
    27         promises.push(InspectorTest.evaluateInPage(expression));
    28 
    29         return Promise.all(promises).then(() => pageRecordingData);
     45        return promise.promise;
    3046    }
    3147});
  • trunk/LayoutTests/inspector/timeline/timeline-event-CancelAnimationFrame-expected.txt

    r243269 r243405  
    66Starting Capture...
    77Evaluating...
    8 Finish recording...
    98Stopping Capture...
    109PASS: Should be 1 AnimationFrameCanceled record.
  • trunk/LayoutTests/inspector/timeline/timeline-event-CancelAnimationFrame.html

    r243269 r243405  
    1111    });
    1212
     13    savePageData({requestAnimationFrameIdentifier});
     14
    1315    cancelAnimationFrame(requestAnimationFrameIdentifier);
    14 
    15     setTimeout(() => {
    16         finishRecording({requestAnimationFrameIdentifier});
    17     });
    1816}
    1917
     
    2523        name: "TimelineEvent.CancelAnimationFrame.requestAnimationFrame",
    2624        async test() {
    27             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testRequestAnimationFrame()`);
     25            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     26                expression: `testRequestAnimationFrame()`,
     27                eventType: WI.ScriptTimelineRecord.EventType.AnimationFrameCanceled,
     28            });
    2829
    2930            InspectorTest.assert(typeof pageRecordingData.requestAnimationFrameIdentifier === "number");
  • trunk/LayoutTests/inspector/timeline/timeline-event-EventDispatch-expected.txt

    r243269 r243405  
    88Evaluating...
    99PASS: click handler fired
    10 Finish recording...
    1110Stopping Capture...
    1211PASS: Should be 1 EventDispatched record.
     
    1817Evaluating...
    1918PASS: click handler fired, will prevent default
    20 Finish recording...
    2119Stopping Capture...
    2220PASS: Should be 1 EventDispatched record.
     
    2826Evaluating...
    2927PASS: b1 onclick attribute handler fired
    30 Finish recording...
    3128Stopping Capture...
    3229PASS: Should be 1 EventDispatched record.
     
    3835Evaluating...
    3936PASS: b2 onclick attribute handler fired, will prevent default
    40 Finish recording...
    4137Stopping Capture...
    4238PASS: Should be 1 EventDispatched record.
  • trunk/LayoutTests/inspector/timeline/timeline-event-EventDispatch.html

    r243269 r243405  
    77
    88function testClickEventHandler({preventDefault}) {
     9    savePageData({preventDefault});
     10
    911    let button = document.body.appendChild(document.createElement("button"));
    1012    button.addEventListener("click", (event) => {
     
    1315        if (preventDefault)
    1416            event.preventDefault();
    15 
    16         setTimeout(() => {
    17             finishRecording({preventDefault});
    18         });
    19     });
     17    }, {once: true});
    2018    button.dispatchEvent(new MouseEvent("click", {bubbles: true, cancelable: true}));
    2119}
    2220
    2321function testClickEventAttributeHandler(id, {preventDefault}) {
     22    savePageData({preventDefault});
     23
    2424    let button = document.getElementById(id);
    2525    button.dispatchEvent(new MouseEvent("click", {bubbles: true, cancelable: true}));
    26 
    27     setTimeout(() => {
    28         finishRecording({preventDefault});
    29     });
    3026}
    3127
     
    3733        name: "TimelineEvent.EventDispatch.Handler.Regular",
    3834        async test() {
    39             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testClickEventHandler({preventDefault: false})`);
     35            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     36                expression: `testClickEventHandler({preventDefault: false})`,
     37                eventType: WI.ScriptTimelineRecord.EventType.EventDispatched,
     38            });
    4039
    4140            InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
     
    5554        name: "TimelineEvent.EventDispatch.Handler.DefaultPrevented",
    5655        async test() {
    57             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testClickEventHandler({preventDefault: true})`);
     56            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     57                expression: `testClickEventHandler({preventDefault: true})`,
     58                eventType: WI.ScriptTimelineRecord.EventType.EventDispatched,
     59            });
    5860
    5961            InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
     
    7375        name: "TimelineEvent.EventDispatch.AttributeHandler.Regular",
    7476        async test() {
    75             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testClickEventAttributeHandler("b1", {preventDefault: false})`);
     77            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     78                expression: `testClickEventAttributeHandler("b1", {preventDefault: false})`,
     79                eventType: WI.ScriptTimelineRecord.EventType.EventDispatched,
     80            });
    7681
    7782            InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
     
    9196        name: "TimelineEvent.EventDispatch.AttributeHandler.DefaultPrevented",
    9297        async test() {
    93             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testClickEventAttributeHandler("b2", {preventDefault: true})`);
     98            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     99                expression: `testClickEventAttributeHandler("b2", {preventDefault: true})`,
     100                eventType: WI.ScriptTimelineRecord.EventType.EventDispatched,
     101            });
    94102
    95103            InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
  • trunk/LayoutTests/inspector/timeline/timeline-event-FireAnimationFrame-expected.txt

    r243269 r243405  
    77Evaluating...
    88PASS: requestAnimationFrame fired
    9 Finish recording...
    109Stopping Capture...
    1110PASS: Should be 1 AnimationFrameFired record.
  • trunk/LayoutTests/inspector/timeline/timeline-event-FireAnimationFrame.html

    r243269 r243405  
    99    let requestAnimationFrameIdentifier = requestAnimationFrame(() => {
    1010        TestPage.addResult("PASS: requestAnimationFrame fired");
     11    });
    1112
    12         setTimeout(() => {
    13             finishRecording({requestAnimationFrameIdentifier});
    14         });
    15     });
     13    savePageData({requestAnimationFrameIdentifier});
    1614}
    1715
     
    2321        name: "TimelineEvent.FireAnimationFrame.requestAnimationFrame",
    2422        async test() {
    25             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testRequestAnimationFrame()`);
     23            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     24                expression: `testRequestAnimationFrame()`,
     25                eventType: WI.ScriptTimelineRecord.EventType.AnimationFrameFired,
     26            });
    2627
    2728            InspectorTest.assert(typeof pageRecordingData.requestAnimationFrameIdentifier === "number");
  • trunk/LayoutTests/inspector/timeline/timeline-event-RequestAnimationFrame-expected.txt

    r243269 r243405  
    77Evaluating...
    88PASS: requestAnimationFrame fired
    9 Finish recording...
    109Stopping Capture...
    1110PASS: Should be 1 AnimationFrameRequested record.
  • trunk/LayoutTests/inspector/timeline/timeline-event-RequestAnimationFrame.html

    r243269 r243405  
    99    let requestAnimationFrameIdentifier = requestAnimationFrame(() => {
    1010        TestPage.addResult("PASS: requestAnimationFrame fired");
     11    });
    1112
    12         setTimeout(() => {
    13             finishRecording({requestAnimationFrameIdentifier});
    14         });
    15     });
     13    savePageData({requestAnimationFrameIdentifier});
    1614}
    1715
     
    2321        name: "TimelineEvent.RequestAnimationFrame.requestAnimationFrame",
    2422        async test() {
    25             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testRequestAnimationFrame()`);
     23            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     24                expression: `testRequestAnimationFrame()`,
     25                eventType: WI.ScriptTimelineRecord.EventType.AnimationFrameFired,
     26            });
    2627
    2728            InspectorTest.assert(typeof pageRecordingData.requestAnimationFrameIdentifier === "number");
  • trunk/LayoutTests/inspector/timeline/timeline-event-TimerFire-expected.txt

    r243269 r243405  
    77Evaluating...
    88PASS: setTimeout fired
    9 Finish recording...
    109Stopping Capture...
    1110PASS: Should be 1 TimerFired record.
     
    1918PASS: setInterval fired: 2
    2019PASS: setInterval fired: 3
    21 Finish recording...
    2220Stopping Capture...
    2321PASS: Should be 3 TimerFired records.
  • trunk/LayoutTests/inspector/timeline/timeline-event-TimerFire.html

    r243269 r243405  
    99    let setTimeoutIdentifier = setTimeout(() => {
    1010        TestPage.addResult("PASS: setTimeout fired");
     11    }, 10);
    1112
    12         requestAnimationFrame(() => {
    13             finishRecording({setTimeoutIdentifier});
    14         });
    15     });
     13    savePageData({setTimeoutIdentifier});
    1614}
    1715
     
    2422        TestPage.addResult("PASS: setInterval fired: " + count);
    2523
    26         if (count === 3) {
     24        if (count === 3)
    2725            clearInterval(setIntervalIdentifier);
     26    }, 5);
    2827
    29             requestAnimationFrame(() => {
    30                 finishRecording({setIntervalIdentifier});
    31             });
    32         }
    33     });
     28    savePageData({setIntervalIdentifier});
    3429}
    3530
     
    4439        name: "TimelineEvent.TimerFire.setTimeout",
    4540        async test() {
    46             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetTimeout()`);
     41            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     42                expression: `testSetTimeout()`,
     43                eventType: WI.ScriptTimelineRecord.EventType.TimerFired,
     44            });
    4745
    4846            InspectorTest.assert(typeof pageRecordingData.setTimeoutIdentifier === "number");
     
    6361        name: "TimelineEvent.TimerFire.setInterval",
    6462        async test() {
    65             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetInterval()`);
     63            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     64                expression: `testSetInterval()`,
     65                eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved,
     66            });
    6667
    6768            InspectorTest.assert(typeof pageRecordingData.setIntervalIdentifier === "number");
  • trunk/LayoutTests/inspector/timeline/timeline-event-TimerInstall-expected.txt

    r243269 r243405  
    77Evaluating...
    88PASS: setTimeout fired
    9 Finish recording...
    109Stopping Capture...
    1110PASS: Should be 1 TimerInstalled record.
     
    1918PASS: setInterval fired: 2
    2019PASS: setInterval fired: 3
    21 Finish recording...
    2220Stopping Capture...
    2321PASS: Should be 1 TimerInstalled record.
  • trunk/LayoutTests/inspector/timeline/timeline-event-TimerInstall.html

    r243269 r243405  
    99    let setTimeoutIdentifier = setTimeout(() => {
    1010        TestPage.addResult("PASS: setTimeout fired");
     11    }, 10);
    1112
    12         requestAnimationFrame(() => {
    13             finishRecording({setTimeoutIdentifier});
    14         });
    15     }, 10);
     13    savePageData({setTimeoutIdentifier});
    1614}
    1715
     
    2422        TestPage.addResult("PASS: setInterval fired: " + count);
    2523
    26         if (count === 3) {
     24        if (count === 3)
    2725            clearInterval(setIntervalIdentifier);
     26    }, 5);
    2827
    29             requestAnimationFrame(() => {
    30                 finishRecording({setIntervalIdentifier});
    31             });
    32         }
    33     }, 5);
     28    savePageData({setIntervalIdentifier});
    3429}
    3530
     
    5045        name: "TimelineEvent.TimerInstall.setTimeout",
    5146        async test() {
    52             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetTimeout()`);
     47            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     48                expression: `testSetTimeout()`,
     49                eventType: WI.ScriptTimelineRecord.EventType.TimerFired,
     50            });
    5351
    5452            InspectorTest.assert(typeof pageRecordingData.setTimeoutIdentifier === "number");
     
    6967        name: "TimelineEvent.TimerInstall.setInterval",
    7068        async test() {
    71             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetInterval()`);
     69            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     70                expression: `testSetInterval()`,
     71                eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved,
     72            });
    7273
    7374            InspectorTest.assert(typeof pageRecordingData.setIntervalIdentifier === "number");
  • trunk/LayoutTests/inspector/timeline/timeline-event-TimerRemove-expected.txt

    r243269 r243405  
    66Starting Capture...
    77Evaluating...
    8 Finish recording...
    98Stopping Capture...
    109PASS: Should be 1 TimerRemoved record.
     
    1817PASS: setInterval fired: 2
    1918PASS: setInterval fired: 3
    20 Finish recording...
    2119Stopping Capture...
    2220PASS: Should be 1 TimerRemoved record.
  • trunk/LayoutTests/inspector/timeline/timeline-event-TimerRemove.html

    r243269 r243405  
    99    let setTimeoutIdentifier = setTimeout(() => {
    1010        TestPage.addResult("FAIL: setTimeout fired");
    11     });
     11    }, 10);
     12
     13    savePageData({setTimeoutIdentifier});
    1214
    1315    clearTimeout(setTimeoutIdentifier);
    14 
    15     requestAnimationFrame(() => {
    16         finishRecording({setTimeoutIdentifier});
    17     });
    1816}
    1917
     
    2624        TestPage.addResult("PASS: setInterval fired: " + count);
    2725
    28         if (count === 3) {
     26        if (count === 3)
    2927            clearInterval(setIntervalIdentifier);
     28    }, 5);
    3029
    31             requestAnimationFrame(() => {
    32                 finishRecording({setIntervalIdentifier});
    33             });
    34         }
    35     });
     30    savePageData({setIntervalIdentifier});
    3631}
    3732
     
    4641        name: "TimelineEvent.TimerRemove.setTimeout",
    4742        async test() {
    48             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetTimeout()`);
     43            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     44                expression: `testSetTimeout()`,
     45                eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved,
     46            });
    4947
    5048            InspectorTest.assert(typeof pageRecordingData.setTimeoutIdentifier === "number");
     
    6563        name: "TimelineEvent.TimerRemove.setInterval",
    6664        async test() {
    67             let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript(`testSetInterval()`);
     65            let pageRecordingData = await InspectorTest.TimelineEvent.captureTimelineWithScript({
     66                expression: `testSetInterval()`,
     67                eventType: WI.ScriptTimelineRecord.EventType.TimerRemoved,
     68            });
    6869
    6970            InspectorTest.assert(typeof pageRecordingData.setIntervalIdentifier === "number");
Note: See TracChangeset for help on using the changeset viewer.