In-band captions not visible immediately after track mode change
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2013 21:11:51 +0000 (21:11 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2013 21:11:51 +0000 (21:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=115922

Reviewed by Dean Jackson.

Source/WebCore:

Test: media/track/track-in-band-mode.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::textTrackModeChanged): Add cues for all loaded tracks, regardless
    of track type.

LayoutTests:

* media/track/track-in-band-mode-expected.txt: Added.
* media/track/track-in-band-mode.html: Added.

* platform/efl/TestExpectations: Skip new test.
* platform/gtk/TestExpectations: Ditto.
* platform/mac/TestExpectations: Ditto.
* platform/qt/TestExpectations: Ditto.
* platform/win/TestExpectations: Ditto.

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

LayoutTests/ChangeLog
LayoutTests/media/track/track-in-band-mode-expected.txt [new file with mode: 0644]
LayoutTests/media/track/track-in-band-mode.html [new file with mode: 0644]
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

index f649c69..8850853 100644 (file)
@@ -1,3 +1,19 @@
+2013-05-10  Eric Carlson  <eric.carlson@apple.com>
+
+        In-band captions not visible immediately after track mode change
+        https://bugs.webkit.org/show_bug.cgi?id=115922
+
+        Reviewed by Dean Jackson.
+
+        * media/track/track-in-band-mode-expected.txt: Added.
+        * media/track/track-in-band-mode.html: Added.
+
+        * platform/efl/TestExpectations: Skip new test.
+        * platform/gtk/TestExpectations: Ditto.
+        * platform/mac/TestExpectations: Ditto.
+        * platform/qt/TestExpectations: Ditto.
+        * platform/win/TestExpectations: Ditto.
+
 2013-05-10  Roger Fong  <roger_fong@apple.com>
 
         Unreviewed mac-lion rebaselines.
diff --git a/LayoutTests/media/track/track-in-band-mode-expected.txt b/LayoutTests/media/track/track-in-band-mode-expected.txt
new file mode 100644 (file)
index 0000000..b645b20
--- /dev/null
@@ -0,0 +1,24 @@
+Test that cues from in-band tracks are displayed immediately when a track is made visible.
+
+EVENT(canplaythrough)
+
+** Check initial in-band track states
+RUN(inbandTrack1 = video.textTracks[0])
+EXPECTED (video.textTracks.length == '1') OK
+EXPECTED (inbandTrack1.language == 'en') OK
+EXPECTED (inbandTrack1.kind == 'captions') OK
+
+** A hidden track should not have visible cues
+RUN(inbandTrack1.mode = 'hidden')
+EXPECTED (inbandTrack1.activeCues.length == '0') OK
+RUN(video.play())
+EVENT(seeked)
+No text track cue with display id 'cue' is currently visible
+
+** Showing a track should show active cues immediately
+RUN(inbandTrack1.mode = 'showing')
+EXPECTED (textTrackDisplayElement(video, 'cue').textContent != 'null') OK
+EXPECTED (inbandTrack1.activeCues.length == '1') OK
+
+END OF TEST
+
diff --git a/LayoutTests/media/track/track-in-band-mode.html b/LayoutTests/media/track/track-in-band-mode.html
new file mode 100644 (file)
index 0000000..def0ac0
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>In-band track cues displayed immediately</title>
+
+        <script src=../media-file.js></script>
+        <script src=../video-test.js></script>
+        <script src=../media-controls.js></script>
+        <script>
+
+            function seeked()
+            {
+                testExpected("textTrackDisplayElement(video, 'cue')", null);
+
+                consoleWrite("<br><i>** Showing a track should show active cues immediately<" + "/i>");
+                run("inbandTrack1.mode = 'showing'");
+
+                testExpected("textTrackDisplayElement(video, 'cue').textContent", null, '!=');
+                testExpected("inbandTrack1.activeCues.length", 1);
+
+                consoleWrite("");
+                endTest();
+            }
+
+            function canplaythrough()
+            {
+                consoleWrite("<br><i>** Check initial in-band track states<" + "/i>");
+                run("inbandTrack1 = video.textTracks[0]");
+                testExpected("video.textTracks.length", 1);
+                testExpected("inbandTrack1.language", "en");
+                testExpected("inbandTrack1.kind", "captions");
+
+                consoleWrite("<br><i>** A hidden track should not have visible cues<" + "/i>");
+                run("inbandTrack1.mode = 'hidden'");
+                testExpected("inbandTrack1.activeCues.length", 0);
+
+                run("video.play()");
+                setTimeout(function() { video.pause(); video.currentTime = 0.5; }, 500);
+            }
+
+            function setup()
+            {
+                findMediaElement();
+                video.src = '../content/counting-captioned.mov';
+                waitForEvent('seeked', seeked);
+                waitForEvent('canplaythrough', canplaythrough);
+            }
+
+        </script>
+    </head>
+    <body onload="setup()">
+        <video controls></video>
+        <p>Test that cues from in-band tracks are displayed immediately when a track is made visible.</p>
+    </body>
+</html>
index d12efdc..983a16c 100644 (file)
@@ -1618,6 +1618,7 @@ Bug(EFL) media/track/track-in-band-cues-added-once.html [ Skip ]
 Bug(EFL) media/track/track-in-band-style.html [ Skip ]
 Bug(EFL) media/track/track-in-band-legacy-api.html [ Skip ]
 Bug(EFL) media/track/track-forced-subtitles-in-band.html [ Skip ]
+Bug(EFL) media/track/track-in-band-mode.html [ Skip ]
 
 # All debug bots timeout (crash) on this one
 webkit.org/b/56496 [ Debug ] fast/js/array-sort-modifying-tostring.html [ Crash Pass ]
index f025607..dcaff45 100644 (file)
@@ -389,6 +389,7 @@ 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 ]
 webkit.org/b/103771 media/track/track-in-band-style.html [ Timeout ]
 webkit.org/b/103771 media/track/track-in-band-legacy-api.html [ Failure ]
