onload callback for <track> element attached to <video> does not fire
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2012 18:28:57 +0000 (18:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2012 18:28:57 +0000 (18:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103258

Patch by Antoine Quint <graouts@apple.com> on 2012-12-20
Reviewed by Eric Carlson.

Source/WebCore:

We now correctly implement the track processing model per the latest spec at
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#start-the-track-processing-model.

For a <track> to load, three conditions must be met:

1. it must have a non-empty src
2. it must have a mode other than "disabled" (the default)
3. it must have a parent media element

We used to only check if we were able to load upon setting the track's src,
whereas a change of any of those conditions should have done this, which this
patch now correctly implements.

We also correctly implement the load model asynchronously after step 4, per
the spec, hence the split of the code previously entirely contained in
HTMLTrackElement::scheduleLoad() in another method fired on a timer.

Test: media/track/track-element-load-event.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::textTrackModeChanged):
* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::HTMLTrackElement):
(WebCore::HTMLTrackElement::insertedInto):
(WebCore::HTMLTrackElement::parseAttribute):
(WebCore::HTMLTrackElement::scheduleLoad):
(WebCore):
(WebCore::HTMLTrackElement::loadTimerFired):
(WebCore::HTMLTrackElement::textTrackModeChanged):
* html/HTMLTrackElement.h:
* html/track/TextTrack.cpp:
(WebCore::TextTrack::removeAllCues):
(WebCore):
* html/track/TextTrack.h:
(TextTrack):

LayoutTests:

As a result of fixing this bug, a few new failures were uncovered and TestExpectations
needed to be updated to take this into account. Additionally, some existing tests were
incorrect or outdated and were fixed as well. Finally, a new test was added to thoroughly
test the various conditions required for a <track> element to successfully load.

* fast/events/constructors/track-event-constructor.html: Update the test to correctly set
a non-disabled mode on the text track such that it may load per the rules enforced with this patch.
* http/tests/security/text-track-crossorigin.html: Update the test to correctly set a non-disabled
mode on the text track such that it may load per the rules enforced with this patch.
* media/track/track-add-track-expected.txt: Update the output to match changes made to test.
* media/track/track-add-track.html: Update the test to correctly set a non-disabled mode on
the text track such that it may load per the rules enforced with this patch. Also, ensure
the .readyState of the text track is correctly assumed to be NONE vs. LOADING as it would
have to wait until the next run loop to be changed to anything but NONE.
* media/track/track-element-load-event-expected.txt: Added.
* media/track/track-element-load-event.html: Added.
* media/track/track-load-from-src-readyState.html: Update the test to correctly set a
non-disabled mode on the text track such that it may load per the rules enforced with
this patch.
* platform/chromium/TestExpectations: Skip tests that now fail instead of timing out.
* platform/efl/TestExpectations: Skip tests that now fail instead of timing out.
* platform/gtk/TestExpectations: Skip tests that now fail instead of timing out.
* platform/mac/TestExpectations: Skip tests that now fail instead of timing out.
* platform/qt/TestExpectations: Skip tests that now fail instead of timing out.
* platform/win/TestExpectations: Skip tests that now fail instead of timing out.

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/constructors/track-event-constructor.html
LayoutTests/http/tests/security/text-track-crossorigin.html
LayoutTests/media/track/track-add-track-expected.txt
LayoutTests/media/track/track-add-track.html
LayoutTests/media/track/track-element-load-event-expected.txt [new file with mode: 0644]
LayoutTests/media/track/track-element-load-event.html [new file with mode: 0644]
LayoutTests/media/track/track-load-from-src-readyState.html
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/qt/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLTrackElement.cpp
Source/WebCore/html/HTMLTrackElement.h
Source/WebCore/html/track/TextTrack.cpp
Source/WebCore/html/track/TextTrack.h

