зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1880096 - Use PermissionSetParameter for parseSetParameter IDL r=webidl,edgar
Differential Revision: https://phabricator.services.mozilla.com/D201738
This commit is contained in:
Родитель
d9d7ace23b
Коммит
3cb66846d5
|
@ -142,26 +142,20 @@ already_AddRefed<Promise> Permissions::Query(JSContext* aCx,
|
|||
}
|
||||
|
||||
already_AddRefed<PermissionStatus> Permissions::ParseSetParameters(
|
||||
JSContext* aCx, JS::Handle<JSObject*> 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<JS::Value> parameters(aCx, JS::ObjectValue(*aParameters));
|
||||
RootedDictionary<PermissionSetParameters> 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<JSObject*> 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<JSObject*> 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<PermissionStatus> 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();
|
||||
}
|
||||
|
|
|
@ -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<PermissionStatus> ParseSetParameters(
|
||||
JSContext* aCx, JS::Handle<JSObject*> aParameters, ErrorResult& aRv);
|
||||
JSContext* aCx, const PermissionSetParameters& aParameters,
|
||||
ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
~Permissions();
|
||||
|
|
|
@ -37,8 +37,6 @@ interface Permissions {
|
|||
Promise<PermissionStatus> 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);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче