diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp
index bd2450dc3af4..faf5a4ec0c24 100644
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3129,20 +3129,20 @@ bool HTMLMediaElement::AllowedToPlay() const {
uint32_t HTMLMediaElement::GetPreloadDefault() const {
if (mMediaSource) {
- return HTMLMediaElement::PRELOAD_ATTR_METADATA;
+ return HTMLMediaElement::PRELOAD_METADATA;
}
if (OnCellularConnection()) {
return Preferences::GetInt("media.preload.default.cellular",
- HTMLMediaElement::PRELOAD_ATTR_NONE);
+ HTMLMediaElement::PRELOAD_NONE);
}
return Preferences::GetInt("media.preload.default",
- HTMLMediaElement::PRELOAD_ATTR_METADATA);
+ HTMLMediaElement::PRELOAD_METADATA);
}
uint32_t HTMLMediaElement::GetPreloadDefaultAuto() const {
if (OnCellularConnection()) {
return Preferences::GetInt("media.preload.auto.cellular",
- HTMLMediaElement::PRELOAD_ATTR_METADATA);
+ HTMLMediaElement::PRELOAD_METADATA);
}
return Preferences::GetInt("media.preload.auto",
HTMLMediaElement::PRELOAD_ENOUGH);
@@ -3167,14 +3167,13 @@ void HTMLMediaElement::UpdatePreloadAction() {
// media.preload.default pref, or just preload metadata if not present.
nextAction = static_cast(preloadDefault);
} else if (val->Type() == nsAttrValue::eEnum) {
- PreloadAttrValue attr =
- static_cast(val->GetEnumValue());
- if (attr == HTMLMediaElement::PRELOAD_ATTR_EMPTY ||
- attr == HTMLMediaElement::PRELOAD_ATTR_AUTO) {
+ MediaPreloadAttrValue attr =
+ static_cast(val->GetEnumValue());
+ if (attr == MediaPreloadAttrValue::PRELOAD_ATTR_AUTO) {
nextAction = static_cast(preloadAuto);
- } else if (attr == HTMLMediaElement::PRELOAD_ATTR_METADATA) {
+ } else if (attr == MediaPreloadAttrValue::PRELOAD_ATTR_METADATA) {
nextAction = HTMLMediaElement::PRELOAD_METADATA;
- } else if (attr == HTMLMediaElement::PRELOAD_ATTR_NONE) {
+ } else if (attr == MediaPreloadAttrValue::PRELOAD_ATTR_NONE) {
nextAction = HTMLMediaElement::PRELOAD_NONE;
}
} else {
@@ -4946,21 +4945,16 @@ bool HTMLMediaElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) {
- // Mappings from 'preload' attribute strings to an enumeration.
- static const nsAttrValue::EnumTableEntry kPreloadTable[] = {
- {"", HTMLMediaElement::PRELOAD_ATTR_EMPTY},
- {"none", HTMLMediaElement::PRELOAD_ATTR_NONE},
- {"metadata", HTMLMediaElement::PRELOAD_ATTR_METADATA},
- {"auto", HTMLMediaElement::PRELOAD_ATTR_AUTO},
- };
-
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::crossorigin) {
ParseCORSValue(aValue, aResult);
return true;
}
if (aAttribute == nsGkAtoms::preload) {
- return aResult.ParseEnumValue(aValue, kPreloadTable, false);
+ return aResult.ParseEnumValue(aValue, kPreloadTable, false,
+ // The default value is "auto" if aValue is
+ // not a recognised value.
+ kPreloadDefaultType);
}
}
diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h
index 4eab5d4ea5fd..6e151457977c 100644
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -110,6 +110,25 @@ enum class StreamCaptureBehavior : uint8_t {
FINISH_WHEN_ENDED
};
+/**
+ * Possible values of the 'preload' attribute.
+ */
+enum MediaPreloadAttrValue : uint8_t {
+ PRELOAD_ATTR_NONE, // set to "none"
+ PRELOAD_ATTR_METADATA, // set to "metadata"
+ PRELOAD_ATTR_AUTO // set to "auto"
+};
+
+// Mappings from 'preload' attribute strings to an enumeration.
+static const nsAttrValue::EnumTableEntry kPreloadTable[] = {
+ {"none", MediaPreloadAttrValue::PRELOAD_ATTR_NONE},
+ {"metadata", MediaPreloadAttrValue::PRELOAD_ATTR_METADATA},
+ {"auto", MediaPreloadAttrValue::PRELOAD_ATTR_AUTO},
+};
+
+static constexpr const nsAttrValue::EnumTableEntry* kPreloadDefaultType =
+ &kPreloadTable[std::size(kPreloadTable) - 1];
+
class HTMLMediaElement : public nsGenericHTMLElement,
public MediaDecoderOwner,
public PrincipalChangeObserver,
@@ -521,7 +540,7 @@ class HTMLMediaElement : public nsGenericHTMLElement,
nsGkAtoms::none->ToString(aValue);
return;
}
- GetEnumAttr(nsGkAtoms::preload, nullptr, aValue);
+ GetEnumAttr(nsGkAtoms::preload, kPreloadDefaultType->tag, aValue);
}
void SetPreload(const nsAString& aValue, ErrorResult& aRv) {
if (mSrcAttrStream) {
@@ -1165,16 +1184,6 @@ class HTMLMediaElement : public nsGenericHTMLElement,
*/
void NotifyShutdownEvent();
- /**
- * Possible values of the 'preload' attribute.
- */
- enum PreloadAttrValue : uint8_t {
- PRELOAD_ATTR_EMPTY, // set to ""
- PRELOAD_ATTR_NONE, // set to "none"
- PRELOAD_ATTR_METADATA, // set to "metadata"
- PRELOAD_ATTR_AUTO // set to "auto"
- };
-
/**
* The preloading action to perform. These dictate how we react to the
* preload attribute. See mPreloadAction.
diff --git a/dom/html/test/mochitest.toml b/dom/html/test/mochitest.toml
index c973a61af200..aab2a1cb1b9c 100644
--- a/dom/html/test/mochitest.toml
+++ b/dom/html/test/mochitest.toml
@@ -660,8 +660,6 @@ skip-if = [
["test_bug666200.html"]
-["test_bug666666.html"]
-
["test_bug669012.html"]
["test_bug674558.html"]
diff --git a/dom/html/test/test_bug666666.html b/dom/html/test/test_bug666666.html
deleted file mode 100644
index a3c22d4e0f2b..000000000000
--- a/dom/html/test/test_bug666666.html
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- Test for Bug 666666
-
-
-
-
-
-Mozilla Bug 666666
-
-
-
-
-
-
-
-
-
diff --git a/dom/media/test/mochitest_compat.toml b/dom/media/test/mochitest_compat.toml
index 7f34caafb9f9..40ddb129db7c 100644
--- a/dom/media/test/mochitest_compat.toml
+++ b/dom/media/test/mochitest_compat.toml
@@ -957,8 +957,6 @@ skip-if = ["appname == 'seamonkey'"] # Seamonkey: Bug 598252, bug 1307337, bug
["test_preload_actions.html"]
-["test_preload_attribute.html"]
-
["test_preload_suspend.html"]
["test_preserve_playbackrate_after_ui_play.html"]
diff --git a/dom/media/test/test_preload_attribute.html b/dom/media/test/test_preload_attribute.html
deleted file mode 100644
index 1e415035c554..000000000000
--- a/dom/media/test/test_preload_attribute.html
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
- Test for Bug 479863
-
-
-
-
-Mozilla Bug 479863
-
-
-
-
-
-
-
-
-
-
-
-
-