Commit 206101e8 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[WPT/common/security-features] Merge test_case_name

This CL moves `test_case_name` and `test_js` into test HTML templates,

- To merge code from indiviual projects into common/, and
- To prepare for merging multiple scenarios into a single HTML file.

This CL keeps generated test files unchanged.

Bug: 906850
Change-Id: Iad2dd874492b8824f4c97d76a78b09bf8e2ab94f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1889476
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710975}
parent 7d177a2b
...@@ -165,22 +165,14 @@ def generate_selection(spec_json, config, selection, spec, ...@@ -165,22 +165,14 @@ def generate_selection(spec_json, config, selection, spec,
['supported_delivery_type'][selection['subresource']]) ['supported_delivery_type'][selection['subresource']])
# We process the top source context below, and do not include it in # We process the top source context below, and do not include it in
# `test_parameters` in JavaScript. # `scenario` field in JavaScript.
top_source_context = selection['source_context_list'].pop(0) top_source_context = selection['source_context_list'].pop(0)
assert (top_source_context.source_context_type == 'top') assert (top_source_context.source_context_type == 'top')
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) selection['scenario'] = dump_test_parameters(selection).replace(
"\n", indent)
selection['test_js'] = '''
%s(
%s,
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
''' % (config.test_case_name, test_parameters)
selection['spec_name'] = spec['name'] selection['spec_name'] = spec['name']
selection[ selection[
......
...@@ -18,7 +18,13 @@ ...@@ -18,7 +18,13 @@
<script src="%(helper_js)s"></script> <script src="%(helper_js)s"></script>
</head> </head>
<body> <body>
<script>%(test_js)s</script> <script>
TestCase(
%(scenario)s,
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div> <div id="log"></div>
</body> </body>
</html> </html>
...@@ -14,7 +14,13 @@ ...@@ -14,7 +14,13 @@
<script src="%(helper_js)s"></script> <script src="%(helper_js)s"></script>
</head> </head>
<body> <body>
<script>%(test_js)s</script> <script>
TestCase(
%(scenario)s,
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div> <div id="log"></div>
</body> </body>
</html> </html>
...@@ -31,8 +31,6 @@ class MixedContentConfig(object): ...@@ -31,8 +31,6 @@ class MixedContentConfig(object):
self.sanity_checker_js = '/mixed-content/generic/sanity-checker.js' self.sanity_checker_js = '/mixed-content/generic/sanity-checker.js'
self.spec_json_js = '/mixed-content/spec_json.js' self.spec_json_js = '/mixed-content/spec_json.js'
self.test_case_name = 'TestCase'
script_directory = os.path.dirname(os.path.abspath(__file__)) script_directory = os.path.dirname(os.path.abspath(__file__))
self.spec_directory = os.path.abspath( self.spec_directory = os.path.abspath(
os.path.join(script_directory, '..', '..')) os.path.join(script_directory, '..', '..'))
......
...@@ -31,8 +31,6 @@ class ReferrerPolicyConfig(object): ...@@ -31,8 +31,6 @@ class ReferrerPolicyConfig(object):
self.sanity_checker_js = '/referrer-policy/generic/sanity-checker.js' self.sanity_checker_js = '/referrer-policy/generic/sanity-checker.js'
self.spec_json_js = '/referrer-policy/spec_json.js' self.spec_json_js = '/referrer-policy/spec_json.js'
self.test_case_name = 'TestCase'
script_directory = os.path.dirname(os.path.abspath(__file__)) script_directory = os.path.dirname(os.path.abspath(__file__))
self.spec_directory = os.path.abspath( self.spec_directory = os.path.abspath(
os.path.join(script_directory, '..', '..')) os.path.join(script_directory, '..', '..'))
......
...@@ -31,8 +31,6 @@ class UpgradeInsecureRequestsConfig(object): ...@@ -31,8 +31,6 @@ class UpgradeInsecureRequestsConfig(object):
self.sanity_checker_js = '/upgrade-insecure-requests/generic/sanity-checker.js' self.sanity_checker_js = '/upgrade-insecure-requests/generic/sanity-checker.js'
self.spec_json_js = '/upgrade-insecure-requests/spec_json.js' self.spec_json_js = '/upgrade-insecure-requests/spec_json.js'
self.test_case_name = 'TestCase'
script_directory = os.path.dirname(os.path.abspath(__file__)) script_directory = os.path.dirname(os.path.abspath(__file__))
self.spec_directory = os.path.abspath( self.spec_directory = os.path.abspath(
os.path.join(script_directory, '..', '..')) os.path.join(script_directory, '..', '..'))
......
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