summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/geolocation-API/interfaces.html
blob: 0db4204653dcf86f20d850e3f31c38059992248f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<meta charset="utf-8">
<title>Geolocation API IDL tests</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://www.w3.org/TR/geolocation-API/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>

<h1>Geolocation API IDL tests</h1>
<div id="log"></div>

<script type=text/plain class=untested>
interface Navigator {
};

typedef unsigned long long DOMTimeStamp;
</script>

<script type=text/plain>
partial interface Navigator {
  readonly attribute Geolocation geolocation;
};

[NoInterfaceObject]
interface Geolocation {
  void getCurrentPosition(PositionCallback successCallback,
                          optional PositionErrorCallback errorCallback,
                          optional PositionOptions options);

  long watchPosition(PositionCallback successCallback,
                     optional PositionErrorCallback errorCallback,
                     optional PositionOptions options);

  void clearWatch(long watchId);
};

callback PositionCallback = void (Position position);

callback PositionErrorCallback = void (PositionError positionError);

dictionary PositionOptions {
  boolean enableHighAccuracy = false;
  [Clamp] unsigned long timeout = 0xFFFFFFFF;
  [Clamp] unsigned long maximumAge = 0;
};

[NoInterfaceObject]
interface Position {
  readonly attribute Coordinates coords;
  readonly attribute DOMTimeStamp timestamp;
};

[NoInterfaceObject]
interface Coordinates {
  readonly attribute double latitude;
  readonly attribute double longitude;
  readonly attribute double? altitude;
  readonly attribute double accuracy;
  readonly attribute double? altitudeAccuracy;
  readonly attribute double? heading;
  readonly attribute double? speed;
};

[NoInterfaceObject]
interface PositionError {
  const unsigned short PERMISSION_DENIED = 1;
  const unsigned short POSITION_UNAVAILABLE = 2;
  const unsigned short TIMEOUT = 3;
  readonly attribute unsigned short code;
  readonly attribute DOMString message;
};
</script>

<script>
"use strict";
var idlArray;
setup(function() {
  idlArray = new IdlArray();
  [].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) {
    if (node.className == "untested") {
      idlArray.add_untested_idls(node.textContent);
    } else {
      idlArray.add_idls(node.textContent);
    }
  });
  idlArray.add_objects({
    Navigator: ["navigator"],
    Geolocation: ["navigator.geolocation"]
  });
});
idlArray.test();
</script>