0

Clarify the Testing section of the origin trials documentation.

This makes it more obvious that generate_token.py is to be used in
conjunction with --origin-trial-public-key.

Change-Id: Ia6fc0c17519013804c10461c3d41cc9323bbb16c
Reviewed-on: https://chromium-review.googlesource.com/c/1412808
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Commit-Queue: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622989}
This commit is contained in:
Steve Kobes
2019-01-16 01:37:46 +00:00
committed by Commit Bot
parent be45bc8327
commit 6d752cbc19

@ -99,29 +99,30 @@ from the renderer.
## Testing
If you want to test your code's interactions with the framework, you'll need to
generate some tokens of your own. To generate your own tokens, use
[generate_token.py]. You can generate signed tokens for localhost, or for
127.0.0.1, or for any origin that you need to help you test. For example:
To test an origin trial feature during development, follow these steps:
```
tools/origin_trials/generate_token.py http://localhost:8000 MyFeature
```
1. Use [generate_token.py] to generate a token signed with the test private key.
You can generate signed tokens for any origin that you need to help you test,
including localhost or 127.0.0.1. Example:
The file `tools/origin_trials/eftest.key` is used by default as the private key
for the test keypair used by Origin Trials unit tests and web tests (i.e. in
content shell). Tokens generated with this key will **not** work in the browser
by default (see the [Developer Guide] for instructions on creating real tokens).
To use a test token with the browser, run Chrome with the command-line flag:
```
tools/origin_trials/generate_token.py http://localhost:8000 MyFeature
```
```
--origin-trial-public-key=dRCs+TocuKkocNKa0AtZ4awrt9XKH2SQCI6o4FY6BNA=
```
2. Copy the token from the end of the output and use it in a `<meta>` tag or
an `Origin-Trial` header as described in the [Developer Guide].
This is the base64 encoding of the public key associated with `eftest.key`. If
it doesn't work, see [trial_token_unittest.cc]. If you cannot set command-line
switches (e.g., on Chrome OS), you can also directly modify
[chrome_origin_trial_policy.cc].
3. Run Chrome with the test public key by passing:
`--origin-trial-public-key=dRCs+TocuKkocNKa0AtZ4awrt9XKH2SQCI6o4FY6BNA=`
The `--origin-trial-public-key` switch is not needed with `content_shell`, as it
uses the test public key by default.
The test private key is stored in the repo at `tools/origin_trials/eftest.key`.
It's also used by Origin Trials unit tests and web tests.
If you cannot set command-line switches (e.g., on Chrome OS), you can also
directly modify [chrome_origin_trial_policy.cc].
### Web Tests
When using the \[OriginTrialEnabled\] IDL attribute, you should add web tests