Title: [268477] trunk
Revision
268477
Author
you...@apple.com
Date
2020-10-14 11:56:04 -0700 (Wed, 14 Oct 2020)

Log Message

MediaRecorder .stop should not throw in Inactive state
https://bugs.webkit.org/show_bug.cgi?id=217705

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

fix-217705

* web-platform-tests/mediacapture-record/MediaRecorder-stop-expected.txt:
* web-platform-tests/mediacapture-record/MediaRecorder-stop.html:

Source/WebCore:

Update according spec changes in https://github.com/w3c/mediacapture-record/pull/158.
stop no longer throws if media recorder is inactive.
Covered by updated test.

* Modules/mediarecorder/MediaRecorder.cpp:
(WebCore::MediaRecorder::stopRecording):
* Modules/mediarecorder/MediaRecorder.h:
* Modules/mediarecorder/MediaRecorder.idl:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (268476 => 268477)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-14 18:06:37 UTC (rev 268476)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-14 18:56:04 UTC (rev 268477)
@@ -1,3 +1,15 @@
+2020-10-14  Youenn Fablet  <you...@apple.com>
+
+        MediaRecorder .stop should not throw in Inactive state
+        https://bugs.webkit.org/show_bug.cgi?id=217705
+
+        Reviewed by Eric Carlson.
+
+        fix-217705
+
+        * web-platform-tests/mediacapture-record/MediaRecorder-stop-expected.txt:
+        * web-platform-tests/mediacapture-record/MediaRecorder-stop.html:
+
 2020-10-13  Chris Dumez  <cdu...@apple.com>
 
         It should be possible to create an AudioWorkletNode for a context that has finished rendering

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop-expected.txt (268476 => 268477)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop-expected.txt	2020-10-14 18:06:37 UTC (rev 268476)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop-expected.txt	2020-10-14 18:56:04 UTC (rev 268477)
@@ -1,9 +1,9 @@
 
 PASS MediaRecorder will stop recording and fire a stop event when all tracks are ended
 PASS MediaRecorder will stop recording and fire a stop event when stop() is called
-PASS MediaRecorder will fire an exception when stopped after creation
-PASS MediaRecorder will fire an exception when stopped after having just been stopped
-PASS MediaRecorder will fire an exception when stopped after having just been spontaneously stopped
+PASS MediaRecorder will not fire an exception when stopped after creation
+PASS MediaRecorder will not fire an exception when stopped after having just been stopped
+PASS MediaRecorder will not fire an exception when stopped after having just been spontaneously stopped
 PASS MediaRecorder will fire start event even if stopped synchronously
 PASS MediaRecorder will fire start event even if a track is removed synchronously
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop.html (268476 => 268477)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop.html	2020-10-14 18:06:37 UTC (rev 268476)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop.html	2020-10-14 18:56:04 UTC (rev 268477)
@@ -83,12 +83,12 @@
 
     promise_test(async t => {
         const recorder = new MediaRecorder(createVideoStream());
-        assert_throws_dom("InvalidStateError", () => { recorder.stop(); });
+        recorder.stop();
         await Promise.race([
             new Promise((_, reject) => recorder._onstop_ =
                 _ => reject(new Error("onstop should never have been called"))),
             new Promise(r => t.step_timeout(r, 0))]);
-    }, "MediaRecorder will fire an exception when stopped after creation");
+    }, "MediaRecorder will not fire an exception when stopped after creation");
 
     promise_test(async t => {
         const recorder = new MediaRecorder(createVideoStream());
@@ -95,12 +95,12 @@
         recorder.start();
         recorder.stop();
         let event = await new Promise(r => recorder._onstop_ = r);
-        assert_throws_dom("InvalidStateError", () => { recorder.stop(); });
+        recorder.stop();
         await Promise.race([
             new Promise((_, reject) => recorder._onstop_ =
                 _ => reject(new Error("onstop should never have been called"))),
             new Promise(r => t.step_timeout(r, 0))]);
-    }, "MediaRecorder will fire an exception when stopped after having just been stopped");
+    }, "MediaRecorder will not fire an exception when stopped after having just been stopped");
 
     promise_test(async t => {
         const stream = createVideoStream();
@@ -108,12 +108,12 @@
         recorder.start();
         stream.getVideoTracks()[0].stop();
         let event = await new Promise(r => recorder._onstop_ = r);
-        assert_throws_dom("InvalidStateError", () => { recorder.stop(); });
+        recorder.stop();
         await Promise.race([
             new Promise((_, reject) => recorder._onstop_ =
                 _ => reject(new Error("onstop should never have been called"))),
             new Promise(r => t.step_timeout(r, 0))]);
-    }, "MediaRecorder will fire an exception when stopped after having just been spontaneously stopped");
+    }, "MediaRecorder will not fire an exception when stopped after having just been spontaneously stopped");
 
     promise_test(async t => {
         const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true });

