Bug 1603673 - Signal that we support web manifest processing in Fenix r=snorp,agi,ladybenko

When enabled, `link.relList.supports("manifest")` will return `true`.

Differential Revision: https://phabricator.services.mozilla.com/D58181

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marcos Cáceres 2020-02-26 18:41:59 +00:00
parent 00dd87f6f4
commit 2cc840acbb
13 changed files with 101 additions and 1 deletions

View File

@ -4,6 +4,7 @@ support-files =
test_page.html
empty_page.html
prefs =
dom.manfiest.enabled=true
browser.ssb.enabled=true
browser.ssb.osintegration=false

View File

@ -44,6 +44,9 @@ async function enableApplicationPanel() {
// Enable all preferences related to service worker debugging.
await enableServiceWorkerDebugging();
// Enable web manifest processing.
Services.prefs.setBoolPref("dom.manifest.enabled", true);
// Enable application panel in DevTools.
await pushPref("devtools.application.enabled", true);
}

View File

@ -3,6 +3,9 @@
"use strict";
// Enable web manifest processing.
Services.prefs.setBoolPref("dom.manifest.enabled", true);
add_task(async function() {
info("Testing fetching a valid manifest");
const response = await fetchManifest("application-manifest-basic.html");

View File

@ -25,6 +25,8 @@
*/
"use strict";
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { PromiseMessage } = ChromeUtils.import(
"resource://gre/modules/PromiseMessage.jsm"
);
@ -72,6 +74,11 @@ var ManifestObtainer = {
aContent,
aOptions = { checkConformance: false }
) {
if (!Services.prefs.getBoolPref("dom.manifest.enabled")) {
throw new Error(
"Obtaining manifest is disabled by pref: dom.manifest.enabled"
);
}
if (!aContent || isXULBrowser(aContent)) {
const err = new TypeError("Invalid input. Expected a DOM Window.");
return Promise.reject(err);

View File

@ -1,6 +1,9 @@
// Used by JSHint:
/* global Cu, BrowserTestUtils, ok, add_task, gBrowser */
"use strict";
Services.prefs.setBoolPref("dom.manifest.enabled", true);
const { ManifestIcons } = ChromeUtils.import(
"resource://gre/modules/ManifestIcons.jsm"
);

View File

@ -1,6 +1,9 @@
// Used by JSHint:
/* global ok, is, Cu, BrowserTestUtils, add_task, gBrowser, makeTestURL, requestLongerTimeout*/
"use strict";
Services.prefs.setBoolPref("dom.manifest.enabled", true);
const { ManifestObtainer } = ChromeUtils.import(
"resource://gre/modules/ManifestObtainer.jsm"
);

View File

@ -2,6 +2,8 @@
/* global ok, is, Cu, BrowserTestUtils, add_task, gBrowser, requestLongerTimeout*/
"use strict";
Services.prefs.setBoolPref("dom.manifest.enabled", true);
const { ManifestObtainer } = ChromeUtils.import(
"resource://gre/modules/ManifestObtainer.jsm"
);

View File

@ -13,6 +13,10 @@ const mixedContentFile = `${path}file_web_manifest_mixed_content.html`;
const server = `${path}file_testserver.sjs`;
const defaultURL = new URL(`http://example.org${server}`);
const mixedURL = new URL(`http://mochi.test:8888${server}`);
// Enable web manifest processing.
Services.prefs.setBoolPref("dom.manifest.enabled", true);
const tests = [
// Check interaction with default-src and another origin,
// CSP allows fetching from example.org, so manifest should load.

View File

@ -17,6 +17,10 @@ const httpsManifest = `${path}file_web_manifest_https.html`;
const server = `${path}file_testserver.sjs`;
const defaultURL = new URL(`http://example.org${server}`);
const secureURL = new URL(`https://example.com:443${server}`);
// Enable web manifest processing.
Services.prefs.setBoolPref("dom.manifest.enabled", true);
const tests = [
// CSP block everything, so trying to load a manifest
// will result in a policy violation.

View File

@ -521,6 +521,7 @@ package org.mozilla.geckoview {
method public boolean getUseMaxScreenDepth();
method public boolean getUseMultiprocess();
method public boolean getWebFontsEnabled();
method public boolean getWebManifestEnabled();
method @NonNull public GeckoRuntimeSettings setAboutConfigEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setAutomaticFontSizeAdjustment(boolean);
method @NonNull public GeckoRuntimeSettings setConsoleOutputEnabled(boolean);
@ -535,6 +536,7 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings setPreferredColorScheme(int);
method @NonNull public GeckoRuntimeSettings setRemoteDebuggingEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setWebFontsEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setWebManifestEnabled(boolean);
field public static final int COLOR_SCHEME_DARK = 1;
field public static final int COLOR_SCHEME_LIGHT = 0;
field public static final int COLOR_SCHEME_SYSTEM = -1;
@ -570,6 +572,7 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings.Builder useMaxScreenDepth(boolean);
method @NonNull public GeckoRuntimeSettings.Builder useMultiprocess(boolean);
method @NonNull public GeckoRuntimeSettings.Builder webFontsEnabled(boolean);
method @NonNull public GeckoRuntimeSettings.Builder webManifest(boolean);
method @NonNull protected GeckoRuntimeSettings newSettings(@Nullable GeckoRuntimeSettings);
}

View File

@ -296,6 +296,26 @@ class ContentDelegateTest : BaseSessionTest() {
})
}
@Test fun webAppManifestPref() {
val initialState = sessionRule.runtime.settings.getWebManifestEnabled()
val jsToRun = "document.querySelector('link[rel=manifest]').relList.supports('manifest');"
// Check pref'ed off
sessionRule.runtime.settings.setWebManifestEnabled(false)
mainSession.loadTestPath(HELLO_HTML_PATH)
var result = equalTo(mainSession.evaluateJS(jsToRun) as Boolean)
assertThat("Disabling pref makes relList.supports('manifest') return false", false, result)
// Check pref'ed on
sessionRule.runtime.settings.setWebManifestEnabled(true)
mainSession.loadTestPath(HELLO_HTML_PATH)
result = equalTo(mainSession.evaluateJS(jsToRun) as Boolean)
assertThat("Enabling pref makes relList.supports('manifest') return true", true, result)
sessionRule.runtime.settings.setWebManifestEnabled(initialState)
}
@Test fun webAppManifest() {
mainSession.loadTestPath(HELLO_HTML_PATH)
mainSession.waitUntilCalled(object : Callbacks.All {

View File

@ -156,6 +156,22 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
return this;
}
/**
* Set whether web manifest support is enabled.
*
* This controls if Gecko actually downloads, or "obtains", web
* manifests and processes them. Without setting this pref, trying
* to obtain a manifest throws.
*
* @param enabled A flag determining whether Web Manifest processing support is
* enabled.
* @return The builder instance.
*/
public @NonNull Builder webManifest(final boolean enabled) {
getSettings().mWebManifest.set(enabled);
return this;
}
/**
* Set whether or not web console messages should go to logcat.
*
@ -431,6 +447,8 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
return mContentBlocking;
}
/* package */ final Pref<Boolean> mWebManifest = new Pref<Boolean>(
"dom.manifest.enabled", true);
/* package */ final Pref<Boolean> mJavaScript = new Pref<Boolean>(
"javascript.enabled", true);
/* package */ final Pref<Boolean> mRemoteDebugging = new Pref<Boolean>(
@ -772,6 +790,28 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
return out.toString();
}
/**
* Sets whether Web Manifest processing support is enabled.
*
* @param enabled A flag determining whether Web Manifest processing support is
* enabled.
*
* @return This GeckoRuntimeSettings instance.
*/
public @NonNull GeckoRuntimeSettings setWebManifestEnabled(final boolean enabled) {
mWebManifest.commit(enabled);
return this;
}
/**
* Get whether or not Web Manifest processing support is enabled.
*
* @return True if web manifest processing support is enabled.
*/
public boolean getWebManifestEnabled() {
return mWebManifest.get();
}
/**
* Set whether or not web console messages should go to logcat.
*

View File

@ -28,10 +28,17 @@ exclude: true
[`GeckoSession.PermissionDelegate#PERMISSION_AUTOPLAY_INAUDIBLE`][73.13] to
control autoplay.
([bug 1614894]({{bugzilla}}1614894))
- Added [`GeckoRuntimeSettings.setWebManifestEnabled`][75.4],
[`GeckoRuntimeSettings.webManifest`][75.5], and
[`GeckoRuntimeSettings.getWebManifestEnabled`][75.6]
([bug 1614894]({{bugzilla}}1603673)), to enable or check Web Manifest support.
[75.1]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#useMultiprocess-boolean-
[75.2]: {{javadoc_uri}}/WebExtensionController.DebuggerDelegate.html#onExtensionListUpdated--
[75.3]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#autoplayDefault-boolean-
[75.4]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#setWebManifestEnabled-boolean-
[75.5]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#webManifest-boolean-
[75.6]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#getWebManifestEnabled--
## v74
- Added [`WebExtensionController.enable`][74.1] and [`disable`][74.2] to
@ -595,4 +602,4 @@ exclude: true
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
[65.25]: {{javadoc_uri}}/GeckoResult.html
[api-version]: 898e8783e858824b7af7e4e9763bf5aaa54c0b0c
[api-version]: 82255b8fdbc57e73920690426bdb4dd261cfe4ff