Skip to content

Commit

Permalink
Added vrEnabled attribute to Document
Browse files Browse the repository at this point in the history
Also addressed comments from @cvan
  • Loading branch information
toji committed Sep 13, 2016
1 parent 1328cc7 commit f8d15c6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
16 changes: 13 additions & 3 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ partial interface Navigator {
### Attributes ### {#navigator-attributes}

<dfn method for="Navigator" id="navigator-getvrdisplays-attribute">getVRDisplays()</dfn>
Return a Promise which resolves to a list of available {{VRDisplay}}s. If the Document object is inside an iframe that does not have the {{allowvr}} attribute set the returned Promise MUST be rejected.
Return a Promise which resolves to a list of available {{VRDisplay}}s. The Promise MUST be rejected if the {{Document}} object is inside an iframe that does not have the {{allowvr}} attribute set.

<dfn attribute for="Navigator" id="navigator-activevrdisplays-attribute">activeVRDisplays</dfn>
{{activeVRDisplays}} includes every {{VRDisplay}} that is currently presenting.
Expand Down Expand Up @@ -678,10 +678,10 @@ partial interface HTMLIFrameElement {
};
</pre>

The {{allowvr}} attribute is a boolean attribute. When specified, it indicates that Document objects in the iframe element's browsing context are to be allowed to access VR devices (if it's not blocked for other reasons, e.g. there is another ancestor iframe without this attribute set). Document objects in an iframe element without this attribute should reject calls to {{getVRDisplays()}} and should not fire any {{VRDisplayEvent}}.
The {{allowvr}} attribute is a boolean attribute. When specified, it indicates that {{Document}} objects in the iframe element's browsing context are to be allowed to access VR devices (if it's not blocked for other reasons, e.g. there is another ancestor iframe without this attribute set). {{Document}} objects in an iframe element without this attribute should reject calls to {{getVRDisplays()}} and should not fire any {{VRDisplayEvent}}.

<div class="example">
Example of declaring an iframe which is allowed to access VR features.
Example of declaring an iframe that is allowed to access VR features.

<pre class="lang-js">
&lt;body&gt;
Expand All @@ -691,6 +691,16 @@ Example of declaring an iframe which is allowed to access VR features.
</pre>
</div>

## vrEnabled Document attribute ## {#vrenabled-attribute}

<pre class="idl">
partial interface Document {
attribute boolean vrEnabled;
};
</pre>

The {{vrEnabled}} attribute's getter must return true if the context object is allowed to use the feature indicated by attribute name {{allowvr}} and VR is supported, and false otherwise.

## Gamepad Interface extension ## {#interface-gamepad}

<pre class="idl">
Expand Down
46 changes: 33 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@
<div class="head">
<p data-fill-with="logo"></p>
<h1 class="p-name no-ref" id="title">WebVR</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2016-09-12">12 September 2016</time></span></h2>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2016-09-13">13 September 2016</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
Expand Down Expand Up @@ -1521,10 +1521,11 @@ <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
</ol>
<li><a href="#interface-window"><span class="secno">2.13</span> <span class="content">Window Interface extension</span></a>
<li><a href="#allowvr-attribute"><span class="secno">2.14</span> <span class="content">allowvr iframe attribute</span></a>
<li><a href="#vrenabled-attribute"><span class="secno">2.15</span> <span class="content">vrEnabled Document attribute</span></a>
<li>
<a href="#interface-gamepad"><span class="secno">2.15</span> <span class="content">Gamepad Interface extension</span></a>
<a href="#interface-gamepad"><span class="secno">2.16</span> <span class="content">Gamepad Interface extension</span></a>
<ol class="toc">
<li><a href="#gamepad-attributes"><span class="secno">2.15.1</span> <span class="content">Attributes</span></a>
<li><a href="#gamepad-attributes"><span class="secno">2.16.1</span> <span class="content">Attributes</span></a>
</ol>
</ol>
<li><a href="#security"><span class="secno">3</span> <span class="content">Security Considerations</span></a>
Expand Down Expand Up @@ -1937,7 +1938,7 @@ <h3 class="heading settled" data-level="2.10" id="interface-navigator"><span cla
};
</pre>
<h4 class="heading settled" data-level="2.10.1" id="navigator-attributes"><span class="secno">2.10.1. </span><span class="content">Attributes</span><a class="self-link" href="#navigator-attributes"></a></h4>
<p><dfn class="dfn-paneled idl-code" data-dfn-for="Navigator" data-dfn-type="method" data-export="" id="navigator-getvrdisplays-attribute">getVRDisplays()</dfn> Return a Promise which resolves to a list of available <code class="idl"><a data-link-type="idl" href="#vrdisplay" id="ref-for-vrdisplay-42">VRDisplay</a></code>s. If the Document object is inside an iframe that does not have the <code class="idl"><a data-link-type="idl" href="#dom-htmliframeelement-allowvr" id="ref-for-dom-htmliframeelement-allowvr-1">allowvr</a></code> attribute set the returned Promise MUST be rejected.</p>
<p><dfn class="dfn-paneled idl-code" data-dfn-for="Navigator" data-dfn-type="method" data-export="" id="navigator-getvrdisplays-attribute">getVRDisplays()</dfn> Return a Promise which resolves to a list of available <code class="idl"><a data-link-type="idl" href="#vrdisplay" id="ref-for-vrdisplay-42">VRDisplay</a></code>s. The Promise MUST be rejected if the Document object is inside an iframe that does not have the <code class="idl"><a data-link-type="idl" href="#dom-htmliframeelement-allowvr" id="ref-for-dom-htmliframeelement-allowvr-1">allowvr</a></code> attribute set.</p>
<p><dfn class="dfn-paneled idl-code" data-dfn-for="Navigator" data-dfn-type="attribute" data-export="" id="navigator-activevrdisplays-attribute">activeVRDisplays</dfn> <code class="idl"><a data-link-type="idl" href="#navigator-activevrdisplays-attribute" id="ref-for-navigator-activevrdisplays-attribute-2">activeVRDisplays</a></code> includes every <code class="idl"><a data-link-type="idl" href="#vrdisplay" id="ref-for-vrdisplay-43">VRDisplay</a></code> that is currently presenting.</p>
<div class="example" id="example-008f898a">
<a class="self-link" href="#example-008f898a"></a> The following code finds the first available <code class="idl"><a data-link-type="idl" href="#vrdisplay" id="ref-for-vrdisplay-44">VRDisplay</a></code>.
Expand Down Expand Up @@ -1999,21 +2000,27 @@ <h3 class="heading settled" data-level="2.14" id="allowvr-attribute"><span class
<span class="kt">attribute</span> <span class="kt">boolean</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="HTMLIFrameElement" data-dfn-type="attribute" data-export="" data-type="boolean" id="dom-htmliframeelement-allowvr">allowvr</dfn>;
};
</pre>
<p>The <code class="idl"><a data-link-type="idl" href="#dom-htmliframeelement-allowvr" id="ref-for-dom-htmliframeelement-allowvr-2">allowvr</a></code> attribute is a boolean attribute. When specified, it indicates that Document objects in the iframe element’s browsing context are to be allowed to access VR devices (if it’s not blocked for other reasons, e.g. there is another ancestor iframe without this attribute set). Document objects in an iframe element without this attribute should reject calls to <code class="idl"><a data-link-type="idl" href="#navigator-getvrdisplays-attribute" id="ref-for-navigator-getvrdisplays-attribute-2">getVRDisplays()</a></code> and should not fire any <code class="idl"><a data-link-type="idl" href="#vrdisplayevent" id="ref-for-vrdisplayevent-2">VRDisplayEvent</a></code>.</p>
<div class="example" id="example-5c12ea46">
<a class="self-link" href="#example-5c12ea46"></a> Example of declaring an iframe which is allowed to access VR features.
<p>The <code class="idl"><a data-link-type="idl" href="#dom-htmliframeelement-allowvr" id="ref-for-dom-htmliframeelement-allowvr-2">allowvr</a></code> attribute is a boolean attribute. When specified, it indicates that <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/dom.html#document">Document</a></code> objects in the iframe element’s browsing context are to be allowed to access VR devices (if it’s not blocked for other reasons, e.g. there is another ancestor iframe without this attribute set). Document objects in an iframe element without this attribute should reject calls to <code class="idl"><a data-link-type="idl" href="#navigator-getvrdisplays-attribute" id="ref-for-navigator-getvrdisplays-attribute-2">getVRDisplays()</a></code> and should not fire any <code class="idl"><a data-link-type="idl" href="#vrdisplayevent" id="ref-for-vrdisplayevent-2">VRDisplayEvent</a></code>.</p>
<div class="example" id="example-9fa4da2d">
<a class="self-link" href="#example-9fa4da2d"></a> Example of declaring an iframe that is allowed to access VR features.
<pre class="lang-js highlight"><span class="o">&lt;</span>body<span class="o">></span>
<span class="o">&lt;</span>p<span class="o">></span>This iframe is allowed to use VR features<span class="o">&lt;</span>/p>
<span class="o">&lt;</span>iframe src<span class="o">=</span><span class="s2">"https://vr.example.com/embed?id=67445"</span> allowvr<span class="o">></span><span class="o">&lt;</span>/iframe>
<span class="o">&lt;</span>/body>
</pre>
</div>
<h3 class="heading settled" data-level="2.15" id="interface-gamepad"><span class="secno">2.15. </span><span class="content">Gamepad Interface extension</span><a class="self-link" href="#interface-gamepad"></a></h3>
<h3 class="heading settled" data-level="2.15" id="vrenabled-attribute"><span class="secno">2.15. </span><span class="content">vrEnabled Document attribute</span><a class="self-link" href="#vrenabled-attribute"></a></h3>
<pre class="idl highlight def"><span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/dom.html#document">Document</a> {
<span class="kt">attribute</span> <span class="kt">boolean</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Document" data-dfn-type="attribute" data-export="" data-type="boolean" id="dom-document-vrenabled">vrEnabled</dfn>;
};
</pre>
<p>The <code class="idl"><a data-link-type="idl" href="#dom-document-vrenabled" id="ref-for-dom-document-vrenabled-1">vrEnabled</a></code> attribute’s getter must return true if the context object is allowed to use the feature indicated by attribute name <code class="idl"><a data-link-type="idl" href="#dom-htmliframeelement-allowvr" id="ref-for-dom-htmliframeelement-allowvr-3">allowvr</a></code> and VR is supported, and false otherwise.</p>
<h3 class="heading settled" data-level="2.16" id="interface-gamepad"><span class="secno">2.16. </span><span class="content">Gamepad Interface extension</span><a class="self-link" href="#interface-gamepad"></a></h3>
<pre class="idl highlight def"><span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://www.w3.org/TR/gamepad/#gamepad">Gamepad</a> {
<span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">unsigned</span> <span class="kt">long</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="unsigned long" href="#gamepad-getvrdisplays-attribute" id="ref-for-gamepad-getvrdisplays-attribute-1">displayId</a>;
};
</pre>
<h4 class="heading settled" data-level="2.15.1" id="gamepad-attributes"><span class="secno">2.15.1. </span><span class="content">Attributes</span><a class="self-link" href="#gamepad-attributes"></a></h4>
<h4 class="heading settled" data-level="2.16.1" id="gamepad-attributes"><span class="secno">2.16.1. </span><span class="content">Attributes</span><a class="self-link" href="#gamepad-attributes"></a></h4>
<p><dfn class="dfn-paneled idl-code" data-dfn-for="Gamepad" data-dfn-type="attribute" data-export="" id="gamepad-getvrdisplays-attribute">displayId</dfn> Return the <code class="idl"><a data-link-type="idl" href="#dom-vrdisplay-displayid" id="ref-for-dom-vrdisplay-displayid-1">displayId</a></code> for the associated <code class="idl"><a data-link-type="idl" href="#vrdisplay" id="ref-for-vrdisplay-58">VRDisplay</a></code>.</p>
<h2 class="heading settled" data-level="3" id="security"><span class="secno">3. </span><span class="content">Security Considerations</span><a class="self-link" href="#security"></a></h2>
<p>While not directly affecting the API interface and Web IDL, WebVR implementations should maintains the user’s expectations of privacy, security, and comfort on the Web by adhering to the following guidelines:</p>
Expand Down Expand Up @@ -2205,7 +2212,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c
displayId
<ul>
<li><a href="#dom-vrdisplay-displayid">attribute for VRDisplay</a><span>, in §2.1</span>
<li><a href="#gamepad-getvrdisplays-attribute">attribute for Gamepad</a><span>, in §2.15.1</span>
<li><a href="#gamepad-getvrdisplays-attribute">attribute for Gamepad</a><span>, in §2.16.1</span>
</ul>
<li><a href="#dom-vrdisplay-displayname">displayName</a><span>, in §2.1</span>
<li><a href="#dom-vrfieldofview-downdegrees">downDegrees</a><span>, in §2.5</span>
Expand Down Expand Up @@ -2298,6 +2305,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c
<li><a href="#dom-vrdisplayevent-vrdisplayevent">VRDisplayEvent(eventInitDict)</a><span>, in §2.12</span>
<li><a href="#dictdef-vrdisplayeventinit">VRDisplayEventInit</a><span>, in §2.12</span>
<li><a href="#enumdef-vrdisplayeventreason">VRDisplayEventReason</a><span>, in §2.11</span>
<li><a href="#dom-document-vrenabled">vrEnabled</a><span>, in §2.15</span>
<li><a href="#enumdef-vreye">VREye</a><span>, in §2.4</span>
<li><a href="#vreyeparameters">VREyeParameters</a><span>, in §2.8</span>
<li><a href="#vrfieldofview">VRFieldOfView</a><span>, in §2.5</span>
Expand All @@ -2320,6 +2328,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span cla
<li>
<a data-link-type="biblio">[HTML]</a> defines the following terms:
<ul>
<li><a href="https://html.spec.whatwg.org/multipage/dom.html#document">Document</a>
<li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a>
<li><a href="https://html.spec.whatwg.org/multipage/browsers.html#framerequestcallback">FrameRequestCallback</a>
<li><a href="https://html.spec.whatwg.org/multipage/scripting.html#htmlcanvaselement">HTMLCanvasElement</a>
Expand Down Expand Up @@ -2570,6 +2579,10 @@ <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">I
<span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv" data-type="boolean" href="#dom-htmliframeelement-allowvr">allowvr</a>;
};

<span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/dom.html#document">Document</a> {
<span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv" data-type="boolean" href="#dom-document-vrenabled">vrEnabled</a>;
};

<span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://www.w3.org/TR/gamepad/#gamepad">Gamepad</a> {
<span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">unsigned</span> <span class="kt">long</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="unsigned long" href="#gamepad-getvrdisplays-attribute">displayId</a>;
};
Expand All @@ -2593,14 +2606,14 @@ <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">I
<li><a href="#ref-for-vrdisplay-47">2.12. VRDisplayEvent</a> <a href="#ref-for-vrdisplay-48">(2)</a>
<li><a href="#ref-for-vrdisplay-49">2.12.1. Attributes</a>
<li><a href="#ref-for-vrdisplay-50">2.13. Window Interface extension</a> <a href="#ref-for-vrdisplay-51">(2)</a> <a href="#ref-for-vrdisplay-52">(3)</a> <a href="#ref-for-vrdisplay-53">(4)</a> <a href="#ref-for-vrdisplay-54">(5)</a> <a href="#ref-for-vrdisplay-55">(6)</a> <a href="#ref-for-vrdisplay-56">(7)</a> <a href="#ref-for-vrdisplay-57">(8)</a>
<li><a href="#ref-for-vrdisplay-58">2.15.1. Attributes</a>
<li><a href="#ref-for-vrdisplay-58">2.16.1. Attributes</a>
<li><a href="#ref-for-vrdisplay-59">3. Security Considerations</a> <a href="#ref-for-vrdisplay-60">(2)</a> <a href="#ref-for-vrdisplay-61">(3)</a> <a href="#ref-for-vrdisplay-62">(4)</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="dom-vrdisplay-displayid">
<b><a href="#dom-vrdisplay-displayid">#dom-vrdisplay-displayid</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dom-vrdisplay-displayid-1">2.15.1. Attributes</a>
<li><a href="#ref-for-dom-vrdisplay-displayid-1">2.16.1. Attributes</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="dom-vrdisplay-isconnected">
Expand Down Expand Up @@ -3017,12 +3030,19 @@ <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">I
<ul>
<li><a href="#ref-for-dom-htmliframeelement-allowvr-1">2.10.1. Attributes</a>
<li><a href="#ref-for-dom-htmliframeelement-allowvr-2">2.14. allowvr iframe attribute</a>
<li><a href="#ref-for-dom-htmliframeelement-allowvr-3">2.15. vrEnabled Document attribute</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="dom-document-vrenabled">
<b><a href="#dom-document-vrenabled">#dom-document-vrenabled</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dom-document-vrenabled-1">2.15. vrEnabled Document attribute</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="gamepad-getvrdisplays-attribute">
<b><a href="#gamepad-getvrdisplays-attribute">#gamepad-getvrdisplays-attribute</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-gamepad-getvrdisplays-attribute-1">2.15. Gamepad Interface extension</a>
<li><a href="#ref-for-gamepad-getvrdisplays-attribute-1">2.16. Gamepad Interface extension</a>
</ul>
</aside>
<script>/* script-dfn-panel */
Expand Down

1 comment on commit f8d15c6

@toji
Copy link
Member Author

@toji toji commented on f8d15c6 Sep 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up to 1328cc7, primarily to mirror the same interface in the fullscreen API. (Also helps with testing.)

Please sign in to comment.