Modified: trunk/Source/WebCore/ChangeLog (268476 => 268477)


--- trunk/Source/WebCore/ChangeLog	2020-10-14 18:06:37 UTC (rev 268476)
+++ trunk/Source/WebCore/ChangeLog	2020-10-14 18:56:04 UTC (rev 268477)
@@ -1,3 +1,19 @@
+2020-10-14  Youenn Fablet  <you...@apple.com>
+
+        MediaRecorder .stop should not throw in Inactive state
+        https://bugs.webkit.org/show_bug.cgi?id=217705
+
+        Reviewed by Eric Carlson.
+
+        Update according spec changes in https://github.com/w3c/mediacapture-record/pull/158.
+        stop no longer throws if media recorder is inactive.
+        Covered by updated test.
+
+        * Modules/mediarecorder/MediaRecorder.cpp:
+        (WebCore::MediaRecorder::stopRecording):
+        * Modules/mediarecorder/MediaRecorder.h:
+        * Modules/mediarecorder/MediaRecorder.idl:
+
 2020-10-13  Simon Fraser  <simon.fra...@apple.com>
 
         Allow passive mouse wheel event listeners to not force synchronous scrolling

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp (268476 => 268477)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-10-14 18:06:37 UTC (rev 268476)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-10-14 18:56:04 UTC (rev 268477)
@@ -202,10 +202,10 @@
     return BlobEvent::create(eventNames().dataavailableEvent, BlobEvent::Init { { false, false, false }, WTFMove(blob), timeCode }, BlobEvent::IsTrusted::Yes);
 }
 
-ExceptionOr<void> MediaRecorder::stopRecording()
+void MediaRecorder::stopRecording()
 {
     if (state() == RecordingState::Inactive)
-        return Exception { InvalidStateError, "The MediaRecorder's state cannot be inactive"_s };
+        return;
 
     stopRecordingInternal();
     fetchData([this](auto&& buffer, auto& mimeType, auto timeCode) {
@@ -218,7 +218,7 @@
             return;
         dispatchEvent(Event::create(eventNames().stopEvent, Event::CanBubble::No, Event::IsCancelable::No));
     }, TakePrivateRecorder::Yes);
-    return { };
+    return;
 }
 
 ExceptionOr<void> MediaRecorder::requestData()

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h (268476 => 268477)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-10-14 18:06:37 UTC (rev 268476)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-10-14 18:56:04 UTC (rev 268477)
@@ -69,7 +69,7 @@
     using RefCounted::deref;
     
     ExceptionOr<void> startRecording(Optional<unsigned>);
-    ExceptionOr<void> stopRecording();
+    void stopRecording();
     ExceptionOr<void> requestData();
     ExceptionOr<void> pauseRecording();
     ExceptionOr<void> resumeRecording();

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl (268476 => 268477)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl	2020-10-14 18:06:37 UTC (rev 268476)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl	2020-10-14 18:56:04 UTC (rev 268477)
@@ -46,7 +46,7 @@
     // readonly attribute BitrateMode audioBitrateMode;
 
     [MayThrowException, ImplementedAs=startRecording] undefined start(optional unsigned long timeslice);
-    [MayThrowException, ImplementedAs=stopRecording] undefined stop();
+    [ImplementedAs=stopRecording] undefined stop();
     [MayThrowException, ImplementedAs=pauseRecording] undefined pause();
     [MayThrowException, ImplementedAs=resumeRecording] undefined resume();
     [MayThrowException] undefined requestData();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to