[MediaStream] MediaStream.addTrack Should not check for active state.
authorberto@igalia.com <berto@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 May 2014 13:56:15 +0000 (13:56 +0000)
committerberto@igalia.com <berto@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 May 2014 13:56:15 +0000 (13:56 +0000)
Source/WebCore:
https://bugs.webkit.org/show_bug.cgi?id=132558

Patch by Kiran <kiran.guduru@samsung.com> on 2014-05-13
Reviewed by Eric Carlson.

MediaStream.addTrack method is checking for active state of a
MediaStream, but it should not check for active state while adding a Track.

Test: fast/mediastream/MediaStream-add-tracks-to-inactive-stream.html

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::addTrack):

LayoutTests:
Nhttps://bugs.webkit.org/show_bug.cgi?id=132558.

Patch by Kiran <kiran.guduru@samsung.com> on 2014-05-13
Reviewed by Eric Carlson.

MediaStream.addTrack method is checking for active state of a
MediaStream, but it should not check for active state while adding a Track

Removed check not to add tracks to ended stream:relative which forced tests to avoid this bug.
* fast/mediastream/MediaStream-add-remove-tracks-expected.txt:
* fast/mediastream/MediaStream-add-remove-tracks.html:

New tests:
* fast/mediastream/MediaStream-add-tracks-to-inactive-stream-expected.txt: Added.
* fast/mediastream/MediaStream-add-tracks-to-inactive-stream.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaStream-add-remove-tracks-expected.txt
LayoutTests/fast/mediastream/MediaStream-add-remove-tracks.html
LayoutTests/fast/mediastream/MediaStream-add-tracks-to-inactive-stream-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/MediaStream-add-tracks-to-inactive-stream.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.cpp

index aa1c2e7..67f44bd 100644 (file)
@@ -1,3 +1,21 @@
+2014-05-13  Kiran  <kiran.guduru@samsung.com>
+
+        [MediaStream] MediaStream.addTrack Should not check for active state.
+        Nhttps://bugs.webkit.org/show_bug.cgi?id=132558.
+
+        Reviewed by Eric Carlson.
+
+        MediaStream.addTrack method is checking for active state of a
+        MediaStream, but it should not check for active state while adding a Track
+
+        Removed check not to add tracks to ended stream:relative which forced tests to avoid this bug. 
+        * fast/mediastream/MediaStream-add-remove-tracks-expected.txt:
+        * fast/mediastream/MediaStream-add-remove-tracks.html:
+
+        New tests:
+        * fast/mediastream/MediaStream-add-tracks-to-inactive-stream-expected.txt: Added.
+        * fast/mediastream/MediaStream-add-tracks-to-inactive-stream.html: Added.
+
 2014-05-13  Lorenzo Tilve  <ltilve@igalia.com>
 
         [GTK] Unreviewed GTK gardening
index 87847d0..b2e1d05 100644 (file)
@@ -48,8 +48,7 @@ PASS stream1.getVideoTracks().length is 2
 PASS stream2.getAudioTracks().length is 0
 PASS stream2.getVideoTracks().length is 0
 
-*** it should be impossible to add a track after the stream has ended
-PASS stream2.addTrack(audioTrack) threw exception Error: InvalidStateError: DOM Exception 11.
+*** it should be impossible to remove a track after the stream has ended
 PASS stream2.removeTrack(audioTrack) threw exception Error: InvalidStateError: DOM Exception 11.
 Stream2 is inactive.
 PASS successfullyParsed is true
index e714d6d..ede8e9f 100644 (file)
                 shouldBe('stream2.getAudioTracks().length', '0');
                 shouldBe('stream2.getVideoTracks().length', '0');
 
-                debug("<br>*** it should be impossible to add a track after the stream has ended");
-                shouldThrow('stream2.addTrack(audioTrack)', '"Error: InvalidStateError: DOM Exception 11"');
+                debug("<br>*** it should be impossible to remove a track after the stream has ended");
                 shouldThrow('stream2.removeTrack(audioTrack)', '"Error: InvalidStateError: DOM Exception 11"');
             }
 
