зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1682632
- part3: Restrict Extension API webidl bindings to nightly builds. r=baku,mixedpuppy
Depends on D99887 Differential Revision: https://phabricator.services.mozilla.com/D104707
This commit is contained in:
Родитель
1570f59193
Коммит
1459fc9f1f
|
@ -1052,21 +1052,14 @@ WEBIDL_FILES += [
|
|||
]
|
||||
|
||||
# WebExtensions API.
|
||||
# TODO: evaluate to add a MOZ_WEBEXT_... config to initially
|
||||
# restrict these new bindings to nightly builds, then gradually
|
||||
# include them in other channels.
|
||||
WEBIDL_FILES += [
|
||||
"ExtensionBrowser.webidl",
|
||||
"ExtensionEventManager.webidl",
|
||||
# ExtensionMockAPI is not a real WebExtensions API, and it is only enabled in tests.
|
||||
"ExtensionMockAPI.webidl",
|
||||
"ExtensionPort.webidl",
|
||||
]
|
||||
|
||||
# The following is not a real WebExtensions API, it is a test WebIDL
|
||||
# interface that includes a collection of the cases useful to unit
|
||||
# test the API request forwarding mechanism without tying it to
|
||||
# a specific WebExtensions API.
|
||||
WEBIDL_FILES += ["ExtensionMockAPI.webidl"]
|
||||
|
||||
# We only expose our prefable test interfaces in debug builds, just to be on
|
||||
# the safe side.
|
||||
if CONFIG["MOZ_DEBUG"] and CONFIG["ENABLE_TESTS"]:
|
||||
|
|
|
@ -124,13 +124,17 @@ MOCHITEST_MANIFESTS += [
|
|||
MOCHITEST_CHROME_MANIFESTS += ["test/mochitest/chrome.ini"]
|
||||
XPCSHELL_TESTS_MANIFESTS += [
|
||||
"test/xpcshell/native_messaging.ini",
|
||||
"test/xpcshell/webidl-api/xpcshell.ini",
|
||||
"test/xpcshell/xpcshell-e10s.ini",
|
||||
"test/xpcshell/xpcshell-legacy-ep.ini",
|
||||
"test/xpcshell/xpcshell-remote.ini",
|
||||
"test/xpcshell/xpcshell.ini",
|
||||
]
|
||||
|
||||
# Only include tests that requires the WebExtensions WebIDL API bindings
|
||||
# in builds where they are enabled (currently only on Nightly builds).
|
||||
if CONFIG["MOZ_WEBEXT_WEBIDL_ENABLED"]:
|
||||
XPCSHELL_TESTS_MANIFESTS += ["test/xpcshell/webidl-api/xpcshell.ini"]
|
||||
|
||||
SPHINX_TREES["webextensions"] = "docs"
|
||||
|
||||
with Files("docs/**"):
|
||||
|
|
|
@ -10,6 +10,14 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
ExtensionTestCommon: "resource://testing-common/ExtensionTestCommon.jsm",
|
||||
});
|
||||
|
||||
add_task(function checkExtensionsWebIDLEnabled() {
|
||||
equal(
|
||||
AppConstants.MOZ_WEBEXT_WEBIDL_ENABLED,
|
||||
true,
|
||||
"WebExtensions WebIDL bindings build time flag should be enabled"
|
||||
);
|
||||
});
|
||||
|
||||
function getBackgroundServiceWorkerRegistration(extension) {
|
||||
const swm = Cc["@mozilla.org/serviceworkers/manager;1"].getService(
|
||||
Ci.nsIServiceWorkerManager
|
||||
|
|
|
@ -36,15 +36,8 @@ JSObject* ExtensionBrowser::WrapObject(JSContext* aCx,
|
|||
|
||||
nsIGlobalObject* ExtensionBrowser::GetParentObject() const { return mGlobal; }
|
||||
|
||||
ExtensionMockAPI* ExtensionBrowser::GetExtensionMockAPI() {
|
||||
if (!mExtensionMockAPI) {
|
||||
mExtensionMockAPI = new ExtensionMockAPI(mGlobal, this);
|
||||
}
|
||||
|
||||
return mExtensionMockAPI;
|
||||
}
|
||||
|
||||
bool ExtensionAPIAllowed(JSContext* aCx, JSObject* aGlobal) {
|
||||
#ifdef MOZ_WEBEXT_WEBIDL_ENABLED
|
||||
// Only expose the Extension API bindings if:
|
||||
// - the context is related to a worker where the Extension API are allowed
|
||||
// (currently only the extension service worker declared in the extension
|
||||
|
@ -69,6 +62,19 @@ bool ExtensionAPIAllowed(JSContext* aCx, JSObject* aGlobal) {
|
|||
MOZ_ASSERT(workerPrivate->IsServiceWorker());
|
||||
|
||||
return workerPrivate->ExtensionAPIAllowed();
|
||||
#else
|
||||
// Always return false on build where MOZ_WEBEXT_WEBIDL_ENABLED is set to
|
||||
// false (currently on all channels but nightly).
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
ExtensionMockAPI* ExtensionBrowser::GetExtensionMockAPI() {
|
||||
if (!mExtensionMockAPI) {
|
||||
mExtensionMockAPI = new ExtensionMockAPI(mGlobal, this);
|
||||
}
|
||||
|
||||
return mExtensionMockAPI;
|
||||
}
|
||||
|
||||
} // namespace extensions
|
||||
|
|
|
@ -29,9 +29,14 @@ EXPORTS.mozilla.extensions += [
|
|||
# test the API request forwarding mechanism without tying it to
|
||||
# a specific WebExtensions API.
|
||||
UNIFIED_SOURCES += ["ExtensionMockAPI.cpp"]
|
||||
|
||||
EXPORTS.mozilla.extensions += ["ExtensionMockAPI.h"]
|
||||
|
||||
# Propagate the build config to be able to use it in souce code preprocessing
|
||||
# (used in mozilla::extensions::ExtensionAPIAllowed to disable the webidl
|
||||
# bindings in non-nightly builds).
|
||||
if CONFIG["MOZ_WEBEXT_WEBIDL_ENABLED"]:
|
||||
DEFINES["MOZ_WEBEXT_WEBIDL_ENABLED"] = True
|
||||
|
||||
include("/ipc/chromium/chromium-config.mozbuild")
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
|
|
|
@ -300,6 +300,13 @@ this.AppConstants = Object.freeze({
|
|||
false,
|
||||
#endif
|
||||
|
||||
MOZ_WEBEXT_WEBIDL_ENABLED:
|
||||
#ifdef MOZ_WEBEXT_WEBIDL_ENABLED
|
||||
true,
|
||||
#else
|
||||
false,
|
||||
#endif
|
||||
|
||||
MENUBAR_CAN_AUTOHIDE:
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
true,
|
||||
|
|
|
@ -301,6 +301,7 @@ for var in (
|
|||
"MOZ_UNSIGNED_SYSTEM_SCOPE",
|
||||
"MOZ_UPDATE_AGENT",
|
||||
"MOZ_UPDATER",
|
||||
"MOZ_WEBEXT_WEBIDL_ENABLED",
|
||||
):
|
||||
if CONFIG[var]:
|
||||
DEFINES[var] = True
|
||||
|
|
|
@ -1486,6 +1486,31 @@ def addon_sideload_allowed(value):
|
|||
|
||||
set_config("MOZ_ALLOW_ADDON_SIDELOAD", addon_sideload_allowed)
|
||||
|
||||
# WebExtensions API WebIDL bindings
|
||||
# ==============================================================
|
||||
|
||||
|
||||
@depends(milestone)
|
||||
def extensions_webidl_bindings_default(milestone):
|
||||
# Only enable the webidl bindings for the WebExtensions APIs
|
||||
# in Nightly.
|
||||
return milestone.is_nightly
|
||||
|
||||
|
||||
option(
|
||||
"--enable-extensions-webidl-bindings",
|
||||
default=extensions_webidl_bindings_default,
|
||||
help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
|
||||
)
|
||||
|
||||
|
||||
@depends("--enable-extensions-webidl-bindings")
|
||||
def extensions_webidl_enabled(value):
|
||||
return bool(value)
|
||||
|
||||
|
||||
set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
|
||||
|
||||
# Launcher process (Windows only)
|
||||
# ==============================================================
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче