diff --git a/dom/permission/Permissions.cpp b/dom/permission/Permissions.cpp index fc6c06d054eb..a74f65b80cbc 100644 --- a/dom/permission/Permissions.cpp +++ b/dom/permission/Permissions.cpp @@ -142,26 +142,20 @@ already_AddRefed Permissions::Query(JSContext* aCx, } already_AddRefed Permissions::ParseSetParameters( - JSContext* aCx, JS::Handle aParameters, ErrorResult& aRv) { + JSContext* aCx, const PermissionSetParameters& aParameters, + ErrorResult& aRv) { // Step 1: Let parametersDict be the parameters argument, converted to an IDL // value of type PermissionSetParameters. If this throws an exception, // return an invalid argument error. - // (The error type should be handled by the caller) - JS::Rooted parameters(aCx, JS::ObjectValue(*aParameters)); - RootedDictionary parametersDict(aCx); - if (!parametersDict.Init(aCx, parameters)) { - aRv.MightThrowJSException(); - aRv.StealExceptionFromJSContext(aCx); - return nullptr; - } + // (Done by IDL layer, and the error type should be handled by the caller) - // Step 2: Let rootDesc be parameters.descriptor. - JS::Rooted rootDesc(aCx, parametersDict.mDescriptor); - - // Step 3: If parameters.state is an inappropriate permission state for any - // implementation-defined reason, return a invalid argument error. + // Step 2: If parametersDict.state is an inappropriate permission state for + // any implementation-defined reason, return a invalid argument error. // (We don't do this) + // Step 3: Let rootDesc be parametersDict.descriptor. + JS::Rooted rootDesc(aCx, aParameters.mDescriptor); + // Step 4: Let typedDescriptor be the object rootDesc refers to, converted // to an IDL value of rootDesc.name's permission descriptor type. If this // throws an exception, return a invalid argument error. @@ -174,7 +168,7 @@ already_AddRefed Permissions::ParseSetParameters( } // Set the state too so that the caller can use it for step 5. - status->SetState(parametersDict.mState); + status->SetState(aParameters.mState); return status.forget(); } diff --git a/dom/permission/Permissions.h b/dom/permission/Permissions.h index 86087ef4aac7..f6cfd4ae6568 100644 --- a/dom/permission/Permissions.h +++ b/dom/permission/Permissions.h @@ -19,6 +19,7 @@ namespace dom { class Promise; class PermissionStatus; +struct PermissionSetParameters; class Permissions final : public nsISupports, public nsWrapperCache { public: @@ -39,7 +40,8 @@ class Permissions final : public nsISupports, public nsWrapperCache { // The IDL conversion steps of // https://w3c.github.io/permissions/#webdriver-command-set-permission already_AddRefed ParseSetParameters( - JSContext* aCx, JS::Handle aParameters, ErrorResult& aRv); + JSContext* aCx, const PermissionSetParameters& aParameters, + ErrorResult& aRv); private: ~Permissions(); diff --git a/dom/webidl/Permissions.webidl b/dom/webidl/Permissions.webidl index 93d5a573d1ce..c4804e79cb0e 100644 --- a/dom/webidl/Permissions.webidl +++ b/dom/webidl/Permissions.webidl @@ -37,8 +37,6 @@ interface Permissions { Promise query(object permission); // http://w3c.github.io/permissions/#webdriver-command-set-permission - // We use `object` instead of PermissionSetParameters here to retain the access - // to the extra descriptor members from e.g. MidiPermissionDescriptor. [ChromeOnly, Throws] - PermissionStatus parseSetParameters(object parameters); + PermissionStatus parseSetParameters(PermissionSetParameters parameters); };