diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 55e06de7fd08..b3200900ea2b 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -1594,7 +1594,12 @@ void Navigator::GetGamepads(nsTArray>& aGamepads, win->GetGamepads(aGamepads); } -GamepadServiceTest* Navigator::RequestGamepadServiceTest() { +GamepadServiceTest* Navigator::RequestGamepadServiceTest(ErrorResult& aRv) { + if (!xpc::IsInAutomation()) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + if (!mGamepadServiceTest) { mGamepadServiceTest = GamepadServiceTest::CreateTestService(mWindow); } @@ -1759,7 +1764,12 @@ void Navigator::NotifyActiveVRDisplaysChanged() { Navigator_Binding::ClearCachedActiveVRDisplaysValue(this); } -VRServiceTest* Navigator::RequestVRServiceTest() { +VRServiceTest* Navigator::RequestVRServiceTest(ErrorResult& aRv) { + if (!xpc::IsInAutomation()) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + // Ensure that the Mock VR devices are not released prematurely nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow); win->NotifyHasXRSession(); diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 0dbb9a5b717a..fd4b1276ab05 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -175,13 +175,13 @@ class Navigator final : public nsISupports, public nsWrapperCache { MediaDevices* GetExtantMediaDevices() const { return mMediaDevices; }; void GetGamepads(nsTArray>& aGamepads, ErrorResult& aRv); - GamepadServiceTest* RequestGamepadServiceTest(); + GamepadServiceTest* RequestGamepadServiceTest(ErrorResult& aRv); already_AddRefed GetVRDisplays(ErrorResult& aRv); void FinishGetVRDisplays(bool isWebVRSupportedInwindow, Promise* p); void GetActiveVRDisplays(nsTArray>& aDisplays) const; void OnXRPermissionRequestAllow(); void OnXRPermissionRequestCancel(); - VRServiceTest* RequestVRServiceTest(); + VRServiceTest* RequestVRServiceTest(ErrorResult& aRv); bool IsWebVRContentDetected() const; bool IsWebVRContentPresenting() const; void RequestVRPresentation(VRDisplay& aDisplay); diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index 8e2259152f3b..2ceb14716390 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -209,7 +209,7 @@ partial interface Navigator { sequence getGamepads(); }; partial interface Navigator { - [Pref="dom.gamepad.test.enabled"] + [Throws, Pref="dom.gamepad.test.enabled"] GamepadServiceTest requestGamepadServiceTest(); }; @@ -228,7 +228,7 @@ partial interface Navigator { undefined requestVRPresentation(VRDisplay display); }; partial interface Navigator { - [Pref="dom.vr.puppet.enabled"] + [Throws, Pref="dom.vr.puppet.enabled"] VRServiceTest requestVRServiceTest(); };