index b809e2a..9ab8659 100644 (file)
@@ -1,3 +1,36 @@
+2012-12-20  Antoine Quint  <graouts@apple.com>
+
+        onload callback for <track> element attached to <video> does not fire
+        https://bugs.webkit.org/show_bug.cgi?id=103258
+
+        Reviewed by Eric Carlson.
+
+        As a result of fixing this bug, a few new failures were uncovered and TestExpectations
+        needed to be updated to take this into account. Additionally, some existing tests were
+        incorrect or outdated and were fixed as well. Finally, a new test was added to thoroughly
+        test the various conditions required for a <track> element to successfully load.
+
+        * fast/events/constructors/track-event-constructor.html: Update the test to correctly set
+        a non-disabled mode on the text track such that it may load per the rules enforced with this patch.
+        * http/tests/security/text-track-crossorigin.html: Update the test to correctly set a non-disabled
+        mode on the text track such that it may load per the rules enforced with this patch.
+        * media/track/track-add-track-expected.txt: Update the output to match changes made to test.
+        * media/track/track-add-track.html: Update the test to correctly set a non-disabled mode on
+        the text track such that it may load per the rules enforced with this patch. Also, ensure
+        the .readyState of the text track is correctly assumed to be NONE vs. LOADING as it would
+        have to wait until the next run loop to be changed to anything but NONE.
+        * media/track/track-element-load-event-expected.txt: Added.
+        * media/track/track-element-load-event.html: Added.
+        * media/track/track-load-from-src-readyState.html: Update the test to correctly set a
+        non-disabled mode on the text track such that it may load per the rules enforced with
+        this patch.
+        * platform/chromium/TestExpectations: Skip tests that now fail instead of timing out.
+        * platform/efl/TestExpectations: Skip tests that now fail instead of timing out.
+        * platform/gtk/TestExpectations: Skip tests that now fail instead of timing out.
+        * platform/mac/TestExpectations: Skip tests that now fail instead of timing out.
+        * platform/qt/TestExpectations: Skip tests that now fail instead of timing out.
+        * platform/win/TestExpectations: Skip tests that now fail instead of timing out.
+
 2012-12-20  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: Layout test showing delete database getting two blocked events
index 59736b5..b69d01e 100644 (file)
@@ -55,6 +55,7 @@
 
         trackElement = document.createElement('track');
         video.appendChild(trackElement);
+        trackElement.track.mode = "hidden";
         trackElement.addEventListener('load', test);
         trackElement.src='data:text/vtt,WEBVTT FILE \r\r1\r00:00:00.000 --> 00:00:30.500\ronly one caption';
 
index 69d8578..f9d7f02 100644 (file)
@@ -79,6 +79,7 @@
             function start()
             {
                 trackElement = document.querySelectorAll('track')[0];
+                trackElement.track.mode = "hidden";
                 log('Loading <b>without</b> Access-Control-Allow-Origin header, no "crossorigin" attribute on &lt;video&gt;');
                 var url = "http://localhost:8000/security/resources/captions-with-access-control-headers.php"
                 trackElement.setAttribute('src', url);
index a2b8ab5..fdb351d 100644 (file)
@@ -4,8 +4,9 @@ Tests that the 'addtrack' event is fired when a TextTrack is created.
 RUN(trackElement = document.createElement('track'))
 RUN(video.appendChild(trackElement))
 RUN(trackElement.src = 'captions-webvtt/tc004-webvtt-file.vtt')
+RUN(trackElement.track.mode = 'hidden')
 EXPECTED (video.textTracks.length == '1') OK
-EXPECTED (trackElement.readyState == '1') OK
+EXPECTED (trackElement.readyState == '0') OK
 EVENT(addtrack)
 EXPECTED (event.target == '[object TextTrackList]') OK
 EXPECTED (event instanceof window.TrackEvent == 'true') OK
index e118c59..a01cc3c 100644 (file)
@@ -41,8 +41,9 @@
                 video.textTracks.addEventListener("addtrack", trackAdded);
 
                 run("trackElement.src = 'captions-webvtt/tc004-webvtt-file.vtt'");
+                run("trackElement.track.mode = 'hidden'");
                 testExpected("video.textTracks.length", 1);
-                testExpected("trackElement.readyState", HTMLTrackElement.LOADING);
+                testExpected("trackElement.readyState", HTMLTrackElement.NONE);
             }
 
         </script>
