Bug 891381 - Tracks loaded via TrackElement should have the same id as the TrackElement. r=cpearce

This commit is contained in:
Rick Eyre 2014-03-19 11:27:39 -04:00
parent c46a46e0fa
commit a0b716dca0
3 changed files with 16 additions and 9 deletions

View File

@ -95,6 +95,16 @@ TextTrack::SetMode(TextTrackMode aValue)
}
}
void
TextTrack::GetId(nsAString& aId) const
{
// If the track has a track element then its id should be the same as the
// track element's id.
if (mTrackElement) {
mTrackElement->GetAttribute(NS_LITERAL_STRING("id"), aId);
}
}
void
TextTrack::AddCue(TextTrackCue& aCue)
{

View File

@ -84,10 +84,7 @@ public:
{
aType = mType;
}
void GetId(nsAString& aId) const
{
aId = mId;
}
void GetId(nsAString& aId) const;
TextTrackMode Mode() const
{
@ -134,7 +131,6 @@ private:
nsString mLabel;
nsString mLanguage;
nsString mType;
nsString mId;
TextTrackMode mMode;
nsRefPtr<TextTrackCueList> mCueList;

View File

@ -67,6 +67,7 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true],
trackOne.label = "first";
trackOne.src = "basic.vtt";
trackOne.default = true;
trackOne.id = "2";
video.appendChild(trackOne);
video.addTextTrack("subtitles", "fourth", "en-CA");
@ -102,10 +103,10 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true],
// method, will occupy the last two indexes in the order that they were
// added in.
var trackData = [
{ label: "first", mode: "showing" },
{ label: "second", mode: "disabled" },
{ label: "third", mode: "hidden" },
{ label: "fourth", mode: "hidden"}
{ label: "first", mode: "showing", id: "2" },
{ label: "second", mode: "disabled", id: "" },
{ label: "third", mode: "hidden", id: "" },
{ label: "fourth", mode: "hidden", id: "" }
];
is(video.textTracks.length, trackData.length, "TextTracks length should be " + trackData.length);
for (var i = 0; i < trackData.length; i++) {