OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <title>Accelerometer Sensor IDL tests</title> |
| 4 <link rel="author" title="Intel" href="http://www.intel.com"> |
| 5 <link rel="help" href="https://www.w3.org/TR/accelerometer/"> |
| 6 <script src="/resources/testharness.js"></script> |
| 7 <script src="/resources/testharnessreport.js"></script> |
| 8 <script src="/resources/WebIDLParser.js"></script> |
| 9 <script src="/resources/idlharness.js"></script> |
| 10 <style> |
| 11 pre { |
| 12 display: none; |
| 13 } |
| 14 </style> |
| 15 <div id="log"></div> |
| 16 |
| 17 <pre id="idl"> |
| 18 interface Event { |
| 19 }; |
| 20 |
| 21 interface EventTarget { |
| 22 }; |
| 23 |
| 24 interface EventHandler { |
| 25 }; |
| 26 |
| 27 interface Error { |
| 28 }; |
| 29 |
| 30 dictionary EventInit { |
| 31 }; |
| 32 </pre> |
| 33 |
| 34 <pre id="generic-idl"> |
| 35 [SecureContext] |
| 36 interface Sensor : EventTarget { |
| 37 readonly attribute SensorState state; |
| 38 readonly attribute SensorReading? reading; |
| 39 void start(); |
| 40 void stop(); |
| 41 attribute EventHandler onchange; |
| 42 attribute EventHandler onactivate; |
| 43 attribute EventHandler onerror; |
| 44 }; |
| 45 |
| 46 dictionary SensorOptions { |
| 47 double? frequency; |
| 48 }; |
| 49 |
| 50 enum SensorState { |
| 51 "idle", |
| 52 "activating", |
| 53 "activated", |
| 54 "errored" |
| 55 }; |
| 56 |
| 57 [SecureContext] |
| 58 interface SensorReading { |
| 59 readonly attribute DOMHighResTimeStamp timeStamp; |
| 60 }; |
| 61 |
| 62 [SecureContext, Constructor(DOMString type, SensorErrorEventInit errorEventInitD
ict)] |
| 63 interface SensorErrorEvent : Event { |
| 64 readonly attribute Error error; |
| 65 }; |
| 66 |
| 67 dictionary SensorErrorEventInit : EventInit { |
| 68 required Error error; |
| 69 }; |
| 70 |
| 71 </pre> |
| 72 |
| 73 <pre id="accelerometer-idl"> |
| 74 [Constructor(optional AccelerometerOptions accelerometerOptions)] |
| 75 interface Accelerometer : Sensor { |
| 76 readonly attribute AccelerometerReading? reading; |
| 77 readonly attribute boolean includesGravity; |
| 78 }; |
| 79 |
| 80 dictionary AccelerometerOptions : SensorOptions { |
| 81 boolean includeGravity = true; |
| 82 }; |
| 83 |
| 84 [Constructor(AccelerometerReadingInit AccelerometerReadingInit)] |
| 85 interface AccelerometerReading : SensorReading { |
| 86 readonly attribute double x; |
| 87 readonly attribute double y; |
| 88 readonly attribute double z; |
| 89 }; |
| 90 |
| 91 dictionary AccelerometerReadingInit { |
| 92 double x = 0; |
| 93 double y = 0; |
| 94 double z = 0; |
| 95 }; |
| 96 </pre> |
| 97 |
| 98 <script> |
| 99 (function() { |
| 100 "use strict"; |
| 101 var idl_array = new IdlArray(); |
| 102 idl_array.add_untested_idls(document.getElementById('idl').textContent); |
| 103 idl_array.add_untested_idls(document.getElementById('generic-idl').textContent
); |
| 104 idl_array.add_idls(document.getElementById('accelerometer-idl').textContent); |
| 105 |
| 106 idl_array.add_objects({ |
| 107 Accelerometer: ['new Accelerometer();'], |
| 108 AccelerometerReading: ['new AccelerometerReading({x: 0.5, y: 0.5, z: 0.5});'
] |
| 109 }); |
| 110 |
| 111 idl_array.test(); |
| 112 })(); |
| 113 </script> |
OLD | NEW |