diff --git a/LayoutTests/media/track/track-element-load-event-expected.txt b/LayoutTests/media/track/track-element-load-event-expected.txt
new file mode 100644 (file)
index 0000000..cb2b796
--- /dev/null
@@ -0,0 +1,8 @@
+PASS Load event on the track element, src / mode / append 
+PASS Load event on the track element, src / append / mode 
+PASS Load event on the track element, mode / append / src 
+PASS Load event on the track element, mode / src / append 
+PASS Load event on the track element, append / src / mode 
+PASS Load event on the track element, append / mode / src 
+
diff --git a/LayoutTests/media/track/track-element-load-event.html b/LayoutTests/media/track/track-element-load-event.html
new file mode 100644 (file)
index 0000000..c4ed102
--- /dev/null
@@ -0,0 +1,73 @@
+<!doctype html>
+<html>
+    <head>
+        <title>Load event on the track element</title>
+        <script src="../../resources/testharness.js"></script>
+        <script src="../../resources/testharnessreport.js"></script>
+    </head>
+    <body>
+        <div id="log"></div>
+        <script type="text/javascript">
+
+            var video;
+
+            // Setup
+
+            setup(function(){
+                video = document.createElement('video');
+                document.body.appendChild(video);
+            }, {timeout: 5000});
+
+            // Tests
+            testCommands(["src", "mode", "append"]);
+            testCommands(["src", "append", "mode"]);
+            testCommands(["mode", "append", "src"]);
+            testCommands(["mode", "src", "append"]);
+            testCommands(["append", "src", "mode"]);
+            testCommands(["append", "mode", "src"]);
+
+            // Utilities
+
+            function testCommands(commands)
+            {
+                var t = async_test(document.title + ", " + commands.join(" / "));
+                t.step(function()
+                {
+                    var count = 0;
+                    // Create the default <track> element.
+                    var track = document.createElement('track');
+                    track.kind = "subtitles";
+                    // Add the "load" event listener.
+                    track.addEventListener("load", t.step_func(function(event)
+                    {
+                        // Clean up for next test.
+                        video.removeChild(track);
+
+                        // Ensure we only got the event after all commands ran.
+                        if (count === commands.length)
+                            t.done();
+                    }));
+                    // Run each command.
+                    commands.forEach(function(command)
+                    {
+                        count++;
+                        runCommand(track, command);
+                    });
+                });
+            };
+
+            function runCommand(track, command)
+            {
+                if (command === "src")
+                    track.src = "data:text/vtt," + encodeURIComponent("WEBVTT\n\n00:00:00.000 --> 00:00:01.000\ntest\n");
+
+                if (command === "mode")
+                    track.track.mode = 'hidden';
+
+                if (command === "append")
+                    video.appendChild(track);
+            };
+
+        </script>
+    </body>
+</html>
index e2d9086..cfe0ac0 100644 (file)
@@ -24,7 +24,7 @@
             testExpected("track.readyState", HTMLTrackElement.NONE);
             track.addEventListener("load", function () { trackLoaded(); }, true);
             track.src = "captions-webvtt/tc004-webvtt-file.vtt";   
-            track.mode = "hidden";
+            track.track.mode = "hidden";
 
         </script>
     </body>
index f2e8ee8..721ac70 100644 (file)
@@ -3013,6 +3013,12 @@ webkit.org/b/103926 media/track/opera/track/webvtt/parsing-cue-data/tests/tree-b
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/cue_font_size_transition.html [ Skip ]
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/voice_with_evil_timestamp.html [ Skip ]
 
+# After fixing webkit.org/b/103258, these tests fail when they used to simply timeout.
+# At any rate, there is no regression, just a different type of failure.
+webkit.org/b/105536 media/track/opera/interfaces/TextTrack/addCue.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/endTime.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/startTime.html [ Failure ]
+
 webkit.org/b/72271 [ SnowLeopard Debug ] fast/dom/node-iterator-reference-node-moved-crash.html [ Crash Pass ]
 
 webkit.org/b/72376 [ Win ] fast/forms/file/input-file-label.html [ Failure Pass ]