+webkit.org/b/103771 media/track/track-in-band-mode.html [ Skip ]
 
 #Incorrect rebaseline
 webkit.org/b/107818 media/controls-styling.html [ Failure ]
index 1c4e9db..ab2cb51 100644 (file)
@@ -1353,6 +1353,7 @@ webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band-
 webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band-style.html
 webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band-legacy-api.html
 webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-forced-subtitles-in-band.html
+webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band-mode.html
 
 # These two tests sometimes timeout
 webkit.org/b/112492 media/track/track-language-preference.html [ Failure Pass ]
index d0eeb2b..d784f9a 100644 (file)
@@ -2641,6 +2641,7 @@ webkit.org/b/103769 media/track/track-in-band-cues-added-once.html [ Skip ]
 webkit.org/b/103769 media/track/track-in-band-style.html [ Skip ]
 webkit.org/b/103769 media/track/track-in-band-legacy-api.html [ Skip ]
 webkit.org/b/103769 media/track/track-forced-subtitles-in-band.html [ Skip ]
+webkit.org/b/103769 media/track/track-in-band-mode.html [ Skip ]
 
 # [Qt] new http/tests/xmlhttprequest/post-blob-content-type-sync.html and ~async.html fail since introduced in r136893
 # https://bugs.webkit.org/show_bug.cgi?id=104352
index b54fff9..a895d20 100644 (file)
@@ -2529,6 +2529,7 @@ webkit.org/b/103770 media/track/track-in-band-cues-added-once.html [ Skip ]
 webkit.org/b/103770 media/track/track-in-band-style.html [ Skip ]
 webkit.org/b/103770 media/track/track-in-band-legacy-api.html [ Skip ]
 webkit.org/b/103770 media/track/track-forced-subtitles-in-band.html [ Skip ]
+webkit.org/b/103770 media/track/track-in-band-mode.html [ Skip ]
 
 # https://bugs.webkit.org/show_bug.cgi?id=97026
 fast/events/keydown-leftright-keys.html
index 2a8acc3..5e5411b 100644 (file)
@@ -1,3 +1,16 @@
+2013-05-10  Eric Carlson  <eric.carlson@apple.com>
+
+        In-band captions not visible immediately after track mode change
+        https://bugs.webkit.org/show_bug.cgi?id=115922
+
+        Reviewed by Dean Jackson.
+
+        Test: media/track/track-in-band-mode.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::textTrackModeChanged): Add cues for all loaded tracks, regardless
+            of track type.
+
 2013-05-10  Timothy Hatcher  <timothy@apple.com>
 
         Web Inspector: determine the resource type in InspectorResourceAgent::willSendRequest.
index 27a0b57..b2922e8 100644 (file)
@@ -1388,34 +1388,32 @@ void HTMLMediaElement::audioTrackEnabledChanged(AudioTrack*)
 
 void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
 {
+    bool trackIsLoaded = true;
     if (track->trackType() == TextTrack::TrackElement) {
-        // 4.8.10.12.3 Sourcing out-of-band text tracks
-        // ... when a text track corresponding to a track element is created with text track
-        // mode set to disabled and subsequently changes its text track mode to hidden, showing,
-        // or showing by default for the first time, the user agent must immediately and synchronously
-        // run the following algorithm ...
-
+        trackIsLoaded = false;
         for (Node* node = firstChild(); node; node = node->nextSibling()) {
             if (!node->hasTagName(trackTag))
                 continue;
+
             HTMLTrackElement* trackElement = static_cast<HTMLTrackElement*>(node);
-            if (trackElement->track() != track)
-                continue;
-            
-            // Mark this track as "configured" so configureTextTracks won't change the mode again.
-            track->setHasBeenConfigured(true);
-            if (track->mode() != TextTrack::disabledKeyword()) {
-                if (trackElement->readyState() == HTMLTrackElement::LOADED)
-                    textTrackAddCues(track, track->cues());
-
-                // If this is the first added track, create the list of text tracks.
-                if (!m_textTracks)
-                  m_textTracks = TextTrackList::create(this, ActiveDOMObject::scriptExecutionContext());
+            if (trackElement->track() == track) {
+                if (trackElement->readyState() == HTMLTrackElement::LOADING || trackElement->readyState() == HTMLTrackElement::LOADED)
+                    trackIsLoaded = true;
+                break;
             }
-            break;
         }
     }
 
+    // If this is the first added track, create the list of text tracks.
+    if (!m_textTracks)
+        m_textTracks = TextTrackList::create(this, ActiveDOMObject::scriptExecutionContext());
+    
+    // Mark this track as "configured" so configureTextTracks won't change the mode again.
+    track->setHasBeenConfigured(true);
+    
+    if (track->mode() != TextTrack::disabledKeyword() && trackIsLoaded)
+        textTrackAddCues(track, track->cues());
+
 #if USE(PLATFORM_TEXT_TRACK_MENU)
     if (platformTextTrackMenu())
         platformTextTrackMenu()->trackWasSelected(track->platformTextTrack());