-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow use in same-origin children, add Feature Policy integration #13
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a369bc9
Stop using incumbent settings object
anssiko 041b059
Allow use in same-origin children
anssiko e9f5442
Add Feature Policy integration
anssiko d2458d8
Fix settings object and global object prose to match the latest HTML
anssiko fb43978
Use 'allowed to use' abstraction, reword Feature Policy integration
anssiko e486c5a
Clarify note on rejection condition
anssiko a9e3c94
Merge branch 'gh-pages' into issue-10-secure-top-level
anssiko 3e08915
Replace SecurityError with NotAllowedError
anssiko 7ad0dd5
Define EventTarget reference to fix a ReSpec error
anssiko e500e98
Merge branch 'issue-10-secure-top-level' of https://github.com/w3c/ba…
anssiko 6d2ce77
Remove duplicate EventTarget definition
anssiko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,16 +147,14 @@ <h2> | |
"https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler"><dfn><code> | ||
EventHandler</code></dfn></a> | ||
</li> | ||
<li> | ||
<a href= | ||
"https://dom.spec.whatwg.org/#eventtarget"><dfn><code> | ||
EventTarget</code></dfn></a> | ||
</li> | ||
<li> | ||
<dfn><a href= | ||
"https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queue a | ||
task</a></dfn> | ||
</li> | ||
<li> | ||
<code><dfn data-cite="DOM#eventtarget">EventTarget</dfn></code> | ||
</li> | ||
<li> | ||
<dfn><a href= | ||
"https://dom.spec.whatwg.org/#concept-event-fire">fires | ||
|
@@ -177,6 +175,21 @@ <h2> | |
"https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing | ||
context</a></dfn> | ||
</li> | ||
<li> | ||
<dfn><a href= | ||
"https://html.spec.whatwg.org/#concept-relevant-global">relevant | ||
global object</a></dfn> | ||
</li> | ||
<li> | ||
<dfn><a href= | ||
"https://html.spec.whatwg.org/#relevant-settings-object">relevant | ||
settings object</a></dfn> | ||
</li> | ||
<li> | ||
<dfn><a href= | ||
"https://html.spec.whatwg.org/#current-settings-object">current | ||
settings object</a></dfn> | ||
</li> | ||
<li> | ||
<dfn><a href= | ||
"https://html.spec.whatwg.org/multipage/browsers.html#top-level-browsing-context"> | ||
|
@@ -187,6 +200,11 @@ <h2> | |
"https://html.spec.whatwg.org/multipage/webappapis.html#incumbent-settings-object"> | ||
incumbent settings object</a></dfn> | ||
</li> | ||
<li> | ||
<dfn><a href= | ||
"https://html.spec.whatwg.org/#concept-document-window">associated | ||
<code>Document</code></a></dfn> | ||
</li> | ||
<li> | ||
<a href= | ||
"https://tc39.github.io/ecma262/#sec-promise-objects"><dfn>Promise</dfn></a> | ||
|
@@ -199,6 +217,10 @@ <h2> | |
<a href= | ||
"https://heycam.github.io/webidl/#securityerror"><dfn><code>SecurityError</code></dfn></a> | ||
</li> | ||
<li> | ||
<a href= | ||
"https://heycam.github.io/webidl/#notallowederror"><dfn><code>NotAllowedError</code></dfn></a> | ||
</li> | ||
<li> | ||
<a href= | ||
"https://heycam.github.io/webidl/#idl-DOMException"><dfn><code>DOMException</code></dfn></a> | ||
|
@@ -208,6 +230,37 @@ <h2> | |
"https://www.w3.org/TR/secure-contexts/#secure-context"><dfn>secure | ||
context</dfn></a> | ||
</li> | ||
<li> | ||
<a href="https://html.spec.whatwg.org/#active-document"><dfn>active | ||
document</dfn></a> | ||
</li> | ||
<li> | ||
<a href= | ||
"https://html.spec.whatwg.org/#concept-origin"><dfn>origin</dfn></a> | ||
</li> | ||
<li> | ||
<a href="https://html.spec.whatwg.org/#same-origin-domain"><dfn>same | ||
origin-domain</dfn></a> | ||
</li> | ||
<li> | ||
<a href="https://html.spec.whatwg.org/#allowed-to-use"><dfn>allowed | ||
to use</dfn></a> | ||
</li> | ||
<li> | ||
<a href= | ||
"https://wicg.github.io/feature-policy/#policy-controlled-feature"><dfn> | ||
policy-controlled feature</dfn></a> | ||
</li> | ||
<li> | ||
<a href= | ||
"https://wicg.github.io/feature-policy/#feature-name"><dfn>feature | ||
name</dfn></a> | ||
</li> | ||
<li> | ||
<a href= | ||
"https://wicg.github.io/feature-policy/#default-allowlist"><dfn>default | ||
allowlist</dfn></a> | ||
</li> | ||
</ul> | ||
</section> | ||
<section class="informative"> | ||
|
@@ -259,17 +312,26 @@ <h2> | |
the following steps: | ||
</p> | ||
<ol> | ||
<li>If the <a>incumbent settings object</a> is not a <a>secure | ||
context</a>, then reject this <a>Navigator</a> object's <a>battery | ||
promise</a> with a "<a>SecurityError</a>" <a>DOMException</a>, return | ||
this <a>Navigator</a> object's <a>battery promise</a> and abort these | ||
steps. | ||
</li> | ||
<li>If the <a>browsing context</a> is not a <a>top-level browsing | ||
context</a>, then reject this <a>Navigator</a> object's <a>battery | ||
promise</a> with a "<a>SecurityError</a>" <a>DOMException</a>, return | ||
this <a>Navigator</a> object's <a>battery promise</a> and abort these | ||
steps. | ||
<li>If the <a>relevant settings object</a> of this <a>Navigator</a> | ||
object is not a <a>secure context</a>, then reject this | ||
<a>Navigator</a> object's <a>battery promise</a> with a | ||
"<a>SecurityError</a>" <a>DOMException</a>, return this | ||
<a>Navigator</a> object's <a>battery promise</a> and abort these steps. | ||
</li> | ||
<li>If this <a>Navigator</a> object's <a>relevant global object</a>'s | ||
<a>associated <code>Document</code></a> is not <a>allowed to use</a> | ||
the <code>battery</code> feature, then reject this <a>Navigator</a> | ||
object's <a>battery promise</a> with a "<a>NotAllowedError</a>" | ||
<a>DOMException</a>, return this <a>Navigator</a> object's <a>battery | ||
promise</a> and abort these steps. | ||
<div class="note"> | ||
In other words, this step rejects if the <a>associated | ||
<code>Document</code></a>'s <a>browsing context</a>'s <a>active | ||
document</a>'s <a>origin</a> is not <a>same origin-domain</a> with | ||
the <a>origin</a> of the <a>current settings object</a> of this | ||
<a>Navigator</a> object, unless specifically allowed by the | ||
document's feature policy. | ||
</div> | ||
</li> | ||
<li>If this <a>Navigator</a> object's <a>battery promise</a> is not | ||
<code>null</code>, return this <a>Navigator</a> object's <a>battery | ||
|
@@ -486,6 +548,18 @@ <h2> | |
</table> | ||
</section> | ||
</section> | ||
<section> | ||
<h2> | ||
Feature Policy integration | ||
</h2> | ||
<p data-link-for="Navigator"> | ||
The Battery Status API is a <a>policy-controlled feature</a> identified | ||
by the string "<code>battery</code>". It's default allowlist is | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Note to self: s/It’s/Its/) |
||
<code>'self'</code>. When disabled in a document, the | ||
<code><a>getBattery</a>()</code> method MUST return a <a>promise</a> | ||
which rejects with a "<a>SecurityError</a>" <a>DOMException</a>. | ||
</p> | ||
</section> | ||
<section class="informative"> | ||
<h2> | ||
Examples | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With feature policy integration, I think you can replace this entire paragraph with something like
Because the default allowlist is
'self'
, that will automatically take care of the same-origin embed case, while allowing cross-origin usage only if explicitly enabled by the embedding document (which this paragraph still prohibits, I think)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed an update in an attempt to make use of "allowed to use". Please take a look. (I'm happy to see "allowed to use" abstracted out and reusable.)