diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index f5fca7549db2..86d61a9867e1 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -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) { diff --git a/dom/base/nsGlobalWindowInner.h b/dom/base/nsGlobalWindowInner.h index 0da75159647b..f3cef6f080e9 100644 --- a/dom/base/nsGlobalWindowInner.h +++ b/dom/base/nsGlobalWindowInner.h @@ -386,12 +386,13 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, mozilla::dom::Nullable 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 aObj, JS::Handle aId, diff --git a/dom/webidl/Window.webidl b/dom/webidl/Window.webidl index 37e79fe05291..751d597f89ba 100644 --- a/dom/webidl/Window.webidl +++ b/dom/webidl/Window.webidl @@ -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; diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 92f86e9d6e36..6c1e977c32ea 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -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