Skip to content

Commit 39d8284

Browse files
authored
Add automation support via WebDriver (#141)
This PR integrates with the automation concepts defined in https://w3c.github.io/device-posture/#automation to allow changing device posture through the WebDriver extension commands defined there. Set device posture WebDriver extension will enable overriding posture defined by hardware. Clear device posture WebDriver extension removes device posture override and returns device posture control back to hardware. Fixes #140
1 parent dc5163e commit 39d8284

File tree

1 file changed

+187
-0
lines changed

1 file changed

+187
-0
lines changed

index.html

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,41 @@ <h3>
188188
</tr>
189189
</tbody>
190190
</table>
191+
<p>
192+
[=Top-level traversables=] must have the following internal slots:
193+
</p>
194+
<table class="simple">
195+
<thead>
196+
<tr>
197+
<th>
198+
Internal slot
199+
</th>
200+
<th>
201+
Description
202+
</th>
203+
</tr>
204+
</thead>
205+
<tbody>
206+
<tr>
207+
<td>
208+
<dfn data-dfn-for="top-level traversable">[[\PostureOverride]]
209+
</dfn>
210+
</td>
211+
<td>
212+
Posture to override posture defined by hardware. Used in
213+
automation. Possible values:
214+
<ul>
215+
<li>"{{DevicePostureType/continuous}}"
216+
</li>
217+
<li>"{{DevicePostureType/folded}}"
218+
</li>
219+
<li><code>null</code>: Used when posture is defined by hardware.
220+
</li>
221+
</ul>
222+
</td>
223+
</tr>
224+
</tbody>
225+
</table>
191226
</section>
192227
<section data-dfn-for="Navigator">
193228
<h2 id="extensions-to-the-navigator-interface">
@@ -445,6 +480,12 @@ <h2>
445480
{{Document}} |document:Document| are as follows:
446481
</p>
447482
<ol class="algorithm">
483+
<li>Let |topLevelTraversable| be |document|'s [=relevant global
484+
object=]'s [=navigable=]'s [=top-level traversable=].
485+
</li>
486+
<li>If |topLevelTraversable|.<a data-link-for="top-level traversable">
487+
[[\PostureOverride]]</a> is non-null, return it.
488+
</li>
448489
<li>Return a {{DevicePostureType}} value determined in an
449490
[=implementation-defined=] way based on the current hinge angle
450491
value, current <a data-cite=
@@ -690,6 +731,152 @@ <h2>
690731
</li>
691732
</ul>
692733
</section>
734+
<section>
735+
<h2>
736+
Automation
737+
</h2>
738+
<p>
739+
The Device Posture API pose a challenge to test authors, as fully
740+
exercising interface requires physical hardware devices. To address this
741+
challenge this document defines a [[WEBDRIVER2]] [=extension commands=]
742+
that allows users to control the reported device posture and simulate a
743+
real device.
744+
</p>
745+
<h3>
746+
Extension Commands
747+
</h3>
748+
<h4>
749+
Set device posture
750+
</h4>
751+
<table class="simple">
752+
<tr>
753+
<th>
754+
HTTP Method
755+
</th>
756+
<th>
757+
[=extension command URI Template|URI Template=]
758+
</th>
759+
</tr>
760+
<tr>
761+
<td>
762+
POST
763+
</td>
764+
<td>
765+
/session/{session id}/deviceposture
766+
</td>
767+
</tr>
768+
</table>
769+
<p>
770+
This [=extension command=] changes device posture to a specific
771+
{{DevicePostureType}}.
772+
</p>
773+
<table class="simple">
774+
<caption>
775+
Properties of the parameters argument used by this algorithm
776+
</caption>
777+
<tr>
778+
<th>
779+
Parameter name
780+
</th>
781+
<th>
782+
Value type
783+
</th>
784+
<th>
785+
Required
786+
</th>
787+
</tr>
788+
<tr>
789+
<td>
790+
posture
791+
</td>
792+
<td>
793+
String
794+
</td>
795+
<td>
796+
yes
797+
</td>
798+
</tr>
799+
</table>
800+
<p>
801+
The [=remote end steps=] are:
802+
</p>
803+
<ol class="algorithm" data-cite="WEBDRIVER2">
804+
<li>Let |posture| be the result of invoking
805+
<a data-cite="!WEBDRIVER2#dfn-getting-properties">get a property</a>
806+
"posture" from |parameters|.
807+
</li>
808+
<li>If |posture| is not a [=string=], return [=error=] with
809+
[=error code|WebDriver error code=] [=invalid argument=].
810+
</li>
811+
<li>If |posture| is neither "{{DevicePostureType/continuous}}" nor
812+
"{{DevicePostureType/folded}}", return [=error=] with
813+
[=error code|WebDriver error code=] [=invalid argument=].
814+
</li>
815+
<li>Let |topLevelTraversable| be the
816+
<a data-cite="webdriver2/#dfn-current-browsing-context">current browsing
817+
context</a>'s [=browsing context/top-level traversable=].
818+
</li>
819+
<li>Set |topLevelTraversable|.<a data-link-for="top-level traversable">
820+
[[\PostureOverride]]</a> to |posture|.
821+
</li>
822+
<li>Let |document| be |topLevelTraversable|'s [=navigable/active
823+
document=].
824+
</li>
825+
<li>Invoke [=device posture change steps=] with |document|.
826+
</li>
827+
<li>Return [=success=] with data <code>null</code>.
828+
</li>
829+
</ol>
830+
<h4>
831+
Clear device posture
832+
</h4>
833+
<table class="simple">
834+
<tr>
835+
<th>
836+
HTTP Method
837+
</th>
838+
<th>
839+
[=extension command URI Template|URI Template=]
840+
</th>
841+
</tr>
842+
<tr>
843+
<td>
844+
DELETE
845+
</td>
846+
<td>
847+
/session/{session id}/deviceposture
848+
</td>
849+
</tr>
850+
</table>
851+
<p>
852+
This [=extension command=] removes device posture override and returns
853+
device posture control back to hardware.
854+
</p>
855+
<p>
856+
The [=remote end steps=] are:
857+
</p>
858+
<ol class="algorithm">
859+
<li>Let |topLevelTraversable| be the
860+
<a data-cite="webdriver2/#dfn-current-browsing-context">current browsing
861+
context</a>'s [=browsing context/top-level traversable=].
862+
</li>
863+
<li>If |topLevelTraversable|.<a data-link-for="top-level traversable">
864+
[[\PostureOverride]]</a> is <code>null</code>, return [=success=] with
865+
data <code>null</code>.
866+
</li>
867+
<li>Set |topLevelTraversable|.<a data-link-for="top-level traversable">
868+
[[\PostureOverride]]</a> to
869+
<code>null</code>.
870+
</li>
871+
<li>Let |document| be |topLevelTraversable|'s [=navigable/active
872+
document=].
873+
</li>
874+
<li>Invoke [=device posture change steps=] with |document|.
875+
</li>
876+
<li>Return [=success=] with data <code>null</code>.
877+
</li>
878+
</ol>
879+
</section>
693880
<section id="examples" class="informative">
694881
<h2>
695882
Examples

0 commit comments

Comments
 (0)