Commit 54cb55fa authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[WPT/common/security-features] Replace name fields with inline comments

To remove special handling in the generator.

This CL doesn't change the generated results or test behavior.

Bug: 906850, https://github.com/web-platform-tests/wpt/issues/21708
Change-Id: Ibb6586d618a04dba96304ba4a21555034bd30d32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102387
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750480}
parent a88b5166
......@@ -54,11 +54,7 @@ def permute_expansion(expansion,
# Dumps the test config `selection` into a serialized JSON string.
# We omit `name` parameter because it is not used by tests.
def dump_test_parameters(selection):
selection = dict(selection)
del selection['name']
return json.dumps(
selection,
indent=2,
......@@ -178,7 +174,6 @@ def generate_selection(spec_directory, test_helper_filenames, spec_json,
selection['scenario'] = dump_test_parameters(selection).replace(
"\n", indent)
selection['spec_name'] = spec['name']
selection['test_page_title'] = spec_json['test_page_title_template'] % spec
selection['spec_description'] = spec['description']
selection['spec_specification_url'] = spec['specification_url']
......@@ -256,7 +251,7 @@ def generate_test_source_files(spec_directory, test_helper_filenames,
# Choose a debug/release template depending on the target.
html_template = "test.%s.html.template" % target
artifact_order = test_expansion_schema.keys() + ['name']
artifact_order = test_expansion_schema.keys()
artifact_order.remove('expansion')
# Create list of excluded tests.
......@@ -282,10 +277,11 @@ def generate_test_source_files(spec_directory, test_helper_filenames,
selection_path = spec_json['selection_pattern'] % selection
if selection_path in output_dict:
if expansion_pattern['expansion'] != 'override':
print(
"Error: %s's expansion is default but overrides %s"
% (selection['name'],
output_dict[selection_path]['name']))
print("Error: expansion is default in:")
print(dump_test_parameters(selection))
print("but overrides:")
print(dump_test_parameters(
output_dict[selection_path]))
sys.exit(1)
output_dict[selection_path] = copy.deepcopy(selection)
......@@ -361,7 +357,8 @@ def main():
return
# Load the default spec JSON file, ...
default_spec_filename = os.path.join(util.script_directory, 'spec.src.json')
default_spec_filename = os.path.join(util.script_directory,
'spec.src.json')
spec_json = collections.OrderedDict()
if os.path.exists(default_spec_filename):
spec_json = util.load_spec_json(default_spec_filename)
......
......@@ -3,7 +3,7 @@
"test_file_path_pattern": "gen/%(source_context_list)s.%(delivery_type)s/%(delivery_value)s/%(subresource)s/%(origin)s.%(redirection)s.%(source_scheme)s.html",
"excluded_tests": [
{
"name": "Workers are same-origin only",
// Workers are same-origin only
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -27,7 +27,7 @@
"expectation": "*"
},
{
"name": "Workers are same-origin only (redirects)",
// Workers are same-origin only (redirects)
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -47,7 +47,7 @@
"expectation": "*"
},
{
"name": "Websockets are ws/wss-only",
// Websockets are ws/wss-only
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -68,7 +68,7 @@
{
// Redirects are intentionally forbidden in browsers:
// https://fetch.spec.whatwg.org/#concept-websocket-establish
"name": "Websockets are no-redirect only",
// Websockets are no-redirect only
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -86,7 +86,7 @@
"expectation": "*"
},
{
"name": "ws/wss are websocket-only",
// ws/wss are websocket-only
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......
......@@ -101,7 +101,7 @@ def validate(spec_json, details):
test_expansion_schema = spec_json['test_expansion_schema']
excluded_tests = spec_json['excluded_tests']
valid_test_expansion_fields = ['name'] + test_expansion_schema.keys()
valid_test_expansion_fields = test_expansion_schema.keys()
# Should be consistent with `sourceContextMap` in
# `/common/security-features/resources/common.sub.js`.
......@@ -136,24 +136,15 @@ def validate(spec_json, details):
# Validate required fields for a single spec.
assert_contains_only_fields(spec, [
'name', 'title', 'description', 'specification_url',
'test_expansion'
'title', 'description', 'specification_url', 'test_expansion'
])
assert_non_empty_string(spec, 'name')
assert_non_empty_string(spec, 'title')
assert_non_empty_string(spec, 'description')
assert_non_empty_string(spec, 'specification_url')
assert_non_empty_list(spec, 'test_expansion')
# Validate spec's test expansion.
used_spec_names = {}
for spec_exp in spec['test_expansion']:
details['object'] = spec_exp
assert_non_empty_string(spec_exp, 'name')
# The name is unique in same expansion group.
assert_value_unique_in((spec_exp['expansion'], spec_exp['name']),
used_spec_names)
assert_contains_only_fields(spec_exp, valid_test_expansion_fields)
for artifact in test_expansion_schema:
......
......@@ -3,13 +3,13 @@
"test_page_title_template": "Mixed-Content: %(title)s",
"specification": [
{
"name": "optionally-blockable",
// optionally-blockable
"title": "Optionally-blockable content",
"description": "Test behavior of optionally-blockable content",
"specification_url": "http://www.w3.org/TR/mixed-content/#category-optionally-blockable",
"test_expansion": [
{
"name": "opt-in-blocks",
// opt-in-blocks
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -28,7 +28,7 @@
"expectation": "blocked"
},
{
"name": "opt-in-blocks-redirects",
// opt-in-blocks-redirects
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -47,7 +47,7 @@
"expectation": "blocked"
},
{
"name": "no-opt-in-allows",
// no-opt-in-allows
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -68,13 +68,13 @@
]
},
{
"name": "blockable",
// blockable
"title": "Blockable content",
"description": "Test behavior of blockable content.",
"specification_url": "http://www.w3.org/TR/mixed-content/#category-blockable",
"test_expansion": [
{
"name": "opt-in-blocks",
// opt-in-blocks
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -114,7 +114,7 @@
"expectation": "blocked"
},
{
"name": "opt-in-blocks-redirects",
// opt-in-blocks-redirects
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -154,7 +154,7 @@
"expectation": "blocked"
},
{
"name": "no-opt-in-blocks",
// no-opt-in-blocks
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -194,7 +194,7 @@
"expectation": "blocked"
},
{
"name": "ws-downgrade-blocks",
// ws-downgrade-blocks
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -211,13 +211,13 @@
]
},
{
"name": "allowed",
// allowed
"title": "Allowed content",
"description": "Test behavior of allowed content.",
"specification_url": "http://www.w3.org/TR/mixed-content/",
"test_expansion": [
{
"name": "allowed",
// allowed
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -234,7 +234,7 @@
"expectation": "allowed"
},
{
"name": "websocket-allowed",
// websocket-allowed
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -256,7 +256,7 @@
"delivery_key": "mixedContent",
"excluded_tests": [
{
"name": "Skip-redundant-no-opt-in",
// Skip-redundant-no-opt-in
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -268,7 +268,7 @@
"expectation": "*"
},
{
"name": "Skip-redundant-for-opt-in-method",
// Skip-redundant-for-opt-in-method
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -283,7 +283,7 @@
"expectation": "*"
},
{
"name": "source_context_list values not yet tested",
// source_context_list values not yet tested
"expansion": "*",
"source_scheme": "*",
"source_context_list": [
......@@ -301,7 +301,7 @@
"expectation": "*"
},
{
"name": "source_context_list values not for CSP tests",
// source_context_list values not for CSP tests
"expansion": "*",
"source_scheme": "*",
"source_context_list": [
......@@ -316,7 +316,7 @@
"expectation": "*"
},
{
"name": "subresource values not yet tested",
// subresource values not yet tested
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -332,7 +332,7 @@
"expectation": "*"
},
{
"name": "redirections that mixed-content tests don't care",
// redirections that mixed-content tests don't care
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......
{
"excluded_tests": [
{
"name": "expectation=stripped-referrer only",
// expectation=stripped-referrer only
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -16,7 +16,7 @@
]
},
{
"name": "Only on the top context",
// Only on the top context
"expansion": "*",
"source_scheme": "*",
"source_context_list": [
......
{
"excluded_tests": [
{
"name": "expectation=stripped-referrer only",
// expectation=stripped-referrer only
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -16,7 +16,7 @@
]
},
{
"name": "Only on the top context",
// Only on the top context
"expansion": "*",
"source_scheme": "*",
"source_context_list": [
......
{
"excluded_tests": [
{
"name": "expectation=stripped-referrer only",
// expectation=stripped-referrer only
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -16,7 +16,7 @@
]
},
{
"name": "Only on the top context",
// Only on the top context
"expansion": "*",
"source_scheme": "*",
"source_context_list": [
......
......@@ -3,13 +3,13 @@
"test_page_title_template": "Upgrade-Insecure-Requests: %(title)s",
"specification": [
{
"name": "No upgrade-insecure-request",
// No upgrade-insecure-request
"title": "No upgrade-insecure-request",
"description": "No upgrade-insecure-request",
"specification_url": "https://w3c.github.io/webappsec-upgrade-insecure-requests/",
"test_expansion": [
{
"name": "Without upgrade-insecure-request, all requests are blocked ...",
// Without upgrade-insecure-request, all requests are blocked ...
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -21,7 +21,7 @@
"expectation": "blocked"
},
{
"name": "... except for the secure requests listed here",
// ... except for the secure requests listed here
"expansion": "override",
"source_scheme": "https",
"source_context_list": "*",
......@@ -40,13 +40,13 @@
]
},
{
"name": "With upgrade-insecure-request",
// With upgrade-insecure-request
"title": "With upgrade-insecure-request",
"description": "With upgrade-insecure-request",
"specification_url": "https://w3c.github.io/webappsec-upgrade-insecure-requests/",
"test_expansion": [
{
"name": "With upgrade-insecure-request, all insecure requests are upgraded and allowed.",
// With upgrade-insecure-request, all insecure requests are upgraded and allowed.
"expansion": "default",
"source_scheme": "https",
"source_context_list": "*",
......@@ -63,7 +63,7 @@
"delivery_key": "upgradeInsecureRequests",
"excluded_tests": [
{
"name": "Omit secure requests",
// Omit secure requests
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -80,7 +80,7 @@
"expectation": "allowed"
},
{
"name": "For inheriting tests skip http-rp because we already have <meta> tests",
// For inheriting tests skip http-rp because we already have <meta> tests
"expansion": "*",
"source_scheme": "*",
"source_context_list": [
......@@ -96,7 +96,7 @@
"expectation": "*"
},
{
"name": "source_context_list values not yet tested",
// source_context_list values not yet tested
"expansion": "*",
"source_scheme": "*",
"source_context_list": [
......@@ -115,7 +115,7 @@
"expectation": "*"
},
{
"name": "source_context_list values not for CSP tests",
// source_context_list values not for CSP tests
"expansion": "*",
"source_scheme": "*",
"source_context_list": [
......@@ -130,7 +130,7 @@
"expectation": "*"
},
{
"name": "subresource values not yet tested",
// subresource values not yet tested
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -153,7 +153,7 @@
"expectation": "*"
},
{
"name": "origins that upgrade-insecure-requests tests don't care",
// origins that upgrade-insecure-requests tests don't care
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......@@ -170,7 +170,7 @@
"expectation": "*"
},
{
"name": "redirections that upgrade-insecure-requests tests don't care",
// redirections that upgrade-insecure-requests tests don't care
"expansion": "*",
"source_scheme": "*",
"source_context_list": "*",
......
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