Addition: support geolocation emulation (#183) · w3c/geolocation@69cc724 (original) (raw)
`@@ -752,6 +752,9 @@
`
752
752
` change of geographic position is left to the
`
753
753
` implementation. User agents MAY impose a rate limit on how
`
754
754
` frequently position changes are reported.
`
``
755
`+
User agents MUST consider
`
``
756
`+
invoking [=set emulated position data=] as a significant
`
``
757
`+
change.
`
755
758
`
`
756
759
`
`
757
760
` [=Document/visibility state=] is not "visible", go back to
`
`@@ -823,6 +826,38 @@
`
823
826
`
`
824
827
`
`
825
828
`
-
`
``
830
`+
Check if an emulated position should be used by running
`
``
831
`+
the following steps:
`
``
832
`+
- Let |emulatedPositionData| be [=get emulated position data=]
`
``
834
`+
passing [=this=].
`
``
835
`+
- If |emulatedPositionData| is not null:
`
``
837
`+
- If |emulatedPositionData| is a {{GeolocationPositionError}}:
`
``
839
`+
- [=Call back with error=] passing |errorCallback| and
`
``
841
`+
|emulatedPositionData|.
`
``
842
`+
- Terminate this algorithm.
`
``
840
`+
`
``
843
`+
`
``
844
`+
`
``
845
`+
- [=Call back with error=] passing |errorCallback| and
- Let |position| be [=a new `GeolocationPosition`=]
``
``
847
`+
passing |emulatedPositionData|, |acquisitionTime| and
`
``
848
`+
|options|.{{PositionOptions/enableHighAccuracy}}.
`
``
849
`+
- [=Queue a task=] on the [=geolocation task source=] with
`
``
851
`+
a step that [=invokes=] |successCallback| with
`
``
852
`` +
« |position| » and "
report
".``
``
853
`+
- Terminate this algorithm.
`
``
855
`+
`
``
838
`+
`
``
846
`` +
`
``
850
`+
`
``
854
`+
`
``
856
`+
`
``
857
`+
- If |emulatedPositionData| is a {{GeolocationPositionError}}:
`
``
833
`+
`
``
836
`+
`
``
858
`+
`
``
859
`+
`
``
860
`+
- Let |emulatedPositionData| be [=get emulated position data=]
- Let |position| be null.
- If |cachedPosition| is not null, and
- Assert |emulatedPositionData| is either null, a
`
``
1534
`+
{{GeolocationCoordinates}}, or a {{GeolocationPositionError}}.
`
``
1535
`+
- Let |traversable| be |navigable|’s [=navigable/top-level traversable=].
`
``
1537
`+
- If |traversable| is not null:
`
``
1539
`+
- Set |traversable|'s associated [=emulated position data=] to
`
``
1541
`+
|emulatedPositionData|.
`
``
1542
`+
- User agents MUST consider this as a "significant change" in the
`
``
1544
`+
wait for a significant change of
`
``
1545
`+
geographic position step.
`
``
1546
`+
`
``
1540
`+
`
``
1543
`+
`
``
1547
`+
`
``
1548
`+
- Set |traversable|'s associated [=emulated position data=] to
- Let |navigable| be |geolocation|'s [=relevant global object=]'s
`
``
1556
`` +
[=associated
Document
=]'s [=node navigable=].``
``
1557
`+
- If |navigable| is null, return null.
`
``
1559
`+
- Let |traversable| be |navigable|’s [=navigable/top-level traversable=].
`
``
1561
`+
- If |traversable| is null, return null.
`
``
1563
`+
- Return |traversable|'s associated [=emulated position data=].
`
``
1565
`+
`
``
829
`+
`
826
861
`
`
827
862
`
`
828
863
`
`
`@@ -1472,6 +1507,65 @@
`
1472
1507
` feature/default allowlist=] is [=default allowlist/'self'=].
`
1473
1508
`
`
1474
1509
`
`
``
1510
`+
`
``
1511
`+
`
``
1512
`+
Emulation
`
``
1513
`+
`
``
1514
`+
`
``
1518
`+
`
``
1519
`+
For the purposes of user-agent automation and application testing, this
`
``
1520
`+
document defines geolocation emulations.
`
``
1521
`+
`
``
1522
`+
`
``
1523
`+
Each [=top-level traversable=] has an associated
`
``
1524
`+
emulated position data, which is data representing
`
``
1525
`+
{{GeolocationCoordinates}}, {{GeolocationPositionError}} or null,
`
``
1526
`+
initially null.
`
``
1527
`+
`
``
1528
`+
`
``
1529
`+
To set emulated position data, given
`
``
1530
`+
[=navigable=] |navigable| and an |emulatedPositionData|:
`
``
1531
`+
`
``
1532
`+
`
``
1533
`+
`
``
1536
`+
`
``
1538
`+
`
``
1549
`+
`
``
1550
`+
`
``
1551
`+
To get emulated position data, given {{Geolocation}}
`
``
1552
`+
|geolocation|:
`
``
1553
`+
`
``
1554
`+
`
``
1555
`+
`
``
1558
`+
`
``
1560
`+
`
``
1562
`+
`
``
1564
`+
`
``
1566
`+
`
``
1567
`+
`
``
1568
`+
`
1475
1569
`
`
1476
1570
`
`
1477
1571
`
`