Commit 8b34445d authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[WPT/referrer-policy] Merge target_protocol and origin

As we've already merged `target_protocol` and `origin` into one
`origin` value in underlying JavaScripts, this CL applies
this conversion also in generators.

Generated files will be updated after some more changes, not now.
Also, changes needed in JavaScripts to handle new generated values
are not included in this CL and will land later.

spec.src.json changes are made by:

originTypeConversion = {
  "same-origin-http": "same-http",
  "same-origin-https": "same-https",
  "cross-origin-http": "cross-http",
  "cross-origin-https": "cross-https"
}
for test_expansion in sum([s['test_expansion'] for s in spec["specification"]],
                          []) + spec["excluded_tests"]:
  if 'target_protocol' in test_expansion:
    protocols = test_expansion['target_protocol']
    origins = test_expansion['origin']
    if protocols == '*':
      protocols = ['http', 'https']
    if origins == '*':
      origins = ['same-origin', 'cross-origin']
    if isinstance(protocols, unicode):
      protocols = [protocols]
    if isinstance(origins, unicode):
      origins = [origins]
    new_origins = []
    for protocol in protocols:
      for origin in origins:
        new_origins.append(originTypeConversion[origin + '-' + protocol])
    if len(set(new_origins)) == 4:
      new_origins = u"*"
    if len(new_origins) == 1:
      new_origins = new_origins[0]
    test_expansion['origin'] = new_origins
    del test_expansion['target_protocol']
spec['test_expansion_schema']['origin'] = [
    "same-http", "same-https", "cross-http", "cross-https"
]
del spec['test_expansion_schema']['target_protocol']

Bug: 906850
Change-Id: Iaf4af8c0b599f9cc843244658a2db7577dddeb4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717470
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681090}
parent 17308745
...@@ -15,7 +15,7 @@ class ReferrerPolicyConfig(object): ...@@ -15,7 +15,7 @@ class ReferrerPolicyConfig(object):
def __init__(self): def __init__(self):
self.selection_pattern = '%(delivery_type)s/' + \ self.selection_pattern = '%(delivery_type)s/' + \
'%(origin)s/' + \ '%(origin)s/' + \
'%(source_protocol)s-%(target_protocol)s/' + \ '%(source_protocol)s/' + \
'%(subresource)s/' + \ '%(subresource)s/' + \
'%(redirection)s/' '%(redirection)s/'
...@@ -23,7 +23,7 @@ class ReferrerPolicyConfig(object): ...@@ -23,7 +23,7 @@ class ReferrerPolicyConfig(object):
'%(name)s.%(source_protocol)s.html' '%(name)s.%(source_protocol)s.html'
self.test_description_template = '''The referrer URL is %(expectation)s when a self.test_description_template = '''The referrer URL is %(expectation)s when a
document served over %(source_protocol)s requires an %(target_protocol)s document served over %(source_protocol)s requires a
sub-resource via %(subresource)s using the %(delivery_type)s sub-resource via %(subresource)s using the %(delivery_type)s
delivery method with %(redirection)s and when delivery method with %(redirection)s and when
the target request is %(origin)s.''' the target request is %(origin)s.'''
......
...@@ -126,9 +126,8 @@ def validate(spec_json, details): ...@@ -126,9 +126,8 @@ def validate(spec_json, details):
# Validate the test_expansion schema members. # Validate the test_expansion schema members.
details['object'] = test_expansion_schema details['object'] = test_expansion_schema
assert_contains_only_fields(test_expansion_schema, [ assert_contains_only_fields(test_expansion_schema, [
'expansion', 'delivery_type', 'delivery_value', 'redirection', 'expansion', 'source_protocol', 'delivery_type', 'delivery_value',
'origin', 'source_protocol', 'target_protocol', 'subresource', 'redirection', 'subresource', 'origin', 'expectation'
'expectation'
]) ])
# Validate excluded tests. # Validate excluded tests.
details['object'] = excluded_tests details['object'] = excluded_tests
......
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