Commit 3685447d authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[WPT] Move subresource_path from generator to referrer-policy-test-case.js

As a preparation for merging generator scripts.

Changes to generated HTMLs are split into a subsequent CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1476172

Bug: 906850
Change-Id: I942159ce3b57dd472fe56764772b610c0231132f
Reviewed-on: https://chromium-review.googlesource.com/c/1476144
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634993}
parent 51252b4e
......@@ -165,12 +165,6 @@ git add * && git commit -m "Update generated tests"
The schema used to check if a ```test_expansion``` is valid.
Each test expansion can only contain fields defined by this schema.
* **subresource_path**
A 1:1 mapping of a **subresource type** to the URL path of the sub-resource.
When adding a new sub-resource, a path to an existing file for it also must be specified.
### Test Expansion Patterns
Each field in a test expansion can be in one of the following formats:
......
......@@ -50,6 +50,19 @@ function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) {
"xhr-request": requestViaXhr
};
const subresourcePath = {
"a-tag": "/referrer-policy/generic/subresource/document.py",
"area-tag": "/referrer-policy/generic/subresource/document.py",
"fetch-request": "/referrer-policy/generic/subresource/xhr.py",
"iframe-tag": "/referrer-policy/generic/subresource/document.py",
"img-tag": "/referrer-policy/generic/subresource/image.py",
"script-tag": "/referrer-policy/generic/subresource/script.py",
"worker-request": "/referrer-policy/generic/subresource/worker.py",
"module-worker": "/referrer-policy/generic/subresource/worker.py",
"shared-worker": "/referrer-policy/generic/subresource/shared-worker.py",
"xhr-request": "/referrer-policy/generic/subresource/xhr.py"
};
var referrerUrlResolver = {
"omitted": function() {
return undefined;
......@@ -85,7 +98,7 @@ function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) {
return t._scenario.target_protocol + "://" +
domainForOrigin[t._scenario.origin] +
normalizePort(targetPort) +
t._scenario["subresource_path"] +
subresourcePath[t._scenario.subresource] +
"?redirection=" + t._scenario["redirection"] +
"&cache_destroyer=" + (new Date()).getTime();
},
......
......@@ -13,9 +13,6 @@ SanityChecker.prototype.checkScenario = function(scenario) {
var expectedFields = SPEC_JSON["test_expansion_schema"];
expectedFields["referrer_policy"] = SPEC_JSON["referrer_policy_schema"];
assert_own_property(scenario, "subresource_path",
"Scenario has the path to the subresource.");
for (var field in expectedFields) {
assert_own_property(scenario, field,
"The scenario contains field " + field)
......
......@@ -7,7 +7,6 @@ ReferrerPolicyTestCase(
"source_protocol": "%(source_protocol)s",
"target_protocol": "%(target_protocol)s",
"subresource": "%(subresource)s",
"subresource_path": "%(subresource_path)s",
"referrer_url": "%(referrer_url)s"
},
document.querySelector("meta[name=assert]").content,
......
......@@ -48,13 +48,11 @@ def permute_expansion(expansion, artifact_order, selection = {}, artifact_index
yield next_selection
def generate_selection(selection, spec, subresource_path,
test_html_template_basename):
def generate_selection(selection, spec, test_html_template_basename):
selection['spec_name'] = spec['name']
selection['spec_title'] = spec['title']
selection['spec_description'] = spec['description']
selection['spec_specification_url'] = spec['specification_url']
selection['subresource_path'] = subresource_path
# Oddball: it can be None, so in JS it's null.
selection['referrer_policy_json'] = json.dumps(spec['referrer_policy'])
......@@ -170,11 +168,8 @@ def generate_test_source_files(spec_json, target):
for selection_path in output_dict:
selection = output_dict[selection_path]
subresource_path = \
spec_json["subresource_path"][selection["subresource"]]
generate_selection(selection,
spec,
subresource_path,
html_template)
......
......@@ -78,7 +78,6 @@ def validate(spec_json, details):
assert_contains_only_fields(spec_json, ["specification",
"referrer_policy_schema",
"test_expansion_schema",
"subresource_path",
"excluded_tests"])
assert_non_empty_list(spec_json, "specification")
assert_non_empty_list(spec_json, "referrer_policy_schema")
......@@ -89,7 +88,6 @@ def validate(spec_json, details):
referrer_policy_schema = spec_json['referrer_policy_schema']
test_expansion_schema = spec_json['test_expansion_schema']
excluded_tests = spec_json['excluded_tests']
subresource_path = spec_json['subresource_path']
valid_test_expansion_fields = ['name'] + test_expansion_schema.keys()
......@@ -152,16 +150,6 @@ def validate(spec_json, details):
test_expansion_schema[artifact])
del details['test_expansion_field']
# Validate subresource paths.
details['object'] = subresource_path
assert_contains_only_fields(subresource_path,
test_expansion_schema['subresource']);
for subresource in subresource_path:
local_rel_path = "." + subresource_path[subresource]
full_path = os.path.join(test_root_directory, local_rel_path)
assert os.path.isfile(full_path), "%s is not an existing file" % path
del details['object']
......
......@@ -640,18 +640,5 @@
"origin",
"stripped-referrer"
]
},
"subresource_path": {
"a-tag": "/referrer-policy/generic/subresource/document.py",
"area-tag": "/referrer-policy/generic/subresource/document.py",
"fetch-request": "/referrer-policy/generic/subresource/xhr.py",
"iframe-tag": "/referrer-policy/generic/subresource/document.py",
"img-tag": "/referrer-policy/generic/subresource/image.py",
"script-tag": "/referrer-policy/generic/subresource/script.py",
"worker-request": "/referrer-policy/generic/subresource/worker.py",
"module-worker": "/referrer-policy/generic/subresource/worker.py",
"shared-worker": "/referrer-policy/generic/subresource/shared-worker.py",
"xhr-request": "/referrer-policy/generic/subresource/xhr.py"
}
}
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