Changeset 107632 in webkit


Ignore:
Timestamp:
Feb 13, 2012 4:06:25 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Chrome crashes when attempting to add cue to track element
https://bugs.webkit.org/show_bug.cgi?id=77951

Patch by Arun Patole <bmf834@motorola.com> on 2012-02-13
Reviewed by Eric Carlson.

Source/WebCore:

Allocate text track's text track list of cues before using it.

  • html/TextTrack.cpp:

(WebCore::TextTrack::cues):
(WebCore::TextTrack::addCue):
(WebCore::TextTrack::removeCue): return if text track list of cues is not allocated.
(WebCore::TextTrack::ensureTextTrackCueList):Added.

  • html/TextTrack.h:

(TextTrack):

LayoutTests:

Updated add-remove-cue.html to handle adding a new cue to the text track created with addTextTrack.

  • media/track/track-add-remove-cue-expected.txt:
  • media/track/track-add-remove-cue.html:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r107630 r107632  
     12012-02-13  Arun Patole  <bmf834@motorola.com>
     2
     3        Chrome crashes when attempting to add cue to track element
     4        https://bugs.webkit.org/show_bug.cgi?id=77951
     5
     6        Reviewed by Eric Carlson.
     7
     8        Updated add-remove-cue.html to handle adding a new cue to the text track created with addTextTrack.
     9        * media/track/track-add-remove-cue-expected.txt:
     10        * media/track/track-add-remove-cue.html:
     11
    1122012-02-13  Kenichi Ishibashi  <bashi@chromium.org>
    213
  • trunk/LayoutTests/media/track/track-add-remove-cue-expected.txt

    r101185 r107632  
    3131EXPECTED (cues[3].startTime == '61') OK
    3232
     33*** create a new cue and add it to a track created with video.addTextTrack, make sure it is inserted correctly.
     34RUN(newTrack = video.addTextTrack("subtitles", "French subtitles", "fr"))
     35RUN(newTrack.addCue(new TextTrackCue("test", 0.0, 1.0, "Test!")))
     36RUN(newCue = newTrack.cues[0])
     37EXPECTED (newCue.track == '[object TextTrack]') OK
     38EXPECTED (newCue.id == 'test') OK
     39EXPECTED (newCue.startTime == '0') OK
     40EXPECTED (newCue.endTime == '1') OK
     41EXPECTED (newCue.pauseOnExit == 'false') OK
     42EXPECTED (newCue.direction == 'horizontal') OK
     43EXPECTED (newCue.snapToLines == 'true') OK
     44EXPECTED (newCue.linePosition == '-1') OK
     45EXPECTED (newCue.textPosition == '50') OK
     46EXPECTED (newCue.size == '100') OK
     47EXPECTED (newCue.alignment == 'middle') OK
     48
    3349*** Remove a cue created with addCue().
    3450RUN(testTrack.track.removeCue(textCue))
  • trunk/LayoutTests/media/track/track-add-remove-cue.html

    r102212 r107632  
    4444                testExpected("cues[3].startTime", 61);
    4545
     46                consoleWrite("<br>*** create a new cue and add it to a track created with video.addTextTrack, make sure it is inserted correctly.");
     47                findMediaElement();
     48                run('newTrack = video.addTextTrack("subtitles", "French subtitles", "fr")');
     49                newTrack.mode = 2;
     50                run('newTrack.addCue(new TextTrackCue("test", 0.0, 1.0, "Test!"))');
     51                run('newCue = newTrack.cues[0]');
     52                testExpected("newCue.track", newTrack);
     53                testExpected("newCue.id", "test");
     54                testExpected("newCue.startTime", 0.0);
     55                testExpected("newCue.endTime", 1.0);
     56                testExpected("newCue.pauseOnExit", false);
     57                testExpected("newCue.direction", "horizontal");
     58                testExpected("newCue.snapToLines", true);
     59                testExpected("newCue.linePosition", -1);
     60                testExpected("newCue.textPosition", 50);
     61                testExpected("newCue.size", 100);
     62                testExpected("newCue.alignment", "middle");
     63
    4664                consoleWrite("<br>*** Remove a cue created with addCue().");
    4765                run("testTrack.track.removeCue(textCue)");
  • trunk/Source/WebCore/ChangeLog

    r107629 r107632  
     12012-02-13  Arun Patole  <bmf834@motorola.com>
     2
     3        Chrome crashes when attempting to add cue to track element
     4        https://bugs.webkit.org/show_bug.cgi?id=77951
     5
     6        Reviewed by Eric Carlson.
     7
     8        Allocate text track's text track list of cues before using it.
     9
     10        * html/TextTrack.cpp:
     11        (WebCore::TextTrack::cues):
     12        (WebCore::TextTrack::addCue):
     13        (WebCore::TextTrack::removeCue): return if text track list of cues is not allocated.
     14        (WebCore::TextTrack::ensureTextTrackCueList):Added.
     15        * html/TextTrack.h:
     16        (TextTrack):
     17
    1182012-02-13  Andy Estes  <aestes@apple.com>
    219
  • trunk/Source/WebCore/html/TextTrack.cpp

    r104327 r107632  
    156156TextTrackCueList* TextTrack::cues()
    157157{
    158     if (!m_cues)
    159         m_cues = TextTrackCueList::create();   
    160 
    161158    // 4.8.10.12.5 If the text track mode ... is not the text track disabled mode,
    162159    // then the cues attribute must return a live TextTrackCueList object ...
     
    164161    // same object must be returned each time.
    165162    // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-cues
    166     if (m_cues && m_mode != TextTrack::DISABLED)
    167         return m_cues.get();
     163    if (m_mode != TextTrack::DISABLED)
     164        return ensureTextTrackCueList();
    168165    return 0;
    169166}
     
    209206    // track's text track list of cues, then throw an InvalidStateError exception.
    210207    // 4. Add cue to the method's TextTrack object's text track's text track list of cues.
    211     if (!m_cues->add(cue)) {
     208    if (!ensureTextTrackCueList()->add(cue)) {
    212209        ec = INVALID_STATE_ERR;
    213210        return;
     
    237234    // object's text track's text track list of cues, then throw a NotFoundError exception.
    238235    // 3. Remove cue from the method's TextTrack object's text track's text track list of cues.
    239     if (!m_cues->remove(cue)) {
     236    if (!m_cues || !m_cues->remove(cue)) {
    240237        ec = INVALID_STATE_ERR;
    241238        return;
     
    272269}
    273270
     271TextTrackCueList* TextTrack::ensureTextTrackCueList()
     272{
     273    if (!m_cues)
     274        m_cues = TextTrackCueList::create();
     275
     276    return m_cues.get();
     277}
     278
    274279} // namespace WebCore
    275280
  • trunk/Source/WebCore/html/TextTrack.h

    r104327 r107632  
    115115
    116116private:
     117    TextTrackCueList* ensureTextTrackCueList();
    117118    HTMLMediaElement* m_mediaElement;
    118119    String m_kind;
Note: See TracChangeset for help on using the changeset viewer.