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

[WPT/common/security-features] Sort keys of test config JSONs

This CL
- Sorts they keys of test config JSONs.
- Fixes generator errors by removing stale imports.

Bug: 906850
Change-Id: I9f88e6d3a32fedc0c31c6cbef4a19b541c38453e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717309
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680903}
parent 3c99fcfd
...@@ -47,13 +47,23 @@ def permute_expansion(expansion, ...@@ -47,13 +47,23 @@ def permute_expansion(expansion,
yield next_selection yield next_selection
# 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, separators=(',', ': '), sort_keys=True)
def generate_selection(config, selection, spec, test_html_template_basename): def generate_selection(config, selection, spec, test_html_template_basename):
# TODO: Refactor out this referrer-policy-specific part. # TODO: Refactor out this referrer-policy-specific part.
if 'referrer_policy' in spec: if 'referrer_policy' in spec:
# Oddball: it can be None, so in JS it's null. # Oddball: it can be None, so in JS it's null.
selection['referrer_policy'] = spec['referrer_policy'] selection['referrer_policy'] = spec['referrer_policy']
test_parameters = json.dumps(selection, indent=2, separators=(',', ':')) test_parameters = dump_test_parameters(selection)
# Adjust the template for the test invoking JS. Indent it to look nice. # Adjust the template for the test invoking JS. Indent it to look nice.
indent = "\n" + " " * 8 indent = "\n" + " " * 8
test_parameters = test_parameters.replace("\n", indent) test_parameters = test_parameters.replace("\n", indent)
...@@ -86,7 +96,7 @@ def generate_selection(config, selection, spec, test_html_template_basename): ...@@ -86,7 +96,7 @@ def generate_selection(config, selection, spec, test_html_template_basename):
html_template_filename = os.path.join(util.template_directory, html_template_filename = os.path.join(util.template_directory,
test_html_template_basename) test_html_template_basename)
generated_disclaimer = disclaimer_template \ generated_disclaimer = disclaimer_template \
% {'generating_script_filename': os.path.relpath(__file__, % {'generating_script_filename': os.path.relpath(sys.argv[0],
util.test_root_directory), util.test_root_directory),
'html_template_filename': os.path.relpath(html_template_filename, 'html_template_filename': os.path.relpath(html_template_filename,
util.test_root_directory)} util.test_root_directory)}
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
from __future__ import print_function from __future__ import print_function
import json, sys import json, sys
from common_paths import *
def assert_non_empty_string(obj, field): def assert_non_empty_string(obj, field):
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
from __future__ import print_function from __future__ import print_function
import json, sys import json, sys
from common_paths import *
def assert_non_empty_string(obj, field): def assert_non_empty_string(obj, field):
......
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