зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1596040 - Teach HTMLLinkElement's relList about 'manifest' r=bzbarsky
Fenix wants to ship Web Manifest support, while other Firefox products (e.g., Desktop) don't support it. With the pref enabled, developers can check, via `link.relList.supports()`, if manifest processing is supported by a particular product. Differential Revision: https://phabricator.services.mozilla.com/D55064 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c93ea7f424
Коммит
78f831bf6c
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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]
|
|
@ -0,0 +1,47 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1596040
|
||||
-->
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1596040 - Link relList support returns false for manifest</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
||||
<script>
|
||||
"use strict";
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
async function run() {
|
||||
const prefSetting = [
|
||||
{ manifest: true, preload: true },
|
||||
{ manifest: true, preload: false },
|
||||
{ manifest: false, preload: true },
|
||||
{ manifest: false, preload: false },
|
||||
];
|
||||
for (const { manifest, preload } of prefSetting) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.manifest.enabled", manifest],
|
||||
["network.preload", preload],
|
||||
],
|
||||
});
|
||||
const { relList } = document.createElement("link");
|
||||
is(
|
||||
relList.supports("manifest"),
|
||||
manifest,
|
||||
`Expected manifest to be ${manifest}`
|
||||
);
|
||||
is(
|
||||
relList.supports("preload"),
|
||||
preload,
|
||||
`Expected preload to be ${preload}`
|
||||
);
|
||||
}
|
||||
}
|
||||
run()
|
||||
.catch(console.error)
|
||||
.finally(() => SimpleTest.finish());
|
||||
</script>
|
||||
</head>
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче