Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <meta charset=utf-8> | |
| 5 <title>WebVR IDL test</title> | |
| 6 <link rel="help" href="https://w3c.github.io/webvr/"> | |
| 7 | |
| 8 <script src=../../../resources/testharness.js></script> | |
| 9 <script src=../../../resources/testharnessreport.js></script> | |
| 10 <script src=../../../resources/WebIDLParser.js></script> | |
| 11 <script src=../../../resources/idlharness.js></script> | |
| 12 <script id="webvr_idl" type=text/plain> | |
| 13 // Archived version of the WebVR spec from | |
| 14 // https://w3c.github.io/webvr/archive/prerelease/1.1/index.html | |
| 15 | |
| 16 interface VRDisplay : EventTarget { | |
| 17 readonly attribute boolean isConnected; | |
| 18 readonly attribute boolean isPresenting; | |
| 19 | |
| 20 /** | |
| 21 * Dictionary of capabilities describing the VRDisplay. | |
| 22 */ | |
| 23 [SameObject] readonly attribute VRDisplayCapabilities capabilities; | |
| 24 | |
| 25 /** | |
| 26 * If this VRDisplay supports room-scale experiences, the optional | |
| 27 * stage attribute contains details on the room-scale parameters. | |
| 28 * The stageParameters attribute can not change between null | |
| 29 * and non-null once the VRDisplay is enumerated; however, | |
| 30 * the values within VRStageParameters may change after | |
| 31 * any call to VRDisplay.submitFrame as the user may re-configure | |
| 32 * their environment at any time. | |
| 33 */ | |
| 34 readonly attribute VRStageParameters? stageParameters; | |
| 35 | |
| 36 /** | |
| 37 * Return the current VREyeParameters for the given eye. | |
| 38 */ | |
| 39 VREyeParameters getEyeParameters(VREye whichEye); | |
| 40 | |
| 41 /** | |
| 42 * An identifier for this distinct VRDisplay. Used as an | |
| 43 * association point in the Gamepad API. | |
| 44 */ | |
| 45 readonly attribute unsigned long displayId; | |
| 46 | |
| 47 /** | |
| 48 * A display name, a user-readable name identifying it. | |
| 49 */ | |
| 50 readonly attribute DOMString displayName; | |
| 51 | |
| 52 /** | |
| 53 * Populates the passed VRFrameData with the information required to render | |
| 54 * the current frame. | |
| 55 */ | |
| 56 boolean getFrameData(VRFrameData frameData); | |
| 57 | |
| 58 /** | |
| 59 * Return a VRPose containing the future predicted pose of the VRDisplay | |
| 60 * when the current frame will be presented. The value returned will not | |
| 61 * change until JavaScript has returned control to the browser. | |
| 62 * | |
| 63 * The VRPose will contain the position, orientation, velocity, | |
| 64 * and acceleration of each of these properties. | |
| 65 */ | |
| 66 [NewObject] VRPose getPose(); | |
| 67 | |
| 68 /** | |
| 69 * Reset the pose for this display, treating its current position and | |
| 70 * orientation as the "origin/zero" values. VRPose.position, | |
| 71 * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be | |
| 72 * updated when calling resetPose(). This should be called in only | |
| 73 * sitting-space experiences. | |
| 74 */ | |
| 75 void resetPose(); | |
| 76 | |
| 77 /** | |
| 78 * z-depth defining the near plane of the eye view frustum | |
| 79 * enables mapping of values in the render target depth | |
| 80 * attachment to scene coordinates. Initially set to 0.01. | |
| 81 */ | |
| 82 attribute double depthNear; | |
| 83 | |
| 84 /** | |
| 85 * z-depth defining the far plane of the eye view frustum | |
| 86 * enables mapping of values in the render target depth | |
| 87 * attachment to scene coordinates. Initially set to 10000.0. | |
| 88 */ | |
| 89 attribute double depthFar; | |
| 90 | |
| 91 /** | |
| 92 * The callback passed to `requestAnimationFrame` will be called | |
| 93 * any time a new frame should be rendered. When the VRDisplay is | |
| 94 * presenting the callback will be called at the native refresh | |
| 95 * rate of the HMD. When not presenting this function acts | |
| 96 * identically to how window.requestAnimationFrame acts. Content should | |
| 97 * make no assumptions of frame rate or vsync behavior as the HMD runs | |
| 98 * asynchronously from other displays and at differing refresh rates. | |
| 99 */ | |
| 100 long requestAnimationFrame(FrameRequestCallback callback); | |
| 101 | |
| 102 /** | |
| 103 * Passing the value returned by `requestAnimationFrame` to | |
| 104 * `cancelAnimationFrame` will unregister the callback. | |
| 105 */ | |
| 106 void cancelAnimationFrame(long handle); | |
| 107 | |
| 108 /** | |
| 109 * Begin presenting to the VRDisplay. Must be called in response to a user ges ture. | |
| 110 * Repeat calls while already presenting will update the VRLayers being displa yed. | |
| 111 * If the number of values in the leftBounds/rightBounds arrays is not 0 or 4 for any of the passed layers the promise is rejected | |
| 112 * If the source of any of the layers is not present (null), the promise is re jected. | |
| 113 */ | |
| 114 Promise<void> requestPresent(sequence<VRLayer> layers); | |
| 115 | |
| 116 /** | |
| 117 * Stops presenting to the VRDisplay. | |
| 118 */ | |
| 119 Promise<void> exitPresent(); | |
| 120 | |
| 121 /** | |
| 122 * Get the layers currently being presented. | |
| 123 */ | |
| 124 sequence<VRLayer> getLayers(); | |
| 125 | |
| 126 /** | |
| 127 * The VRLayer provided to the VRDisplay will be captured and presented | |
| 128 * in the HMD. Calling this function has the same effect on the source | |
| 129 * canvas as any other operation that uses its source image, and canvases | |
| 130 * created without preserveDrawingBuffer set to true will be cleared. | |
| 131 */ | |
| 132 void submitFrame(); | |
| 133 }; | |
| 134 | |
| 135 typedef (HTMLCanvasElement or | |
| 136 OffscreenCanvas) VRSource; | |
| 137 | |
| 138 dictionary VRLayer { | |
| 139 VRSource? source = null; | |
| 140 | |
| 141 sequence<float> leftBounds = []; | |
| 142 sequence<float> rightBounds = []; | |
| 143 }; | |
| 144 | |
| 145 interface VRDisplayCapabilities { | |
| 146 readonly attribute boolean hasPosition; | |
| 147 readonly attribute boolean hasOrientation; | |
| 148 readonly attribute boolean hasExternalDisplay; | |
| 149 readonly attribute boolean canPresent; | |
| 150 readonly attribute unsigned long maxLayers; | |
| 151 }; | |
| 152 | |
| 153 enum VREye { | |
| 154 "left", | |
| 155 "right" | |
| 156 }; | |
| 157 | |
| 158 interface VRFieldOfView { | |
| 159 readonly attribute double upDegrees; | |
| 160 readonly attribute double rightDegrees; | |
| 161 readonly attribute double downDegrees; | |
| 162 readonly attribute double leftDegrees; | |
| 163 }; | |
| 164 | |
| 165 interface VRPose { | |
| 166 readonly attribute Float32Array? position; | |
| 167 readonly attribute Float32Array? linearVelocity; | |
| 168 readonly attribute Float32Array? linearAcceleration; | |
| 169 | |
| 170 readonly attribute Float32Array? orientation; | |
| 171 readonly attribute Float32Array? angularVelocity; | |
| 172 readonly attribute Float32Array? angularAcceleration; | |
| 173 }; | |
| 174 | |
| 175 [Constructor] | |
| 176 interface VRFrameData { | |
| 177 readonly attribute DOMHighResTimeStamp timestamp; | |
| 178 | |
| 179 readonly attribute Float32Array leftProjectionMatrix; | |
| 180 readonly attribute Float32Array leftViewMatrix; | |
| 181 | |
| 182 readonly attribute Float32Array rightProjectionMatrix; | |
| 183 readonly attribute Float32Array rightViewMatrix; | |
| 184 | |
| 185 readonly attribute VRPose pose; | |
| 186 }; | |
| 187 | |
| 188 interface VREyeParameters { | |
| 189 readonly attribute Float32Array offset; | |
| 190 | |
| 191 [SameObject] readonly attribute VRFieldOfView fieldOfView; | |
| 192 | |
| 193 readonly attribute unsigned long renderWidth; | |
| 194 readonly attribute unsigned long renderHeight; | |
| 195 }; | |
| 196 | |
| 197 interface VRStageParameters { | |
| 198 readonly attribute Float32Array sittingToStandingTransform; | |
| 199 | |
| 200 readonly attribute float sizeX; | |
| 201 readonly attribute float sizeZ; | |
| 202 }; | |
| 203 | |
| 204 partial interface Navigator { | |
| 205 Promise<sequence<VRDisplay>> getVRDisplays(); | |
| 206 readonly attribute FrozenArray<VRDisplay> activeVRDisplays; | |
| 207 readonly attribute boolean vrEnabled; | |
| 208 }; | |
| 209 | |
| 210 enum VRDisplayEventReason { | |
| 211 "mounted", | |
| 212 "navigation", | |
| 213 "requested", | |
| 214 "unmounted" | |
| 215 }; | |
| 216 | |
| 217 [Constructor(DOMString type, VRDisplayEventInit eventInitDict)] | |
| 218 interface VRDisplayEvent : Event { | |
| 219 readonly attribute VRDisplay display; | |
| 220 readonly attribute VRDisplayEventReason? reason; | |
| 221 }; | |
| 222 | |
| 223 dictionary VRDisplayEventInit : EventInit { | |
| 224 required VRDisplay display; | |
| 225 VRDisplayEventReason reason; | |
| 226 }; | |
| 227 | |
| 228 partial interface Window { | |
| 229 attribute EventHandler onvrdisplayconnect; | |
| 230 attribute EventHandler onvrdisplaydisconnect; | |
| 231 attribute EventHandler onvrdisplayactivate; | |
| 232 attribute EventHandler onvrdisplaydeactivate; | |
| 233 attribute EventHandler onvrdisplayblur; | |
| 234 attribute EventHandler onvrdisplayfocus; | |
| 235 attribute EventHandler onvrdisplaypresentchange; | |
| 236 }; | |
| 237 | |
| 238 partial interface HTMLIFrameElement { | |
| 239 attribute boolean allowvr; | |
| 240 }; | |
| 241 | |
| 242 partial interface Gamepad { | |
| 243 readonly attribute unsigned long displayId; | |
| 244 }; | |
| 245 </script> | |
| 246 </head> | |
| 247 <body> | |
| 248 <h1 class="instructions">Description</h1> | |
| 249 <p class="instructions"> | |
| 250 This test verifies that implementations of the WebVR API match its WebIDL definition. | |
| 251 </p> | |
| 252 | |
| 253 <div id='log'></div> | |
| 254 | |
| 255 <script> | |
| 256 setup( () => { | |
| 257 var idl_array = new IdlArray(); | |
| 258 idl_array.add_untested_idls("[PrimaryGlobal] interface Window {};"); | |
| 259 idl_array.add_untested_idls("interface Navigator {};"); | |
| 260 idl_array.add_untested_idls("interface ArrayBuffer {};"); | |
| 261 idl_array.add_untested_idls("interface HTMLMediaElement {};"); | |
|
Lei Lei
2016/12/20 18:22:17
Why do we need to test HTMLMediaElement?
Should w
bsheedy
2016/12/20 18:31:06
HTMLMediaElement and ArrayBuffer were leftover fro
Lei Lei
2016/12/20 18:34:07
Please remove those two lines if not needed.
| |
| 262 idl_array.add_untested_idls("interface Event {};"); | |
| 263 idl_array.add_untested_idls("interface EventTarget {};"); | |
| 264 idl_array.add_untested_idls("interface HTMLIFrameElement {};"); | |
| 265 idl_array.add_untested_idls("interface Gamepad {};"); | |
| 266 | |
| 267 idl_array.add_idls(document.getElementById("webvr_idl").textContent); | |
| 268 | |
| 269 idl_array.test(); | |
| 270 done(); | |
| 271 }, {explicit_done: true}); | |
| 272 </script> | |
| 273 </body> | |
| 274 </html> | |
| OLD | NEW |