Queries a card reader's attribute or capability value, given its tag.
-
Write an algorithm for this method.
+
The {{SmartCardConnection/getAttribute(tag)}} method steps are:
+
+
Let |promise:Promise| be [=a new promise=].
+
If
+ [=this=].{{SmartCardConnection/[[context]]}}.{{SmartCardContext/[[operationInProgress]]}}
+ is `true`, [=reject=] |promise| with a "{{InvalidStateError}}"
+ {{DOMException}} and return |promise|.
+
If [=this=].{{SmartCardConnection/[[comm]]}} is `null`, [=reject=]
+ |promise| with a "{{InvalidStateError}}" {{DOMException}} and return
+ |promise|.
+
Set
+ [=this=].{{SmartCardConnection/[[context]]}}.{{SmartCardContext/[[operationInProgress]]}}
+ to `true`.
+
Run the following steps [=in parallel=]:
+
+
Let |pcscTag:DWORD| be a [[PCSC5]] `DWORD` containing |tag|.
+
Let |buffer:array of BYTE| be a [[PCSC5]] `BYTE[]` large
+ enough to hold this reader attribute, as determined by the
+ platform's [[PCSC5]] implementation.
+
Call [=this=].{{SmartCardConnection/[[comm]]}}.`GetReaderCapabilities()`
+ with |pcscTag| and |buffer| as arguments.
+
Let |responseCode:RESPONSECODE| be the returned
+ `RESPONSECODE`.
+
[=Queue a global task=] on the [=relevant global object=] of
+ [=this=] using the [=smart card task source=] which performs the
+ following steps:
+
+
[=Clear the operationInProgress=] of
+ [=this=].{{SmartCardConnection/[[context]]}}.
+
If |responseCode| is not `SCARD_S_SUCCESS`, [=reject=]
+ |promise| with an [=exception=]
+ {{SmartCardError/corresponding}} to |responseCode| and abort
+ these steps.
+
Let |resultBytes:byte sequence| be the bytes of |buffer|
+ containing the attribute read.
+
[=Resolve=] |promise| with the result of
+ [=ArrayBuffer/Create|creating=] an {{ArrayBuffer}} from
+ |resultBytes| in [=this=]'s [=relevant Realm=].