Title: [238874] trunk
Revision
238874
Author
you...@apple.com
Date
2018-12-04 13:40:44 -0800 (Tue, 04 Dec 2018)

Log Message

Fix MediaRecorder flaky tests
https://bugs.webkit.org/show_bug.cgi?id=192371

Reviewed by Eric Carlson.

Source/WebCore:

No change of behavior.

* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
Reset to use real MediaRecorder by default.

LayoutTests:

Updated tests to make them less flaky and more debuggable.

* http/wpt/mediarecorder/MediaRecorder-AV-audio-only-dataavailable.html:
* http/wpt/mediarecorder/MediaRecorder-AV-audio-video-dataavailable.html:
* http/wpt/mediarecorder/MediaRecorder-AV-video-only-dataavailable.html:
* platform/gtk/TestExpectations:
* platform/wpe/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (238873 => 238874)


--- trunk/LayoutTests/ChangeLog	2018-12-04 20:57:56 UTC (rev 238873)
+++ trunk/LayoutTests/ChangeLog	2018-12-04 21:40:44 UTC (rev 238874)
@@ -1,3 +1,18 @@
+2018-12-04  Youenn Fablet  <you...@apple.com>
+
+        Fix MediaRecorder flaky tests
+        https://bugs.webkit.org/show_bug.cgi?id=192371
+
+        Reviewed by Eric Carlson.
+
+        Updated tests to make them less flaky and more debuggable.
+
+        * http/wpt/mediarecorder/MediaRecorder-AV-audio-only-dataavailable.html:
+        * http/wpt/mediarecorder/MediaRecorder-AV-audio-video-dataavailable.html:
+        * http/wpt/mediarecorder/MediaRecorder-AV-video-only-dataavailable.html:
+        * platform/gtk/TestExpectations:
+        * platform/wpe/TestExpectations:
+
 2018-12-04  Justin Michaud  <justin_mich...@apple.com>
 
         CSS Painting API should allow image values in inputProperties

Modified: trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-AV-audio-only-dataavailable.html (238873 => 238874)


--- trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-AV-audio-only-dataavailable.html	2018-12-04 20:57:56 UTC (rev 238873)
+++ trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-AV-audio-only-dataavailable.html	2018-12-04 21:40:44 UTC (rev 238874)
@@ -1,7 +1,7 @@
 <!doctype html>
 <html>
 <head>
-    <title>MediaRecorder Dataavailable</title>
+    <title>MediaRecorder can successfully record the audio for a audio-only stream</title>
     <link rel="help" href=""
     <script src=""
     <script src=""
@@ -11,37 +11,35 @@
 </audio>
 <script>
 
-    async_test(t => {
-        const ac = new AudioContext();
-        const osc = ac.createOscillator();
-        const dest = ac.createMediaStreamDestination();
-        const audio = dest.stream;
-        osc.connect(dest);
-        const recorder = new MediaRecorder(audio);
-        recorder._ondataavailable_ = t.step_func(blobEvent => {
-            assert_true(blobEvent instanceof BlobEvent, 'the type of event should be BlobEvent');
-            assert_equals(blobEvent.type, 'dataavailable', 'the event type should be dataavailable');
-            assert_true(blobEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
-            assert_true(blobEvent.data instanceof Blob, 'the type of data should be Blob');
-            assert_true(blobEvent.data.size > 0, 'the blob should contain some buffers');
-            const player = document.getElementById("player");
-            player.src = ""
-            player._oncanplay_ = () => {
-                assert_greater_than(player.duration, 0, 'the duration should be greater than 0');
-                t.done();
-            };
-            player.load();
-        });
+    const ac = new webkitAudioContext();
+    const osc = ac.createOscillator();
+    const dest = ac.createMediaStreamDestination();
+    const audio = dest.stream;
+    osc.connect(dest);
+    const recorder = new MediaRecorder(audio);
+    recorder._ondataavailable_ = (blobEvent) => {
+        assert_true(blobEvent instanceof BlobEvent, 'the type of event should be BlobEvent');
+        assert_equals(blobEvent.type, 'dataavailable', 'the event type should be dataavailable');
+        assert_true(blobEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
+        assert_true(blobEvent.data instanceof Blob, 'the type of data should be Blob');
+        assert_true(blobEvent.data.size > 0, 'the blob should contain some buffers');
+        const player = document.getElementById("player");
+        player.src = ""
+        player._oncanplay_ = () => {
+            assert_greater_than(player.duration, 0, 'the duration should be greater than 0');
+            done();
+        };
+        player.load();
+    };
 
-        recorder.start();
-        osc.start();
-        assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
-        setTimeout(() => {
-            recorder.stop();
-            osc.stop();
-        }, 500);
-    }, 'MediaRecorder can successfully record the audio for a audio-only stream');
+    recorder.start();
+    osc.start();
+    assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
+    setTimeout(() => {
+        recorder.stop();
+        osc.stop();
+    }, 500);
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-AV-audio-video-dataavailable.html (238873 => 238874)


--- trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-AV-audio-video-dataavailable.html	2018-12-04 20:57:56 UTC (rev 238873)
+++ trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-AV-audio-video-dataavailable.html	2018-12-04 21:40:44 UTC (rev 238874)
@@ -1,7 +1,7 @@
 <!doctype html>
 <html>
 <head>
-    <title>MediaRecorder Dataavailable</title>
+    <title>MediaRecorder can successfully record the video for a audio-video stream</title>
     <link rel="help" href=""
     <script src=""
     <script src=""
@@ -10,13 +10,13 @@
 </head>
 <body>
 <div>
-    <video id="player">
+    <video id="player" controls="true">
     </video>
 </div>
 <div>
     <canvas id="canvas" width="200" height="200">
     </canvas>
-    <canvas id="frame" width="200" height="200">
+    <canvas id="frame" width="200" height="200" style="visibility:visible; display:block">
     </canvas>
 </div>
 <script>
@@ -33,7 +33,7 @@
         if (context) {
             context.fillStyle = "#ff0000";
             context.fillRect(0, 0, 200, 200);
-            if (Date.now() - drawStartTime < 500) {
+            if (Date.now() - drawStartTime < 2000) {
                 window.requestAnimationFrame(doRedImageDraw);
             } else {
                 drawStartTime = Date.now();
@@ -46,68 +46,70 @@
         if (context) {
             context.fillStyle = "#00ff00";
             context.fillRect(0, 0, 200, 200);
-            if (Date.now() - drawStartTime < 500) {
+            if (Date.now() - drawStartTime < 10000) {
                 window.requestAnimationFrame(doGreenImageDraw);
             }
         }
     }
 
-    async_test(t => {
-        const ac = new AudioContext();
-        const osc = ac.createOscillator();
-        const dest = ac.createMediaStreamDestination();
-        const audio = dest.stream;
-        osc.connect(dest);
+    const ac = new webkitAudioContext();
+    const osc = ac.createOscillator();
+    const dest = ac.createMediaStreamDestination();
+    const audio = dest.stream;
+    osc.connect(dest);
 
-        const video = createVideoStream();
-        assert_equals(video.getAudioTracks().length, 0, "video mediastream starts with no audio track");
-        assert_equals(audio.getAudioTracks().length, 1, "audio mediastream starts with one audio track");
-        video.addTrack(audio.getAudioTracks()[0]);
-        assert_equals(video.getAudioTracks().length, 1, "video mediastream starts with one audio track");
-        const recorder = new MediaRecorder(video);
-        let mode = 0;
+    const video = createVideoStream();
+    assert_equals(video.getAudioTracks().length, 0, "video mediastream starts with no audio track");
+    assert_equals(audio.getAudioTracks().length, 1, "audio mediastream starts with one audio track");
+    video.addTrack(audio.getAudioTracks()[0]);
+    assert_equals(video.getAudioTracks().length, 1, "video mediastream starts with one audio track");
+    const recorder = new MediaRecorder(video);
+    let mode = 0;
 
-        recorder._ondataavailable_ = t.step_func(blobEvent => {
-            assert_true(blobEvent instanceof BlobEvent, 'the type of event should be BlobEvent');
-            assert_equals(blobEvent.type, 'dataavailable', 'the event type should be dataavailable');
-            assert_true(blobEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
-            assert_true(blobEvent.data instanceof Blob, 'the type of data should be Blob');
-            assert_true(blobEvent.data.size > 0, 'the blob should contain some buffers');
-            player.src = ""
-            const resFrame = document.getElementById("frame");
-            const resContext = resFrame.getContext('2d');
-            player._oncanplay_ = () => {
-                assert_greater_than(player.duration, 0.1, 'the duration should be greater than 100ms');
-                player.play();
-            };
-            player._onplay_ = () => {
-                player.pause();
-                player.currentTime = 0.1;
-            };
-            player._onseeked_ = () => {
-                resContext.drawImage(player, 0, 0);
-                if (!mode) {
-                    _assertPixelApprox(resFrame, 0, 0, 255, 0, 0, 255, "0, 0", "255, 0, 0, 255", 5);
-                    _assertPixelApprox(resFrame, 50, 50, 255, 0, 0, 255, "50, 50", "255, 0, 0, 255", 5);
-                    mode = 1;
-                    player.currentTime = player.duration;
-                } else {
-                    _assertPixelApprox(resFrame, 199, 0, 0, 255, 0, 255, "199, 0", "0, 255, 0, 255", 5);
-                    _assertPixelApprox(resFrame, 199, 199, 0, 255, 0, 255, "199, 199", "0, 255, 0, 255", 5);
-                    t.done();
-                }
-            };
-            player.load();
-        });
-        drawStartTime = Date.now();
-        doRedImageDraw();
-        recorder.start();
-        assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
-        setTimeout(() => {
-            recorder.stop();
-        }, 1000);
-    }, 'MediaRecorder can successfully record the video for a audio-video stream');
+    recorder._ondataavailable_ = (blobEvent) => {
+        assert_true(blobEvent instanceof BlobEvent, 'the type of event should be BlobEvent');
+        assert_equals(blobEvent.type, 'dataavailable', 'the event type should be dataavailable');
+        assert_true(blobEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
+        assert_true(blobEvent.data instanceof Blob, 'the type of data should be Blob');
+        assert_true(blobEvent.data.size > 0, 'the blob should contain some buffers');
+        player.src = ""
+        const resFrame = document.getElementById("frame");
+        const resContext = resFrame.getContext('2d');
+        player._oncanplay_ = () => {
+            assert_greater_than(player.duration, 0.1, 'the duration should be greater than 100ms');
+            player.play();
+        };
+        player._onplay_ = () => {
+            if (mode === 2)
+                return;
+            player.pause();
+            player.currentTime = 1;
+        };
+        player._onseeked_ = () => {
+            resContext.drawImage(player, 0, 0);
+            if (!mode) {
+                _assertPixelApprox(resFrame, 20, 20, 255, 0, 0, 255, "20, 20", "255, 0, 0, 255", 50);
+                _assertPixelApprox(resFrame, 50, 50, 255, 0, 0, 255, "50, 50", "255, 0, 0, 255", 50);
+                mode = 1;
+                player.currentTime = 3;
+            } else if (mode === 1) {
+                _assertPixelApprox(resFrame, 21, 21, 0, 255, 0, 255, "21, 21", "0, 255, 0, 255", 50);
+                _assertPixelApprox(resFrame, 51, 51, 0, 255, 0, 255, "51, 51", "0, 255, 0, 255", 50);
+                mode =2;
+                done();
+            }
+        };
+        player.load();
+    };
+    recorder.start();
+    assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
+    drawStartTime = Date.now();
+    doRedImageDraw();
+    osc.start();
+    setTimeout(() => {
+        recorder.stop();
+    }, 4000);
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-AV-video-only-dataavailable.html (238873 => 238874)


--- trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-AV-video-only-dataavailable.html	2018-12-04 20:57:56 UTC (rev 238873)
+++ trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-AV-video-only-dataavailable.html	2018-12-04 21:40:44 UTC (rev 238874)
@@ -1,7 +1,7 @@
 <!doctype html>
 <html>
 <head>
-    <title>MediaRecorder Dataavailable</title>
+    <title>MediaRecorder can successfully record the video for a video-only stream</title>
     <link rel="help" href=""
     <script src=""
     <script src=""
@@ -10,13 +10,13 @@
 </head>
 <body>
 <div>
-    <video id="player">
+    <video id="player" controls=true>
     </video>
 </div>
 <div>
     <canvas id="canvas" width="200" height="200">
     </canvas>
-    <canvas id="frame" width="200" height="200">
+    <canvas id="frame" width="200" height="200" style="visibility:visible; display:block">
     </canvas>
 </div>
 <script>
@@ -33,7 +33,7 @@
         if (context) {
             context.fillStyle = "#ff0000";
             context.fillRect(0, 0, 200, 200);
-            if (Date.now() - drawStartTime < 500) {
+            if (Date.now() - drawStartTime < 2000) {
                 window.requestAnimationFrame(doRedImageDraw);
             } else {
                 drawStartTime = Date.now();
@@ -46,57 +46,58 @@
         if (context) {
             context.fillStyle = "#00ff00";
             context.fillRect(0, 0, 200, 200);
-            if (Date.now() - drawStartTime < 500) {
+            if (Date.now() - drawStartTime < 10000) {
                 window.requestAnimationFrame(doGreenImageDraw);
             }
         }
     }
 
-    async_test(t => {
-        const video = createVideoStream();
-        const recorder = new MediaRecorder(video);
-        let mode = 0;
-        recorder._ondataavailable_ = t.step_func(blobEvent => {
-            assert_true(blobEvent instanceof BlobEvent, 'the type of event should be BlobEvent');
-            assert_equals(blobEvent.type, 'dataavailable', 'the event type should be dataavailable');
-            assert_true(blobEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
-            assert_true(blobEvent.data instanceof Blob, 'the type of data should be Blob');
-            assert_true(blobEvent.data.size > 0, 'the blob should contain some buffers');
-            player.src = ""
-            const resFrame = document.getElementById("frame");
-            const resContext = resFrame.getContext('2d');
-            player._oncanplay_ = () => {
-                assert_greater_than(player.duration, 0.1, 'the duration should be greater than 100ms');
-                player.play();
-            };
-            player._onplay_ = () => {
-                player.pause();
-                player.currentTime = 0.1;
-            };
-            player._onseeked_ = () => {
-                resContext.drawImage(player, 0, 0);
-                if (!mode) {
-                    _assertPixelApprox(resFrame, 0, 0, 255, 0, 0, 255, "0, 0", "255, 0, 0, 255", 5);
-                    _assertPixelApprox(resFrame, 50, 50, 255, 0, 0, 255, "50, 50", "255, 0, 0, 255", 5);
-                    mode = 1;
-                    player.currentTime = player.duration;
-                } else {
-                    _assertPixelApprox(resFrame, 199, 0, 0, 255, 0, 255, "199, 0", "0, 255, 0, 255", 5);
-                    _assertPixelApprox(resFrame, 199, 199, 0, 255, 0, 255, "199, 199", "0, 255, 0, 255", 5);
-                    t.done();
-                }
-            };
-            player.load();
-        });
-        drawStartTime = Date.now();
-        doRedImageDraw();
-        recorder.start();
-        assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
-        setTimeout(() => {
-            recorder.stop();
-        }, 1000);
-    }, 'MediaRecorder can successfully record the video for a video-only stream');
+    const video = createVideoStream();
+    const recorder = new MediaRecorder(video);
+    let mode = 0;
+    recorder._ondataavailable_ = (blobEvent) => {
+        assert_true(blobEvent instanceof BlobEvent, 'the type of event should be BlobEvent');
+        assert_equals(blobEvent.type, 'dataavailable', 'the event type should be dataavailable');
+        assert_true(blobEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
+        assert_true(blobEvent.data instanceof Blob, 'the type of data should be Blob');
+        assert_true(blobEvent.data.size > 0, 'the blob should contain some buffers');
+        player.src = ""
+        const resFrame = document.getElementById("frame");
+        const resContext = resFrame.getContext('2d');
+        player._oncanplay_ = () => {
+            assert_greater_than(player.duration, 0.1, 'the duration should be greater than 100ms');
+            player.play();
+        };
+        player._onplay_ = () => {
+            if (mode === 2)
+                return;
+            player.pause();
+            player.currentTime = 1;
+        };
+        player._onseeked_ = () => {
+            resContext.drawImage(player, 0, 0);
+            if (!mode) {
+                _assertPixelApprox(resFrame, 20, 20, 255, 0, 0, 255, "20,2 0", "255, 0, 0, 255", 50);
+                _assertPixelApprox(resFrame, 50, 50, 255, 0, 0, 255, "50, 50", "255, 0, 0, 255", 50);
+                mode = 1;
+                player.currentTime = 3;
+            } else if (mode === 1){
+                _assertPixelApprox(resFrame, 21, 21, 0, 255, 0, 255, "21, 21", "0, 255, 0, 255", 50);
+                _assertPixelApprox(resFrame, 51, 51, 0, 255, 0, 255, "51, 51", "0, 255, 0, 255", 50);
+                mode = 2;
+                done();
+            }
+        };
+        player.load();
+    };
+    recorder.start();
+    assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
+    drawStartTime = Date.now();
+    doRedImageDraw();
+    setTimeout(() => {
+        recorder.stop();
+    }, 4000);
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (238873 => 238874)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2018-12-04 20:57:56 UTC (rev 238873)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2018-12-04 21:40:44 UTC (rev 238874)
@@ -599,6 +599,9 @@
 
 imported/w3c/web-platform-tests/webrtc/ [ Skip ]
 http/tests/webrtc [ Skip ]
+
+http/wpt/mediarecorder [ Skip ]
+
 # The MediaStream implementation is also still not completed
 webkit.org/b/79203 fast/mediastream/mock-media-source-webaudio.html [ Timeout ]
 webkit.org/b/79203 fast/mediastream/getUserMedia-webaudio.html [ Failure ]

Modified: trunk/LayoutTests/platform/wpe/TestExpectations (238873 => 238874)


--- trunk/LayoutTests/platform/wpe/TestExpectations	2018-12-04 20:57:56 UTC (rev 238873)
+++ trunk/LayoutTests/platform/wpe/TestExpectations	2018-12-04 21:40:44 UTC (rev 238874)
@@ -494,6 +494,8 @@
 http/tests/websocket [ Skip ]
 http/tests/xmlhttprequest [ Skip ]
 
+http/wpt/mediarecorder [ Skip ]
+
 # Service-workers tests that fail, time out or crash.
 webkit.org/b/175419 http/tests/workers/service/controller-change.html [ Skip ]
 webkit.org/b/175419 http/tests/workers/service/no-page-cache-when-controlled.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (238873 => 238874)


--- trunk/Source/WebCore/ChangeLog	2018-12-04 20:57:56 UTC (rev 238873)
+++ trunk/Source/WebCore/ChangeLog	2018-12-04 21:40:44 UTC (rev 238874)
@@ -1,3 +1,16 @@
+2018-12-04  Youenn Fablet  <you...@apple.com>
+
+        Fix MediaRecorder flaky tests
+        https://bugs.webkit.org/show_bug.cgi?id=192371
+
+        Reviewed by Eric Carlson.
+
+        No change of behavior.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+        Reset to use real MediaRecorder by default.
+
 2018-12-04  Justin Michaud  <justin_mich...@apple.com>
 
         CSS Painting API should allow image values in inputProperties

Modified: trunk/Source/WebCore/testing/Internals.cpp (238873 => 238874)


--- trunk/Source/WebCore/testing/Internals.cpp	2018-12-04 20:57:56 UTC (rev 238873)
+++ trunk/Source/WebCore/testing/Internals.cpp	2018-12-04 21:40:44 UTC (rev 238874)
@@ -519,6 +519,10 @@
     page.setFullscreenControlsHidden(false);
 
     MediaEngineConfigurationFactory::disableMock();
+
+#if ENABLE(MEDIA_STREAM)
+    WebCore::MediaRecorder::setCustomPrivateRecorderCreator(nullptr);
+#endif
 }
 
 Internals::Internals(Document& document)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to