1. For deprecation trials only, ignore the origin when content comes from a file URL. That is, allow file URLs to enable a trial with any valid token, regardless of the specified origin in the token.
2. Match only the scheme and host, ignoring the port number, for non-reserved ports (i.e. > 1024).
These constraints have the potential to cause, or have already caused, undue friction for web developers. I believe that relaxing the constraints doesn't materially impact the ability of origin trials to limit usage of features and attribute usage to specific web developers.
Longer version
1. Allow file URLs to enable trials, for deprecation trials only
As described in
High-Usage API Deprecation, it's important for a trial for a deprecated feature to re-enable the feature anywhere it previously worked. File URLs are not supported by the origin trials framework, because they do not have a well-defined origin (e.g.
the URL spec). This is tracked in
crbug.com/1025782, and is particularly problematic for the WebComponents V0 deprecation. For WCv0, there are sites that heavily rely on having content work locally from file URLs (see
crbug.com/1021137).
Given that file URLs can change arbitrarily, as well as the contents of a saved file, it's difficult to come up with a reliable way to derive an "origin" for validation. In theory, we could generate a hash of the file contents when downloaded, embed in the file somehow, and later validate that the contents haven't changed. After initial investigation, that seems possible to implement in Chrome, but definitely non-trivial.
The more feasible approach is to ignore the origin check for file URLs. This was prototyped by masonfreed@ in:
By ignoring the origin check, an otherwise valid token is still required. This means that the web developer would have to make some change to their content, which implies awareness of the deprecation (at least implicitly). This approach makes it possible for a developer to blindly copy/paste any token (e.g. from code snippet found elsewhere), but that would only work for the saved file. The web site as served would not work, which makes it much less likely a developer wouldn't sign up for their own token.
I propose to implement logic similar to the prototype, but instead of hard-coding a trial name, it would allow for any trial explicitly marked as a deprecation. We could also add metrics to track how much this is used, to see if it might become a problem.
2. Match only the scheme and host, ignoring the port number
We've learned that the internal Google test infrastructure makes it difficult (impossible?) to serve test web content from a known and consistent port number. We've run into this problem at times with the Chromium test infrastructure, but were able to work around it (e.g.
origin_trials_browsertest.cc). We don't have explicit reports from other web developers, but it seems likely it would affect others. Tracking bug is
crbug.com/1046826.
We already allow subdomain matching in tokens, as a relaxation of the strict origin check. Part of the rationale was that a subdomain token still provides reasonable attribution, because it's not possible for different entities (i.e. web developers), to register different subdomains on the same domain.
The port number is also optional in the trial registration process. It's possible to specify a port, but not required, and the port number is then defaulted to 80 (http) or 443 (https).
I propose to implement validation logic for port numbers similar to that for subdomains: either the port matches the token exactly OR the current port number is > 1024. While subdomain matching requires an explicit opt-in from the web developer, I don't see that as necessary for port numbers. It seems unlikely that a web developer would be serving a website on two different ports, and want to make a distinction in enabling a trial by port number.
What do the API owners think?
Thanks,
Jason