diff --git a/dom/html/HTMLLinkElement.cpp b/dom/html/HTMLLinkElement.cpp index 9f9ce4a96585..43a46fa755df 100644 --- a/dom/html/HTMLLinkElement.cpp +++ b/dom/html/HTMLLinkElement.cpp @@ -396,17 +396,32 @@ void HTMLLinkElement::GetLinkTarget(nsAString& aTarget) { } static const DOMTokenListSupportedToken sSupportedRelValues[] = { - // Keep this in sync with ToLinkMask in nsStyleLinkElement.cpp. + // Keep this and the one below in sync with ToLinkMask in + // nsStyleLinkElement.cpp. // "preload" must come first because it can be disabled. "preload", "prefetch", "dns-prefetch", "stylesheet", "next", "alternate", "preconnect", "icon", "search", nullptr}; +static const DOMTokenListSupportedToken sSupportedRelValuesWithManifest[] = { + // Keep this in sync with ToLinkMask in nsStyleLinkElement.cpp. + // "preload" and "manifest" must come first because they can be disabled. + "preload", "manifest", "prefetch", "dns-prefetch", "stylesheet", "next", + "alternate", "preconnect", "icon", "search", nullptr}; + nsDOMTokenList* HTMLLinkElement::RelList() { if (!mRelList) { - if (Preferences::GetBool("network.preload") || - StaticPrefs::network_preload_experimental()) { + auto preload = Preferences::GetBool("network.preload") || + StaticPrefs::network_preload_experimental(); + auto manifest = StaticPrefs::dom_manifest_enabled(); + if (manifest && preload) { + mRelList = new nsDOMTokenList(this, nsGkAtoms::rel, + sSupportedRelValuesWithManifest); + } else if (manifest && !preload) { + mRelList = new nsDOMTokenList(this, nsGkAtoms::rel, + &sSupportedRelValuesWithManifest[1]); + } else if (!manifest && preload) { mRelList = new nsDOMTokenList(this, nsGkAtoms::rel, sSupportedRelValues); - } else { + } else { // both false...drop preload mRelList = new nsDOMTokenList(this, nsGkAtoms::rel, &sSupportedRelValues[1]); } diff --git a/dom/manifest/test/mochitest.ini b/dom/manifest/test/mochitest.ini index eb6029cc6190..32cc821b334c 100644 --- a/dom/manifest/test/mochitest.ini +++ b/dom/manifest/test/mochitest.ini @@ -9,6 +9,7 @@ support-files = [test_ImageObjectProcessor_sizes.html] [test_ImageObjectProcessor_src.html] [test_ImageObjectProcessor_type.html] +[test_link_relList_supports_manifest.html] [test_ManifestProcessor_background_color.html] [test_ManifestProcessor_dir.html] [test_ManifestProcessor_display.html] @@ -21,4 +22,4 @@ support-files = [test_ManifestProcessor_start_url.html] [test_ManifestProcessor_theme_color.html] [test_ManifestProcessor_warnings.html] -[test_window_onappinstalled_event.html] +[test_window_onappinstalled_event.html] \ No newline at end of file diff --git a/dom/manifest/test/test_link_relList_supports_manifest.html b/dom/manifest/test/test_link_relList_supports_manifest.html new file mode 100644 index 000000000000..af678ddb5f3d --- /dev/null +++ b/dom/manifest/test/test_link_relList_supports_manifest.html @@ -0,0 +1,47 @@ + + + + + + + Test for Bug 1596040 - Link relList support returns false for manifest + + + + diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index d15a7e962dcd..d7ea04b02e7d 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1796,6 +1796,12 @@ value: true mirror: always +# Whether "W3C Web Manifest" processing is enabled +- name: dom.manifest.enabled + type: bool + value: false + mirror: always + # Whether window.onappinstalled from "W3C Web Manifest" is enabled - name: dom.manifest.onappinstalled type: bool