Title: [195540] trunk
Revision
195540
Author
[email protected]
Date
2016-01-25 09:55:17 -0800 (Mon, 25 Jan 2016)

Log Message

Media "ended" event incorrectly fires when currentTime is set
https://bugs.webkit.org/show_bug.cgi?id=150348
<rdar://problem/24247974>

Reviewed by Jer Noble.

Source/WebCore:

Test: media/media-ended-fired-once.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::invalidateCachedTime): Always mark m_cachedTime as invalid.

LayoutTests:

* media/media-ended-fired-once-expected.txt: Added.
* media/media-ended-fired-once.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195539 => 195540)


--- trunk/LayoutTests/ChangeLog	2016-01-25 17:49:22 UTC (rev 195539)
+++ trunk/LayoutTests/ChangeLog	2016-01-25 17:55:17 UTC (rev 195540)
@@ -1,3 +1,14 @@
+2016-01-25  Eric Carlson  <[email protected]>
+
+        Media "ended" event incorrectly fires when currentTime is set
+        https://bugs.webkit.org/show_bug.cgi?id=150348
+        <rdar://problem/24247974>
+
+        Reviewed by Jer Noble.
+
+        * media/media-ended-fired-once-expected.txt: Added.
+        * media/media-ended-fired-once.html: Added.
+
 2016-01-22  Ryosuke Niwa  <[email protected]>
 
         document.createElement should be able to create a custom element

Added: trunk/LayoutTests/media/media-ended-fired-once-expected.txt (0 => 195540)


--- trunk/LayoutTests/media/media-ended-fired-once-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-ended-fired-once-expected.txt	2016-01-25 17:55:17 UTC (rev 195540)
@@ -0,0 +1,17 @@
+
+Test 'ended' event by:
+
+Playing to the end.
+When 'ended' event fires, seek to 0.
+Verify that 'ended' event is not fired again.
+
+EVENT(canplaythrough)
+RUN(audio.currentTime = 1.0)
+RUN(audio.play())
+
+EVENT(ended)
+EXPECTED (audio.ended == 'true') OK
+RUN(audio.currentTime = 0)
+
+END OF TEST
+

Added: trunk/LayoutTests/media/media-ended-fired-once.html (0 => 195540)


--- trunk/LayoutTests/media/media-ended-fired-once.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-ended-fired-once.html	2016-01-25 17:55:17 UTC (rev 195540)
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script src=""
+
+        <script>
+            var endedCount = 0;
+            var audio;
+
+            function start()
+            {
+                consoleWrite("");
+                audio = document.querySelector("audio");
+                waitForEvent("ended", ended);
+                waitForEvent("canplaythrough", canplaythrough);
+
+                audio.src = "" "content/silence")
+            }
+
+            function canplaythrough()
+            {
+                run("audio.currentTime = 1.0");
+                run("audio.play()");
+                consoleWrite("");
+            }
+
+            function ended()
+            {
+                switch (++endedCount)
+                {
+                    case 1:
+                        testExpected("audio.ended", true);
+
+                        run("audio.currentTime = 0");
+                        setTimeout(endTest, 200);
+
+                        consoleWrite("");
+                        break;
+                    default:
+                        consoleWrite("");
+                        failTest("'ended' event fired again");
+                        break;
+                }
+            }
+        </script>
+    </head>
+    <body _onload_="start()">
+        <audio controls></audio>
+        <p><b>Test 'ended' event by:</b>
+            <ol>
+                <li>Playing to the end.</li>
+                <li>When 'ended' event fires, seek to 0.</li>
+                <li>Verify that 'ended' event is not fired again.</li>
+            </ol>
+        </p>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (195539 => 195540)


--- trunk/Source/WebCore/ChangeLog	2016-01-25 17:49:22 UTC (rev 195539)
+++ trunk/Source/WebCore/ChangeLog	2016-01-25 17:55:17 UTC (rev 195540)
@@ -1,3 +1,16 @@
+2016-01-25  Eric Carlson  <[email protected]>
+
+        Media "ended" event incorrectly fires when currentTime is set
+        https://bugs.webkit.org/show_bug.cgi?id=150348
+        <rdar://problem/24247974>
+
+        Reviewed by Jer Noble.
+
+        Test: media/media-ended-fired-once.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::invalidateCachedTime): Always mark m_cachedTime as invalid.
+
 2016-01-25  Konstantin Tokarev  <[email protected]>
 
         Do not convert GlyphBufferAdvance to FloatSize

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (195539 => 195540)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-01-25 17:49:22 UTC (rev 195539)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-01-25 17:55:17 UTC (rev 195540)
@@ -2687,6 +2687,7 @@
 
 void HTMLMediaElement::invalidateCachedTime() const
 {
+    m_cachedTime = MediaTime::invalidTime();
     if (!m_player || !m_player->maximumDurationToCacheMediaTime())
         return;
 
@@ -2701,7 +2702,6 @@
     static const double minimumTimePlayingBeforeCacheSnapshot = 0.5;
 
     m_minimumClockTimeToUpdateCachedTime = monotonicallyIncreasingTime() + minimumTimePlayingBeforeCacheSnapshot;
-    m_cachedTime = MediaTime::invalidTime();
 }
 
 // playback state
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to