2011-05-25 Andrew Scherkus <scherkus@chromium.org>
authorscherkus@chromium.org <scherkus@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 May 2011 21:47:39 +0000 (21:47 +0000)
committerscherkus@chromium.org <scherkus@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 May 2011 21:47:39 +0000 (21:47 +0000)
        Reviewed by Eric Carlson.

        Fix media element regression where ended event stopped firing after changing the src attribute.

        https://bugs.webkit.org/show_bug.cgi?id=61336

        * media/media-ended-expected.txt: Added.
        * media/media-ended.html: Added.
2011-05-25  Andrew Scherkus  <scherkus@chromium.org>

        Reviewed by Eric Carlson.

        Fix media element regression where ended event stopped firing after changing the src attribute.

        https://bugs.webkit.org/show_bug.cgi?id=61336

        Test: media/media-ended.html

        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::prepareForLoad):

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

LayoutTests/ChangeLog
LayoutTests/media/media-ended-expected.txt [new file with mode: 0644]
LayoutTests/media/media-ended.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp

index 07b86de..f6fdc7e 100644 (file)
@@ -1,3 +1,14 @@
+2011-05-25  Andrew Scherkus  <scherkus@chromium.org>
+
+        Reviewed by Eric Carlson.
+
+        Fix media element regression where ended event stopped firing after changing the src attribute.
+
+        https://bugs.webkit.org/show_bug.cgi?id=61336
+
+        * media/media-ended-expected.txt: Added.
+        * media/media-ended.html: Added.
+
 2011-05-25  Jer Noble  <jer.noble@apple.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/media/media-ended-expected.txt b/LayoutTests/media/media-ended-expected.txt
new file mode 100644 (file)
index 0000000..eb8233e
--- /dev/null
@@ -0,0 +1,13 @@
+Test ended by:
+
+Play to the end.
+When 'ended' event fires, change the source.
+Verify that 'ended' event fires again on different source.
+EVENT(ended)
+EXPECTED (audio.ended == 'true') OK
+EXPECTED (audio.ended == 'false') OK
+
+EVENT(ended)
+EXPECTED (audio.ended == 'true') OK
+END OF TEST
+
diff --git a/LayoutTests/media/media-ended.html b/LayoutTests/media/media-ended.html
new file mode 100644 (file)
index 0000000..0a96fcc
--- /dev/null
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=media-file.js></script>
+        <script src=video-test.js></script>
+
+        <script>
+            var endedCount = 0;
+            var canplaythroughCount = 0;
+            var audio;
+
+            function start()
+            {
+                audio = document.querySelector("audio");
+                waitForEvent("ended", ended);
+
+                audio.src = findMediaFile("audio", "content/silence")
+            }
+
+            function ended()
+            {
+                switch (++endedCount)
+                {
+                    case 1:
+                        testExpected("audio.ended", true);
+
+                        // Change src but don't seek so that internal state isn't reset.
+                        audio.src = findMediaFile("audio", "content/silence")
+                        testExpected("audio.ended", false);
+
+                        consoleWrite("");
+                        break;
+                    case 2:
+                        testExpected("audio.ended", true);
+                        endTest();
+                        break;
+                }
+            }
+        </script>
+    </head>
+    <body onload="start()">
+        <audio controls autoplay></audio>
+        <p><b>Test ended by:</b>
+        <ol>
+            <li>Play to the end.</li>
+            <li>When 'ended' event fires, change the source.</li>
+            <li>Verify that 'ended' event fires again on different source.</li>
+        </ol>
+        </p>
+    </body>
+</html>
index 76ddd00..c314854 100644 (file)
@@ -1,3 +1,16 @@
+2011-05-25  Andrew Scherkus  <scherkus@chromium.org>
+
+        Reviewed by Eric Carlson.
+
+        Fix media element regression where ended event stopped firing after changing the src attribute.
+
+        https://bugs.webkit.org/show_bug.cgi?id=61336
+
+        Test: media/media-ended.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::prepareForLoad):
+
 2011-05-25  Jer Noble  <jer.noble@apple.com>
 
         Reviewed by Darin Adler.
index ed9cda8..27c92a1 100644 (file)
@@ -515,6 +515,7 @@ void HTMLMediaElement::prepareForLoad()
     // Perform the cleanup required for the resource load algorithm to run.
     stopPeriodicTimers();
     m_loadTimer.stop();
+    m_sentEndEvent = false;
     m_sentStalledEvent = false;
     m_haveFiredLoadedData = false;
     m_completelyLoaded = false;