index 7cfbda3..10d8128 100644 (file)
@@ -790,6 +790,12 @@ webkit.org/b/103926 media/track/opera/track/webvtt/parsing-cue-data/tests/tree-b
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/cue_font_size_transition.html [ Skip ]
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/voice_with_evil_timestamp.html [ Skip ]
 
+# After fixing webkit.org/b/103258, these tests fail when they used to simply timeout.
+# At any rate, there is no regression, just a different type of failure.
+webkit.org/b/105536 media/track/opera/interfaces/TextTrack/addCue.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/endTime.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/startTime.html [ Failure ]
+
 webkit.org/b/100636 [ Debug ] jquery/traversing.html [ Failure Crash Pass ]
 
 webkit.org/b/102928 svg/foreignObject/viewport-foreignobject-crash.html [ Crash Failure Pass ]
index 579ca7e..7a975ea 100644 (file)
@@ -493,6 +493,12 @@ webkit.org/b/103926 media/track/opera/track/webvtt/parsing-cue-data/tests/tree-b
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/cue_font_size_transition.html [ Skip ]
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/voice_with_evil_timestamp.html [ Skip ]
 
+# After fixing webkit.org/b/103258, these tests fail when they used to simply timeout.
+# At any rate, there is no regression, just a different type of failure.
+webkit.org/b/105536 media/track/opera/interfaces/TextTrack/addCue.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/endTime.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/startTime.html [ Failure ]
+
 # No support for exposing in-band text tracks
 webkit.org/b/103771 media/track/track-in-band.html [ Failure ]
 webkit.org/b/103771 media/track/track-in-band-cues-added-once.html [ Timeout ]
index 57267d0..9834ab3 100644 (file)
@@ -474,7 +474,6 @@ media/track/track-cue-rendering-vertical.html
 media/track/track-webvtt-tc028-unsupported-markup.html
 
 # Opera-submitted tests to W3C for <track>, a lot of failures still.
-# Opera-submitted tests to W3C for <track>, a lot of failures still.
 webkit.org/b/103926 media/track/opera/idl/media-idl-tests.html [ Skip ]
 webkit.org/b/103926 media/track/opera/interfaces/HTMLElement/HTMLMediaElement/crossOrigin.html [ Skip ]
 webkit.org/b/103926 media/track/opera/interfaces/HTMLElement/HTMLTrackElement/kind.html [ Skip ]
@@ -508,6 +507,12 @@ webkit.org/b/103926 media/track/opera/track/webvtt/parsing-cue-data/tests/tree-b
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/cue_font_size_transition.html [ Skip ]
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/voice_with_evil_timestamp.html [ Skip ]
 
+# After fixing webkit.org/b/103258, these tests fail when they used to simply timeout.
+# At any rate, there is no regression, just a different type of failure.
+webkit.org/b/105536 media/track/opera/interfaces/TextTrack/addCue.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/endTime.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/startTime.html [ Failure ]
+
 # Tests for MediaSource API. Feature is not yet functional.
 # https://bugs.webkit.org/show_bug.cgi?id=64731
 http/tests/media/media-source/
index 4b38285..7fee55f 100644 (file)
@@ -927,6 +927,12 @@ webkit.org/b/103926 media/track/opera/track/webvtt/parsing-cue-data/tests/tree-b
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/cue_font_size_transition.html [ Skip ]
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/voice_with_evil_timestamp.html [ Skip ]
 
+# After fixing webkit.org/b/103258, these tests fail when they used to simply timeout.
+# At any rate, there is no regression, just a different type of failure.
+webkit.org/b/105536 media/track/opera/interfaces/TextTrack/addCue.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/endTime.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/startTime.html [ Failure ]
+
 # https://bugs.webkit.org/show_bug.cgi?id=38376
 media/media-document-audio-size.html
 
index 8fef5d1..e91cf37 100644 (file)
@@ -1585,6 +1585,12 @@ webkit.org/b/103926 media/track/opera/track/webvtt/parsing-cue-data/tests/tree-b
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/cue_font_size_transition.html [ Skip ]
 webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/voice_with_evil_timestamp.html [ Skip ]
 