diff --git a/LayoutTests/fast/mediastream/MediaStream-add-tracks-to-inactive-stream-expected.txt b/LayoutTests/fast/mediastream/MediaStream-add-tracks-to-inactive-stream-expected.txt
new file mode 100644 (file)
index 0000000..9e10fc1
--- /dev/null
@@ -0,0 +1,13 @@
+Test adding tracks to inactive MediaStream.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+MediaStream without tracks created.
+PASS stream2.getAudioTracks().length is 0
+Adding tracks to inactive stream
+PASS stream2.getAudioTracks().length is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/mediastream/MediaStream-add-tracks-to-inactive-stream.html b/LayoutTests/fast/mediastream/MediaStream-add-tracks-to-inactive-stream.html
new file mode 100644 (file)
index 0000000..be9ba5e
--- /dev/null
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+    <head>
+        <script src="../../resources/js-test-pre.js"></script>
+        <script>
+
+
+            var stream1;
+            var audioTrack;
+
+            function error()
+            {
+                testFailed('Stream generation failed.');
+                finishJSTest();
+            }
+
+            function getUserMedia(dictionary, callback)
+            {
+                try {
+                    navigator.webkitGetUserMedia(dictionary, callback, error);
+                } catch (e) {
+                    testFailed('webkitGetUserMedia threw exception :' + e);
+                    finishJSTest();
+                }
+            }
+
+            function tryAddTrack(stream, track)
+            {
+                try {
+                    stream.addTrack(track);
+                } catch (exception) {
+                    testFailed("addTrack threw an exception.");
+                    finishJSTest();
+                }
+            }
+
+            function createStreamAndAddTracks()
+            {
+                stream2 = new webkitMediaStream();
+                debug("MediaStream without tracks created.");
+                shouldBe('stream2.getAudioTracks().length', '0');
+                audioTrack = stream1.getAudioTracks()[0];
+                debug("Adding tracks to inactive stream");
+                tryAddTrack(stream2, audioTrack);
+                shouldBe('stream2.getAudioTracks().length', '1');
+                finishJSTest();
+            }
+
+            function gotStream1(s)
+            {
+                stream1 = s;
+                createStreamAndAddTracks();
+            }
+
+            function startMedia()
+            {
+                description("Test adding tracks to inactive MediaStream.");
+                getUserMedia({audio:true, video:true}, gotStream1); 
+            }
+            window.jsTestIsAsync = true;
+            window.successfullyParsed = true;
+        </script>
+        <script src="../../resources/js-test-post.js"></script>
+    </head>
+    <body onload="startMedia()">
+        <p id="description"></p>
+        <div id="console"></div>
+    </body>
+</html>
index 0694647..a45cc89 100644 (file)
@@ -1,3 +1,18 @@
+2014-05-13  Kiran  <kiran.guduru@samsung.com>
+
+        [MediaStream] MediaStream.addTrack Should not check for active state.
+        https://bugs.webkit.org/show_bug.cgi?id=132558
+
+        Reviewed by Eric Carlson.
+
+        MediaStream.addTrack method is checking for active state of a
+        MediaStream, but it should not check for active state while adding a Track.
+
+        Test: fast/mediastream/MediaStream-add-tracks-to-inactive-stream.html
+
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::MediaStream::addTrack):
+
 2014-05-12  Mark Lam  <mark.lam@apple.com>
 
         WebKit2 on iOS needs to capture the main thread's floating point environment.
index a55c663..b09f56b 100644 (file)
@@ -143,11 +143,6 @@ void MediaStream::cloneMediaStreamTrackVector(Vector<RefPtr<MediaStreamTrack>>&
 
 void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode& ec)
 {
-    if (!active()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
-
     if (!prpTrack) {
         ec = TYPE_MISMATCH_ERR;
         return;