Skip to content

Commit 69cc724

Browse files
Addition: support geolocation emulation (#183)
* feat: support geolocation emulation * Addition: support geolocation emulation * remove duplicated candidate additions * fix html * Update index.html Co-authored-by: Reilly Grant <[email protected]> * mention build tool * emulate `GeolocationPositionError` * Update index.html Co-authored-by: Reilly Grant <[email protected]> * Update index.html Co-authored-by: Reilly Grant <[email protected]> * Update index.html Co-authored-by: Reilly Grant <[email protected]> * Update index.html Co-authored-by: Reilly Grant <[email protected]> * Update index.html Co-authored-by: Reilly Grant <[email protected]> * Update index.html Co-authored-by: Reilly Grant <[email protected]> * Update index.html Co-authored-by: Reilly Grant <[email protected]> * |emulatedPositionData| * fix html * Move `emulated position data` after permission check * Update index.html Co-authored-by: Reilly Grant <[email protected]> --------- Co-authored-by: Reilly Grant <[email protected]>
1 parent 841f1c6 commit 69cc724

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ contributors in the pull request's body or in subsequent comments.
2525

2626
If you are making a pull request on behalf of someone else but you had no part in designing the
2727
feature, you can remove yourself with the above syntax.
28+
29+
To build a local copy of the specification, please refer to [respec documentation](https://respec.org/docs/#using-command-line).

index.html

+94
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,9 @@ <h2>
752752
change of geographic position is left to the
753753
implementation. User agents MAY impose a rate limit on how
754754
frequently position changes are reported.
755+
<ins cite="#a4"> User agents MUST consider
756+
invoking [=set emulated position data=] as a significant
757+
change.</ins>
755758
</li>
756759
<li>If |document| is not [=Document/fully active=] or
757760
[=Document/visibility state=] is not "visible", go back to
@@ -823,6 +826,38 @@ <h2>
823826
</li>
824827
<li>If |permission| is "granted":
825828
<ol>
829+
<li>
830+
<ins cite="#a4">Check if an emulated position should be used by running
831+
the following steps:
832+
<ol>
833+
<li>Let |emulatedPositionData| be [=get emulated position data=]
834+
passing [=this=].
835+
</li>
836+
<li>If |emulatedPositionData| is not null:
837+
<ol>
838+
<li>If |emulatedPositionData| is a {{GeolocationPositionError}}:
839+
<ol>
840+
<li>[=Call back with error=] passing |errorCallback| and
841+
|emulatedPositionData|.
842+
</li>
843+
<li>Terminate this algorithm.</li>
844+
</ol>
845+
</li>
846+
<li>Let |position| be [=a new `GeolocationPosition`=]
847+
passing |emulatedPositionData|, |acquisitionTime| and
848+
|options|.{{PositionOptions/enableHighAccuracy}}.
849+
</li>
850+
<li>[=Queue a task=] on the [=geolocation task source=] with
851+
a step that [=invokes=] |successCallback| with
852+
« |position| » and "`report`".
853+
</li>
854+
<li>Terminate this algorithm.
855+
</li>
856+
</ol>
857+
</li>
858+
</ol>
859+
</ins>
860+
</li>
826861
<li>Let |position| be null.
827862
</li>
828863
<li>If |cachedPosition| is not null, and
@@ -1472,6 +1507,65 @@ <h2>
14721507
feature/default allowlist=] is [=default allowlist/'self'=].
14731508
</p>
14741509
</section>
1510+
<section data-cite="html">
1511+
<h2>
1512+
Emulation
1513+
</h2>
1514+
<aside class="addition" id="a4">
1515+
<span class="marker">Candidate Addition:</span> Introduce emulated
1516+
position data to enable user-agent automation.
1517+
</aside><ins cite="#a4">
1518+
<p>
1519+
For the purposes of user-agent automation and application testing, this
1520+
document defines geolocation emulations.
1521+
</p>
1522+
<p>
1523+
Each [=top-level traversable=] has an associated
1524+
<dfn>emulated position data</dfn>, which is data representing
1525+
{{GeolocationCoordinates}}, {{GeolocationPositionError}} or null,
1526+
initially null.
1527+
</p>
1528+
<p>
1529+
To <dfn class="export">set emulated position data</dfn>, given
1530+
[=navigable=] |navigable| and an |emulatedPositionData|:
1531+
</p>
1532+
<ol class="algorithm">
1533+
<li>Assert |emulatedPositionData| is either null, a
1534+
{{GeolocationCoordinates}}, or a {{GeolocationPositionError}}.
1535+
</li>
1536+
<li>Let |traversable| be |navigable|’s [=navigable/top-level traversable=].
1537+
</li>
1538+
<li>If |traversable| is not null:
1539+
<ol class="algorithm">
1540+
<li>Set |traversable|'s associated [=emulated position data=] to
1541+
|emulatedPositionData|.
1542+
</li>
1543+
<li>User agents MUST consider this as a "significant change" in the
1544+
<a href="#wait-for-change">wait for a significant change of
1545+
geographic position</a> step.
1546+
</li>
1547+
</ol>
1548+
</li>
1549+
</ol>
1550+
<p>
1551+
To <dfn>get emulated position data</dfn>, given {{Geolocation}}
1552+
|geolocation|:
1553+
</p>
1554+
<ol class="algorithm">
1555+
<li>Let |navigable| be |geolocation|'s [=relevant global object=]'s
1556+
[=associated `Document`=]'s [=node navigable=].
1557+
</li>
1558+
<li>If |navigable| is null, return null.
1559+
</li>
1560+
<li>Let |traversable| be |navigable|’s [=navigable/top-level traversable=].
1561+
</li>
1562+
<li>If |traversable| is null, return null.
1563+
</li>
1564+
<li>Return |traversable|'s associated [=emulated position data=].
1565+
</li>
1566+
</ol>
1567+
</ins>
1568+
</section>
14751569
<section id="conformance"></section>
14761570
<section id="idl-index" class="appendix">
14771571
<!-- All the Web IDL will magically appear here -->

0 commit comments

Comments
 (0)