+# After fixing webkit.org/b/103258, these tests fail when they used to simply timeout.
+# At any rate, there is no regression, just a different type of failure.
+webkit.org/b/105536 media/track/opera/interfaces/TextTrack/addCue.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/endTime.html [ Failure ]
+webkit.org/b/105536 media/track/opera/interfaces/TextTrackCue/startTime.html [ Failure ]
+
 # Tests for MediaSource API. Feature is not yet functional.
 # https://bugs.webkit.org/show_bug.cgi?id=64731
 http/tests/media/media-source/
index ccaec09..6a10b65 100644 (file)
@@ -1,3 +1,46 @@
+2012-12-20  Antoine Quint  <graouts@apple.com>
+
+        onload callback for <track> element attached to <video> does not fire
+        https://bugs.webkit.org/show_bug.cgi?id=103258
+
+        Reviewed by Eric Carlson.
+
+        We now correctly implement the track processing model per the latest spec at
+        http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#start-the-track-processing-model.
+        
+        For a <track> to load, three conditions must be met:
+        
+        1. it must have a non-empty src
+        2. it must have a mode other than "disabled" (the default)
+        3. it must have a parent media element
+        
+        We used to only check if we were able to load upon setting the track's src,
+        whereas a change of any of those conditions should have done this, which this
+        patch now correctly implements.
+        
+        We also correctly implement the load model asynchronously after step 4, per
+        the spec, hence the split of the code previously entirely contained in
+        HTMLTrackElement::scheduleLoad() in another method fired on a timer.
+
+        Test: media/track/track-element-load-event.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::textTrackModeChanged):
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::HTMLTrackElement):
+        (WebCore::HTMLTrackElement::insertedInto):
+        (WebCore::HTMLTrackElement::parseAttribute):
+        (WebCore::HTMLTrackElement::scheduleLoad):
+        (WebCore):
+        (WebCore::HTMLTrackElement::loadTimerFired):
+        (WebCore::HTMLTrackElement::textTrackModeChanged):
+        * html/HTMLTrackElement.h:
+        * html/track/TextTrack.cpp:
+        (WebCore::TextTrack::removeAllCues):
+        (WebCore):
+        * html/track/TextTrack.h:
+        (TextTrack):
+
 2012-12-20  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: Layout test showing delete database getting two blocked events
