#292: Feature Policy JS introspection API

Visit on Github.

Opened Jul 4, 2018

Hello TAG!

I'm requesting a TAG review of:

  • Name: Feature Policy: JavaScript policy introspection
  • Specification URL: PR, published as draft here (See section 7, specifically).
  • Explainer, Requirements Doc, or Example code: See introduction and examples in draft
  • Tests: This API is tested in WPT/feature-policy, specifically with the feature-policy-frame-policy-*, feature-policy-header-policy-*, and feature-policy-nested-header-policy-* tests. Once available, this API can also be used to test many other policy-controlled features, as well.
  • Primary contacts: iclelland

Further details (optional):

You should also know that...

[please tell us anything you think is relevant to this review]

We'd prefer the TAG provide feedback as (please select one):

  • open issues in our Github repo for each point of feedback
  • open a single issue in our Github repo for the entire review
  • leave review feedback as a comment in this issue and @-notify [github usernames]

Please preview the issue and check that the links work before submitting

For background, some decent explainers:

https://github.com/w3c/ServiceWorker/blob/master/explainer.md https://github.com/zkoch/paymentrequest/blob/gh-pages/docs/explainer.md https://github.com/WICG/IntersectionObserver/blob/gh-pages/explainer.md (although this one includes IDL, which an explainer should not)

Discussions

Comment by @clelland Jul 25, 2018 (See Github)

Chrome is implementing this as an origin trial, as a means of obtaining additional feedback from the developer community. As such, I've merged the PR into the main spec, with a large disclaimer that the API should be considered unstable (pending feedback).

The up-to-date spec changes are now public at https://wicg.github.io/feature-policy/#introspection

Comment by @clelland Nov 29, 2018 (See Github)

I'm considering making some changes to this API, in light of developer and implementer feedback; before I do, though, I'm wondering if there has been any action from the TAG, or if I should wait a bit longer?

(I totally understand that there's a backlog, just looking to get some insight into the process)

Comment by @clelland Jan 31, 2019 (See Github)

Friendly ping :) Any updates? FYI, this has received API owners approval to ship in Chrome: https://groups.google.com/a/chromium.org/d/msg/blink-dev/qwLRSNFsfUQ/ZhxYYusjCAAJ

Also, the spec changes (now at https://w3c.github.io/webappsec-feature-policy/#introspection) are no longer marked as unstable.

Comment by @cynthia Feb 6, 2019 (See Github)

Pong! Sorry this took so long. We plan to discuss this in our Tokyo F2F. (which is until tomorrow)

Reading the spec now.

Comment by @kenchris May 22, 2019 (See Github)

During the F2F, @cynthia and me looked at this issue. Apologies for the long wait, but we are in the process of speeding up our reviews.

We find the method names somewhat inconsistent. There are two getters, one starts with get - the other doesn't. There is a query method that is not clear that it is a query method from the name.

allowedFeatures() should maybe take an optional origin like the query method.

We have existing similar names on the web today like document.querySelector() and document.getElementsByTag(). Better names could be policy.queryAllowList() and policy.getAllowList(optional origin) and policy.getAllowedOrigins(feature) - in particular we find the term "allow list" being two different things (features, origins) called the same thing confusing (hence getAllowlistForFeature returns a list of origins and not an actual allow list).

Given these inconsistencies, how malleable are the APIs at the moment since it is a shipped feature? If the adoption rate isn´t high, considering that other browsers have not shipped we think it might not be too late to make adjustments to the naming.

At this F2F we are hearing that feature policy will get feature policies that support parameters - what is the interopt story for that?

Comment by @clelland May 22, 2019 (See Github)

@kenchris:

Given these inconsistencies, how malleable are the APIs at the moment since it is a shipped feature?

Those changes are likely still possible; the feature itself only shipped in Chrome 74; We're seeing some uptick in usage, though the absolute numbers are still quite small (https://www.chromestatus.com/metrics/feature/timeline/popularity/2511). An optional origin should be trivial to add; we may need to have a short overlap period while we deprecate the old names, if we go that route.

Are there TAG guidelines for what counts as a 'query' for naming purposes? The only instances I can find in our IDL are for querySelector and querySelectorAll (Permissions and WebLocks have generically-named query() methods as well)

in particular we find the term "allow list" being two different things (features, origins) called the same thing confusing (hence getAllowlistForFeature returns a list of origins and not an actual allow list).

In the spec, an 'allowlist' is either a list of origins, or the value '*' (representing all origins). It shouldn't be a list of features (a declared policy is a map from features to allowlists). I think that it would run counter to that definition if we used getAllowList to return a list of features -- would getAllowedFeatures be as clear?

At this F2F we are hearing that feature policy will get feature policies that support parameters - what is the interopt story for that?

The initial proposal (https://github.com/w3c/webappsec-feature-policy/issues/163) extended feature policy with parameters for some new features; existing features are all considered 'boolean' in type, and so 'true' and 'false' would be the only valid values, and could be omitted from any declarations (the 'true' value is inferred from the an origin being allowed at all); in this way it was intended to be backwards-compatible with existing features and existing uses.

There is some interest from people in taking those features that would work well with parameters, and splitting them off into a different mechanism, to avoid burdening Feature Policy with additional complexity. This was proposed in https://github.com/w3c/webappsec-feature-policy/issues/282#issuecomment-486267212, and I opened an issue for further design discussion at https://github.com/w3c/webappsec-feature-policy/issues/299.

Discussed Jun 26, 2019 (See Github)

Dave: [reads tea-leaves] I think this needs a breakout. 304/303/389

... cors-like bit...

Sangwhan: happy to do a breakout.

Dave: we can figure it out time-zone wise.

Sangwhan: this could change how you substrate protocols - layered protocols - http3 runs on top of quic - quic runs on UDP. Also we have DNS over http - a protocol that has been pulled up. CHanges the dynamics...

Hadley: so you would say dns over http is a substrate of http?

Sangwhan: yes.

Peter: Breakout on this? Milestone on breakout session - a generic one...

Hadley: label?

Dan: feels more like a label

Peter: ok but then set a milestone when you are done with the breakout...

Alice: there is also a new TAG review to web transfer API - which is 389 so you may want to pull that into the breakout as well.

Peter: should we close 303?

Alice & Sangwhan: no

Alice: 2 separate things.

Dave: possible it's 304 and 389 but we can sort it out in the breakout...

[set for breakouts

Comment by @cynthia Jun 26, 2019 (See Github)

Apologies for the delay again. New process adoption.. takes time, and discipline - the latter which at least I have failed at. :-)

Are there TAG guidelines for what counts as a 'query' for naming purposes? The only instances I can find in our IDL are for querySelector and querySelectorAll (Permissions and WebLocks have generically-named query() methods as well)

No, not that I am aware of. The only bit we touch on is the term "is", here: https://w3ctag.github.io/design-principles/#naming-is-hard

Would it be helpful if we had a guideline on this? If it feels useful we will file an issue to address this in the design principles document.

As for the remaining comments - I'll discuss this separately with @kenchris. Thanks for the patience.

Comment by @kenchris Sep 11, 2019 (See Github)

I hope our feedback was useful, there doesn't seem to be much more for us to do here, so thanks for flying TAG!