Skip to content

Commit

Permalink
Bug 1603673 - Signal that we support web manifest processing in Fenix…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Marcos Cáceres committed Mar 4, 2020
1 parent d782507 commit 65ea85a
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 2 deletions.
1 change: 1 addition & 0 deletions browser/components/ssb/tests/browser/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

// Enable web manifest processing.
Services.prefs.setBoolPref("dom.manifest.enabled", true);

// Check that a site's manifest affects the scope of a ssb.

function build_task(page, linkId, external, preload) {
Expand Down
3 changes: 3 additions & 0 deletions devtools/client/application/test/browser/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions devtools/server/tests/browser/browser_application_manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
7 changes: 7 additions & 0 deletions dom/manifest/ManifestObtainer.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
"use strict";

const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

const { PromiseMessage } = ChromeUtils.import(
"resource://gre/modules/PromiseMessage.jsm"
);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions dom/manifest/test/browser_ManifestIcons_browserFetchIcon.js
Original file line number Diff line number Diff line change
@@ -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"
);
Expand Down
3 changes: 3 additions & 0 deletions dom/manifest/test/browser_ManifestObtainer_credentials.js
Original file line number Diff line number Diff line change
@@ -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"
);
Expand Down
2 changes: 2 additions & 0 deletions dom/manifest/test/browser_ManifestObtainer_obtain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions dom/security/test/csp/browser_test_web_manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions mobile/android/geckoview/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,30 @@ 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)
sessionRule.waitForPageStop(mainSession)

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)
sessionRule.waitForPageStop(mainSession)

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ public static final class Builder
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.
*
Expand Down Expand Up @@ -431,6 +447,8 @@ public static final class Builder
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>(
Expand Down Expand Up @@ -772,6 +790,28 @@ private static String getLanguageTag(final Locale locale) {
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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ exclude: true
object which contains additional information about the newly created tab
(including the `url` which used to be passed in directly).
([bug 1616625]({{bugzilla}}1616625))

- Added [`GeckoRuntimeSettings.setWebManifestEnabled`][75.15],
[`GeckoRuntimeSettings.webManifest`][75.16], and
[`GeckoRuntimeSettings.getWebManifestEnabled`][75.17]
([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--
Expand All @@ -60,6 +63,9 @@ exclude: true
[75.12]: {{javadoc_uri}}/WebExtension.SessionTabDelegate.html#onUpdateTab-org.mozilla.geckoview.WebExtension-org.mozilla.geckoview.GeckoSession-org.mozilla.geckoview.WebExtension.UpdateTabDetails-
[75.13]: {{javadoc_uri}}/WebExtension.TabDelegate.html#onNewTab-org.mozilla.geckoview.WebExtension-org.mozilla.geckoview.WebExtension.CreateTabDetails-
[75.14]: {{javadoc_uri}}/WebExtension.CreateTabDetails.html
[75.15]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#setWebManifestEnabled-boolean-
[75.16]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#webManifest-boolean-
[75.17]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#getWebManifestEnabled--

## v74
- Added [`WebExtensionController.enable`][74.1] and [`disable`][74.2] to
Expand Down Expand Up @@ -623,4 +629,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]: 8b880533b33a0ad178f88ade00aaae5897625ef9
[api-version]: b293a94c5f74d3f660959dadd2b48732b2b1ecd1

0 comments on commit 65ea85a

Please sign in to comment.