index 4e9125b..fb35fb9 100644 (file)
@@ -1351,8 +1351,6 @@ void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
             if (track->mode() != TextTrack::disabledKeyword()) {
                 if (trackElement->readyState() == HTMLTrackElement::LOADED)
                     textTrackAddCues(track, track->cues());
-                else if (trackElement->readyState() == HTMLTrackElement::NONE)
-                    trackElement->scheduleLoad();
 
                 // If this is the first added track, create the list of text tracks.
                 if (!m_textTracks)
index cd99dc4..89e7152 100644 (file)
@@ -56,6 +56,7 @@ static String urlForLoggingTrack(const KURL& url)
     
 inline HTMLTrackElement::HTMLTrackElement(const QualifiedName& tagName, Document* document)
     : HTMLElement(tagName, document)
+    , m_loadTimer(this, &HTMLTrackElement::loadTimerFired)
 {
     LOG(Media, "HTMLTrackElement::HTMLTrackElement - %p", this);
     ASSERT(hasTagName(trackTag));
@@ -74,6 +75,9 @@ PassRefPtr<HTMLTrackElement> HTMLTrackElement::create(const QualifiedName& tagNa
 
 Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode* insertionPoint)
 {
+    // Since we've moved to a new parent, we may now be able to load.
+    scheduleLoad();
+
     HTMLElement::insertedInto(insertionPoint);
     HTMLMediaElement* parent = mediaElement();
     if (insertionPoint == parent)
@@ -92,10 +96,13 @@ void HTMLTrackElement::parseAttribute(const QualifiedName& name, const AtomicStr
 {
     if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) {
         if (name == srcAttr) {
-            if (!value.isEmpty() && mediaElement())
+            if (!value.isEmpty())
                 scheduleLoad();
-            // 4.8.10.12.3 Sourcing out-of-band text tracks
-            // As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly...
+            else if (m_track)
+                m_track->removeAllCues();
+
+        // 4.8.10.12.3 Sourcing out-of-band text tracks
+        // As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly...
         } else if (name == kindAttr)
             track()->setKind(value.lower());
         else if (name == labelAttr)
@@ -188,21 +195,39 @@ bool HTMLTrackElement::isURLAttribute(const Attribute& attribute) const
 
 void HTMLTrackElement::scheduleLoad()
 {
+    // 1. If another occurrence of this algorithm is already running for this text track and its track element,
+    // abort these steps, letting that other algorithm take care of this element.
+    if (m_loadTimer.isActive())
+        return;
+
     if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled())
         return;
 
+    // 2. If the text track's text track mode is not set to one of hidden or showing, abort these steps.
+    if (ensureTrack()->mode() != TextTrack::hiddenKeyword() && ensureTrack()->mode() != TextTrack::showingKeyword())
+        return;
+
+    // 3. If the text track's track element does not have a media element as a parent, abort these steps.
     if (!mediaElement())
         return;
 
+    // 4. Run the remainder of these steps asynchronously, allowing whatever caused these steps to run to continue.
+    m_loadTimer.startOneShot(0);
+}
+
+void HTMLTrackElement::loadTimerFired(Timer<HTMLTrackElement>*)
+{
     if (!fastHasAttribute(srcAttr))
         return;
 
-    // 4.8.10.12.3 Sourcing out-of-band text tracks
-
-    // 1. Set the text track readiness state to loading.
+    // 6. Set the text track readiness state to loading.
     setReadyState(HTMLTrackElement::LOADING);
 
+    // 7. Let URL be the track URL of the track element.
     KURL url = getNonEmptyURLAttribute(srcAttr);
+
+    // 8. If the track element's parent is a media element then let CORS mode be the state of the parent media
+    // element's crossorigin content attribute. Otherwise, let CORS mode be No CORS.
     if (!canLoadUrl(url)) {
         didCompleteLoad(ensureTrack(), HTMLTrackElement::Failure);
         return;
@@ -302,6 +327,10 @@ void HTMLTrackElement::textTrackKindChanged(TextTrack* track)
 
 void HTMLTrackElement::textTrackModeChanged(TextTrack* track)
 {
+    // Since we've moved to a new parent, we may now be able to load.
+    if (readyState() == HTMLTrackElement::NONE)
+        scheduleLoad();
+
     if (HTMLMediaElement* parent = mediaElement())
         return parent->textTrackModeChanged(track);
 }
index 1b659ff..4b45adf 100644 (file)
@@ -79,6 +79,8 @@ private:
     virtual void removedFrom(ContainerNode*) OVERRIDE;
     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
 
+    void loadTimerFired(Timer<HTMLTrackElement>*);
+
 #if ENABLE(MICRODATA)
     virtual String itemValueText() const OVERRIDE;
     virtual void setItemValueText(const String&, ExceptionCode&) OVERRIDE;
@@ -98,6 +100,7 @@ private:
     virtual bool canLoadUrl(const KURL&);
 
     RefPtr<LoadableTextTrack> m_track;
+    Timer<HTMLTrackElement> m_loadTimer;
 };
 
 }
index f608563..5db4924 100644 (file)
@@ -201,6 +201,20 @@ TextTrackCueList* TextTrack::cues()
     return 0;
 }
 
+void TextTrack::removeAllCues()
+{
+    if (!m_cues)
+        return;
+
+    if (m_client)
+        m_client->textTrackRemoveCues(this, m_cues.get());
+    
+    for (size_t i = 0; i < m_cues->length(); ++i)
+        m_cues->item(i)->setTrack(0);
+    
+    m_cues = 0;
+}
+
 TextTrackCueList* TextTrack::activeCues() const
 {
     // 4.8.10.12.5 If the text track mode ... is not the text track disabled mode,
index 63503da..8893aed 100644 (file)
@@ -123,6 +123,8 @@ public:
     virtual bool isDefault() const { return false; }
     virtual void setIsDefault(bool) { }
 
+    void removeAllCues();
+
 protected:
     TextTrack(ScriptExecutionContext*, TextTrackClient*, const AtomicString& kind, const AtomicString& label, const AtomicString& language, TextTrackType);