Changeset 221155 in webkit


Ignore:
Timestamp:
Aug 24, 2017 12:44:20 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

HTMLTrackElement behavior violates the standard
https://bugs.webkit.org/show_bug.cgi?id=175888

Patch by Kirill Ovchinnikov <kirill.ovchinn@gmail.com> on 2017-08-24
Reviewed by Eric Carlson.

Source/WebCore:

Test: media/track/text-track-src-change.html: added asserts

  • html/HTMLTrackElement.cpp:

(WebCore::HTMLTrackElement::parseAttribute):
(WebCore::HTMLTrackElement::loadTimerFired):

  • html/track/LoadableTextTrack.cpp:

(WebCore::LoadableTextTrack::scheduleLoad):

  • html/track/TextTrack.cpp:

(WebCore::TextTrack::removeAllCues):

  • html/track/TextTrackCueList.cpp:

(WebCore::TextTrackCueList::removeAll):

  • html/track/TextTrackCueList.h:

LayoutTests:

  • media/track/text-track-src-change-expected.txt:
  • media/track/text-track-src-change.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r221150 r221155  
     12017-08-24  Kirill Ovchinnikov  <kirill.ovchinn@gmail.com>
     2
     3        HTMLTrackElement behavior violates the standard
     4        https://bugs.webkit.org/show_bug.cgi?id=175888
     5
     6        Reviewed by Eric Carlson.
     7
     8        * media/track/text-track-src-change-expected.txt:
     9        * media/track/text-track-src-change.html:
     10
    1112017-08-24  Jonathan Bedard  <jbedard@apple.com>
    212
  • trunk/LayoutTests/media/track/text-track-src-change-expected.txt

    r220472 r221155  
    88*** Changing 'src' attribute...
    99EXPECTED (cues.length == '100') OK
     10EXPECTED (cues === testTrack.track.cues == 'true') OK
    1011
    1112*** Changing back 'src' attribute...
     13EXPECTED (cues === testTrack.track.cues == 'true') OK
    1214EXPECTED (cues.length == '4') OK
     15
     16*** Setting 'src' to the same value...
     17EXPECTED (cues === testTrack.track.cues == 'true') OK
     18EXPECTED (cues.length == '4') OK
     19
     20*** Setting 'src' to an empty value...
     21EXPECTED (stage == '5') OK
     22EXPECTED (true == 'true') OK
     23EXPECTED (cues.length == '0') OK
    1324END OF TEST
    1425
  • trunk/LayoutTests/media/track/text-track-src-change.html

    r220472 r221155  
    88        <script>
    99            var stage = 0;
     10            var errorEventTimer = null;
    1011
    11             function trackLoaded()
     12            function loadedTrackTest()
    1213            {
    1314                var testTrack = document.getElementById('testTrack');
     
    2223                        break;
    2324                    case 1:
    24                         cues = testTrack.track.cues;
    2525                        testExpected("cues.length", 100);
     26                        testExpected("cues === testTrack.track.cues", true);
    2627                        consoleWrite("<br>*** Changing back 'src' attribute...");
    2728                        ++stage;
     
    2930                        break;
    3031                    case 2:
    31                         cues = testTrack.track.cues;
     32                        testExpected("cues === testTrack.track.cues", true);
    3233                        testExpected("cues.length", 4);
    33                         endTest();
     34                        consoleWrite("<br>*** Setting 'src' to the same value...");
     35                        ++stage;
     36                        testTrack.src = "captions-webvtt/tc013-settings.vtt";
     37                        // Let's ensure that 'load' event is not fired after that
     38                        // - it should jump directly to the stage 4 instead of stage 3
     39                        setTimeout(function() { ++stage; loadedTrackTest(); }, 100);
     40                        break;
     41                    case 3:
     42                        failTest("'load' event should not be fired after setting the same URL");
     43                        break;
     44                    case 4:
     45                        testExpected("cues === testTrack.track.cues", true);
     46                        testExpected("cues.length", 4);
     47                        consoleWrite("<br>*** Setting 'src' to an empty value...");
     48                        ++stage;
     49                        testTrack.src = ""; // this should fire 'error' event
     50                        errorEventTimer = setTimeout(function() {
     51                                failTest("'error' event didn't fire after setting an empty URL");
     52                            }, 10000);
     53                        break;
     54                    case 5:
     55                        failTest("'load' event should not be fired after setting an empty URL");
    3456                        break;
    3557                }
    3658            }
     59
     60            function trackLoadFailed()
     61            {
     62                clearTimeout(errorEventTimer);
     63                testExpected("stage", 5);
     64                testExpected(cues === testTrack.track.cues, true);
     65                testExpected("cues.length", 0);
     66                endTest();
     67            }
     68
    3769
    3870            setCaptionDisplayMode('Automatic');
     
    4274        <p>Tests Track 'src' changing handling</p>
    4375        <video>
    44             <track id="testTrack" src="captions-webvtt/tc013-settings.vtt" kind="captions" onload="trackLoaded()" default>
     76            <track id="testTrack" src="captions-webvtt/tc013-settings.vtt" kind="captions" onload="loadedTrackTest()" onerror="trackLoadFailed()" default>
    4577        </video>
    4678    </body>
  • trunk/Source/WebCore/ChangeLog

    r221152 r221155  
     12017-08-24  Kirill Ovchinnikov  <kirill.ovchinn@gmail.com>
     2
     3        HTMLTrackElement behavior violates the standard
     4        https://bugs.webkit.org/show_bug.cgi?id=175888
     5
     6        Reviewed by Eric Carlson.
     7
     8        Test: media/track/text-track-src-change.html: added asserts
     9
     10        * html/HTMLTrackElement.cpp:
     11        (WebCore::HTMLTrackElement::parseAttribute):
     12        (WebCore::HTMLTrackElement::loadTimerFired):
     13        * html/track/LoadableTextTrack.cpp:
     14        (WebCore::LoadableTextTrack::scheduleLoad):
     15        * html/track/TextTrack.cpp:
     16        (WebCore::TextTrack::removeAllCues):
     17        * html/track/TextTrackCueList.cpp:
     18        (WebCore::TextTrackCueList::removeAll):
     19        * html/track/TextTrackCueList.h:
     20
    1212017-08-24  David Kilzer  <ddkilzer@apple.com>
    222
  • trunk/Source/WebCore/html/HTMLTrackElement.cpp

    r220472 r221155  
    101101{
    102102    if (name == srcAttr) {
    103         if (!value.isEmpty())
    104             scheduleLoad();
    105         else if (m_track)
    106             m_track->removeAllCues();
     103        scheduleLoad();
    107104
    108105    // 4.8.10.12.3 Sourcing out-of-band text tracks
     
    187184void HTMLTrackElement::loadTimerFired()
    188185{
    189     if (!hasAttributeWithoutSynchronization(srcAttr))
    190         return;
     186    if (!hasAttributeWithoutSynchronization(srcAttr)) {
     187        track().removeAllCues();
     188        return;
     189    }
    191190
    192191    // 6. Set the text track readiness state to loading.
     
    196195    URL url = getNonEmptyURLAttribute(srcAttr);
    197196
     197    // ... if URL is the empty string, then queue a task to first change the text track readiness state
     198    // to failed to load and then fire an event named error at the track element.
    198199    // 8. If the track element's parent is a media element then let CORS mode be the state of the parent media
    199200    // element's crossorigin content attribute. Otherwise, let CORS mode be No CORS.
    200     if (!canLoadURL(url)) {
     201    if (url.isEmpty() || !canLoadURL(url)) {
     202        track().removeAllCues();
    201203        didCompleteLoad(HTMLTrackElement::Failure);
    202204        return;
    203205    }
    204 
    205     // When src attribute is changed we need to flush all collected track data
    206     if (m_track)
    207         m_track->removeAllCues();
    208206
    209207    track().scheduleLoad(url);
  • trunk/Source/WebCore/html/track/LoadableTextTrack.cpp

    r219237 r221155  
    4848    if (url == m_url)
    4949        return;
     50
     51    // When src attribute is changed we need to flush all collected track data
     52    removeAllCues();
    5053
    5154    // 4.8.10.12.3 Sourcing out-of-band text tracks (continued)
  • trunk/Source/WebCore/html/track/TextTrack.cpp

    r219856 r221155  
    270270        m_cues->item(i)->setTrack(nullptr);
    271271   
    272     m_cues = nullptr;
     272    m_cues->clear();
    273273}
    274274
  • trunk/Source/WebCore/html/track/TextTrackCueList.cpp

    r210319 r221155  
    107107}
    108108
     109void TextTrackCueList::clear()
     110{
     111    m_vector.clear();
     112    if (m_activeCues)
     113        m_activeCues->m_vector.clear();
     114}
     115
    109116void TextTrackCueList::updateCueIndex(TextTrackCue& cue)
    110117{
  • trunk/Source/WebCore/html/track/TextTrackCueList.h

    r210319 r221155  
    4747    void updateCueIndex(TextTrackCue&);
    4848
     49    void clear();
     50
    4951    TextTrackCueList& activeCues();
    5052
Note: See TracChangeset for help on using the changeset viewer.