Title: [135931] branches/chromium/1271

Diff

Copied: branches/chromium/1271/LayoutTests/http/tests/media/media-source/video-media-source-closed-on-htmlmediaelement-destruction-expected.txt (from rev 135906, trunk/LayoutTests/http/tests/media/media-source/video-media-source-closed-on-htmlmediaelement-destruction-expected.txt) (0 => 135931)


--- branches/chromium/1271/LayoutTests/http/tests/media/media-source/video-media-source-closed-on-htmlmediaelement-destruction-expected.txt	                        (rev 0)
+++ branches/chromium/1271/LayoutTests/http/tests/media/media-source/video-media-source-closed-on-htmlmediaelement-destruction-expected.txt	2012-11-27 23:33:37 UTC (rev 135931)
@@ -0,0 +1,9 @@
+Tests that the MediaSource is closed when the HTMLMediaElement is destroyed.
+
+sourceOpened called.
+Removing video element from DOM.
+Running the garbage collector.
+Setting timestampOffset failed as expected: InvalidStateError
+sourceClosed called.
+END OF TEST
+

Copied: branches/chromium/1271/LayoutTests/http/tests/media/media-source/video-media-source-closed-on-htmlmediaelement-destruction.html (from rev 135906, trunk/LayoutTests/http/tests/media/media-source/video-media-source-closed-on-htmlmediaelement-destruction.html) (0 => 135931)


--- branches/chromium/1271/LayoutTests/http/tests/media/media-source/video-media-source-closed-on-htmlmediaelement-destruction.html	                        (rev 0)
+++ branches/chromium/1271/LayoutTests/http/tests/media/media-source/video-media-source-closed-on-htmlmediaelement-destruction.html	2012-11-27 23:33:37 UTC (rev 135931)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+    <head>
+      <script src=""
+      <script src=""
+
+      <script>
+          var ms = new WebKitMediaSource();
+
+          function sourceOpened()
+          {
+              consoleWrite("sourceOpened called.");
+              var vid = document.getElementById('vid');
+              var buffer = ms.addSourceBuffer('video/webm; codecs="vorbis,vp8"');
+
+              MediaSourceTest.expectSourceState(ms, "open");
+
+              consoleWrite("Removing video element from DOM.");
+              vid.parentNode.removeChild(vid);
+              vid = null;
+
+              consoleWrite("Running the garbage collector.");
+              gc();
+
+              MediaSourceTest.expectSourceState(ms, "closed");
+
+              try {
+                  buffer.timestampOffset = 42;
+                  failTest("Expected an exception");
+              } catch (e) {
+                  consoleWrite("Setting timestampOffset failed as expected: " + e.name);
+              }
+          }
+
+          function sourceClosed()
+          {
+              consoleWrite("sourceClosed called.");
+              endTest();
+          }
+
+          function onLoad()
+          {
+              waitForEventAndFail('error');
+
+              ms.addEventListener('webkitsourceopen', sourceOpened);
+              ms.addEventListener('webkitsourceclose', sourceClosed);
+
+              document.getElementById('vid').src = ""
+          }
+      </script>
+    </head>
+    <body _onload_="onLoad()">
+      <video id="vid"></video>
+      <p>Tests that the MediaSource is closed when the HTMLMediaElement is destroyed.</p>
+    </body>
+</html>

Modified: branches/chromium/1271/LayoutTests/http/tests/media/media-source/video-media-source-state-changes-expected.txt (135930 => 135931)


--- branches/chromium/1271/LayoutTests/http/tests/media/media-source/video-media-source-state-changes-expected.txt	2012-11-27 23:27:05 UTC (rev 135930)
+++ branches/chromium/1271/LayoutTests/http/tests/media/media-source/video-media-source-state-changes-expected.txt	2012-11-27 23:33:37 UTC (rev 135931)
@@ -16,18 +16,18 @@
 onSecondSeeking
 EVENT(seeked)
 onSecondSeeked
-EVENT(emptied)
 EVENT(webkitsourceclose) : closed
 onFirstSourceClose
+EVENT(emptied)
 EVENT(webkitsourceopen) : open
 onSecondSourceOpen
 EVENT(webkitsourceended) : ended
 onSecondSourceEnded
 EVENT(playing)
 triggerSecondSourceClose
-EVENT(emptied)
 EVENT(webkitsourceclose) : closed
 onSecondSourceClose
+EVENT(emptied)
 EVENT(webkitsourceopen) : open
 onThirdSourceOpen
 END OF TEST

Modified: branches/chromium/1271/Source/WebCore/html/HTMLMediaElement.cpp (135930 => 135931)


--- branches/chromium/1271/Source/WebCore/html/HTMLMediaElement.cpp	2012-11-27 23:27:05 UTC (rev 135930)
+++ branches/chromium/1271/Source/WebCore/html/HTMLMediaElement.cpp	2012-11-27 23:33:37 UTC (rev 135931)
@@ -303,6 +303,10 @@
     if (m_mediaController)
         m_mediaController->removeMediaElement(this);
 
+#if ENABLE(MEDIA_SOURCE)
+    setSourceState(MediaSource::closedKeyword());
+#endif
+
     removeElementFromDocumentMap(this, document());
 }
 
@@ -3616,6 +3620,10 @@
     // If the media data fetching process is aborted by the user:
 
     // 1 - The user agent should cancel the fetching process.
+#if ENABLE(MEDIA_SOURCE)
+    setSourceState(MediaSource::closedKeyword());
+#endif
+
 #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     m_player.clear();
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to