Bug 1632116 - Introduce dom.window.content.untrusted.enabled r=emilio

`window.content` is currently disabled only in Nightly by C preprecessor, and this patch replaces it with a new flag to allow users to manipulate.

Differential Revision: https://phabricator.services.mozilla.com/D71775
This commit is contained in:
Kagami Sascha Rosylight 2020-04-22 13:08:25 +00:00
parent c4506737ea
commit 6da77fced9
4 changed files with 20 additions and 12 deletions

View File

@ -2918,8 +2918,7 @@ void nsGlobalWindowInner::GetOwnPropertyNames(
}
/* static */
bool nsGlobalWindowInner::IsPrivilegedChromeWindow(JSContext* aCx,
JSObject* aObj) {
bool nsGlobalWindowInner::IsPrivilegedChromeWindow(JSContext*, JSObject* aObj) {
// For now, have to deal with XPConnect objects here.
nsGlobalWindowInner* win = xpc::WindowOrNull(aObj);
return win && win->IsChromeWindow() &&
@ -2929,17 +2928,23 @@ bool nsGlobalWindowInner::IsPrivilegedChromeWindow(JSContext* aCx,
/* static */
bool nsGlobalWindowInner::IsRequestIdleCallbackEnabled(JSContext* aCx,
JSObject* aObj) {
JSObject*) {
// The requestIdleCallback should always be enabled for system code.
return StaticPrefs::dom_requestIdleCallback_enabled() ||
nsContentUtils::IsSystemCaller(aCx);
}
/* static */
bool nsGlobalWindowInner::DeviceSensorsEnabled(JSContext* aCx, JSObject* aObj) {
bool nsGlobalWindowInner::DeviceSensorsEnabled(JSContext*, JSObject*) {
return Preferences::GetBool("device.sensors.enabled");
}
/* static */
bool nsGlobalWindowInner::ContentPropertyEnabled(JSContext* aCx, JSObject*) {
return StaticPrefs::dom_window_content_untrusted_enabled() ||
nsContentUtils::IsSystemCaller(aCx);
}
nsDOMOfflineResourceList* nsGlobalWindowInner::GetApplicationCache(
ErrorResult& aError) {
if (!mApplicationCache) {

View File

@ -386,12 +386,13 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> IndexedGetter(
uint32_t aIndex);
static bool IsPrivilegedChromeWindow(JSContext* /* unused */, JSObject* aObj);
static bool IsPrivilegedChromeWindow(JSContext*, JSObject* aObj);
static bool IsRequestIdleCallbackEnabled(JSContext* aCx,
JSObject* /* unused */);
static bool IsRequestIdleCallbackEnabled(JSContext* aCx, JSObject*);
static bool DeviceSensorsEnabled(JSContext* /* unused */, JSObject* aObj);
static bool DeviceSensorsEnabled(JSContext*, JSObject*);
static bool ContentPropertyEnabled(JSContext* aCx, JSObject*);
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
JS::Handle<jsid> aId,

View File

@ -502,10 +502,7 @@ partial interface Window {
optional DOMString options = "",
any... extraArguments);
[
#ifdef NIGHTLY_BUILD
ChromeOnly,
#endif
[Func="nsGlobalWindowInner::ContentPropertyEnabled",
NonEnumerable, Replaceable, Throws, NeedsCallerType]
readonly attribute object? content;

View File

@ -3103,6 +3103,11 @@
value: true
mirror: always
- name: dom.window.content.untrusted.enabled
type: bool
value: @IS_NOT_NIGHTLY_BUILD@
mirror: always
- name: dom.worker.canceling.timeoutMilliseconds
type: RelaxedAtomicUint32
value: 30000 # 30 seconds