diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp
index 68e37f86c824..36ba880b65e6 100644
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1875,10 +1875,6 @@ void HTMLMediaElement::AbortExistingLoads() {
mIsRunningSelectResource = false;
- if (mTextTrackManager) {
- mTextTrackManager->NotifyReset();
- }
-
mEventDeliveryPaused = false;
mPendingEvents.Clear();
mCurrentLoadPlayTime.Reset();
@@ -5521,6 +5517,13 @@ void HTMLMediaElement::ChangeReadyState(nsMediaReadyState aState) {
DDLOG(DDLogCategory::Property, "ready_state", gReadyStateToString[aState]);
+ // https://html.spec.whatwg.org/multipage/media.html#text-track-cue-active-flag
+ // The user agent must synchronously unset cues' active flag whenever the
+ // media element's readyState is changed back to HAVE_NOTHING.
+ if (mReadyState == HAVE_NOTHING && mTextTrackManager) {
+ mTextTrackManager->NotifyReset();
+ }
+
if (mNetworkState == NETWORK_EMPTY) {
return;
}
diff --git a/dom/html/TextTrackManager.cpp b/dom/html/TextTrackManager.cpp
index 30699c062bbb..590c23debcb9 100644
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -824,8 +824,14 @@ void TextTrackManager::NotifyCueUpdated(TextTrackCue* aCue) {
}
void TextTrackManager::NotifyReset() {
+ // https://html.spec.whatwg.org/multipage/media.html#text-track-cue-active-flag
+ // This will unset all cues' active flag and update the cue display.
WEBVTT_LOG("NotifyReset");
mLastTimeMarchesOnCalled = media::TimeUnit::Zero();
+ for (uint32_t idx = 0; idx < mTextTracks->Length(); ++idx) {
+ (*mTextTracks)[idx]->SetCuesInactive();
+ }
+ UpdateCueDisplay();
}
void TextTrackManager::ReportTelemetryForTrack(TextTrack* aTextTrack) const {
diff --git a/dom/media/TextTrack.cpp b/dom/media/TextTrack.cpp
index 7c2f01187fef..a5aeb99653df 100644
--- a/dom/media/TextTrack.cpp
+++ b/dom/media/TextTrack.cpp
@@ -222,7 +222,10 @@ void TextTrack::SetTrackElement(HTMLTrackElement* aTrackElement) {
mTrackElement = aTrackElement;
}
-void TextTrack::SetCuesInactive() { mCueList->SetCuesInactive(); }
+void TextTrack::SetCuesInactive() {
+ WEBVTT_LOG("SetCuesInactive");
+ mCueList->SetCuesInactive();
+}
void TextTrack::NotifyCueUpdated(TextTrackCue* aCue) {
WEBVTT_LOG("NotifyCueUpdated, cue=%p", aCue);