Commit e63949cb authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[WPT/common/security-features] Add formatter of spec.src.json

Bug: 906850
Change-Id: I486eef6697a7ef5ff1360549321236add8e1c75b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717499
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681079}
parent da365165
import collections
import json
import os
def main():
'''Formats spec.src.json.'''
script_directory = os.path.dirname(os.path.abspath(__file__))
for dir in ['mixed-content', 'referrer-policy']:
filename = os.path.join(script_directory, '..', '..', '..', dir,
'spec.src.json')
spec = json.load(
open(filename, 'r'), object_pairs_hook=collections.OrderedDict)
with open(filename, 'w') as f:
f.write(json.dumps(spec, indent=2, separators=(',', ': ')))
f.write('\n')
if __name__ == '__main__':
main()
......@@ -17,7 +17,10 @@
"blockable": [],
"optionally-blockable": "*"
},
"origin": ["cross-origin-http", "same-host-http"],
"origin": [
"cross-origin-http",
"same-host-http"
],
"expectation": "blocked"
},
{
......@@ -31,7 +34,10 @@
"blockable": [],
"optionally-blockable": "*"
},
"origin": ["cross-origin-http", "same-host-http"],
"origin": [
"cross-origin-http",
"same-host-http"
],
"expectation": "allowed"
}
]
......@@ -53,7 +59,10 @@
"blockable": "*",
"optionally-blockable": []
},
"origin": ["cross-origin-http", "same-host-http"],
"origin": [
"cross-origin-http",
"same-host-http"
],
"expectation": "blocked"
},
{
......@@ -67,7 +76,10 @@
"blockable": "*",
"optionally-blockable": []
},
"origin": ["cross-origin-http", "same-host-http"],
"origin": [
"cross-origin-http",
"same-host-http"
],
"expectation": "blocked"
},
{
......@@ -81,7 +93,10 @@
"blockable": "websocket-request",
"optionally-blockable": []
},
"origin": ["cross-origin-ws", "same-host-ws"],
"origin": [
"cross-origin-ws",
"same-host-ws"
],
"expectation": "blocked"
}
]
......@@ -98,12 +113,17 @@
"source_protocol": "https",
"delivery_type": "*",
"delivery_value": "*",
"redirection": ["no-redirect", "keep-scheme-redirect"],
"redirection": [
"no-redirect",
"keep-scheme-redirect"
],
"subresource": {
"blockable": "*",
"optionally-blockable": "*"
},
"origin": ["same-host-https"],
"origin": [
"same-host-https"
],
"expectation": "allowed"
},
{
......@@ -112,20 +132,23 @@
"source_protocol": "https",
"delivery_type": "*",
"delivery_value": "*",
"redirection": ["no-redirect", "keep-scheme-redirect"],
"redirection": [
"no-redirect",
"keep-scheme-redirect"
],
"subresource": {
"blockable": "websocket-request",
"optionally-blockable": []
},
"origin": ["same-host-wss"],
"origin": [
"same-host-wss"
],
"expectation": "allowed"
}
]
}
],
"delivery_key": "mixedContent",
"excluded_tests": [
{
"name": "Skip-redundant-no-opt-in",
......@@ -184,7 +207,10 @@
"source_protocol": "*",
"delivery_type": "meta",
"delivery_value": "opt-in",
"redirection": ["keep-scheme-redirect", "swap-scheme-redirect"],
"redirection": [
"keep-scheme-redirect",
"swap-scheme-redirect"
],
"subresource": {
"blockable": "*",
"optionally-blockable": "*"
......@@ -193,7 +219,6 @@
"expectation": "*"
}
],
"test_expansion_schema": {
"expansion": [
"default",
......
......@@ -30,6 +30,8 @@ Invoking ```./generic/tools/generate.py``` will parse the spec JSON and determin
The spec can be validated by running ```./generic/tools/spec_validator.py```. This is specially important when you're making changes to ```spec.src.json```. Make sure it's a valid JSON (no comments or trailing commas). The validator should be informative and very specific on any issues.
The ```spec.src.json``` file can be formatted by running ```../common/security-features/tools/format_spec_src_json.py```.
For details about the spec JSON, see **Overview of the spec JSON** below.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment