mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision 097043b336e46876e281ddec3bb014fe9c480128
This commit is contained in:
parent
ecd32570c0
commit
b68253eac0
405 changed files with 9164 additions and 3050 deletions
|
@ -57,6 +57,57 @@ def dump_test_parameters(selection):
|
|||
selection, indent=2, separators=(',', ': '), sort_keys=True)
|
||||
|
||||
|
||||
def get_test_filename(config, selection):
|
||||
'''Returns the filname for the main test HTML file'''
|
||||
|
||||
selection_for_filename = copy.deepcopy(selection)
|
||||
# Use 'unset' rather than 'None' in test filenames.
|
||||
if selection_for_filename['delivery_value'] is None:
|
||||
selection_for_filename['delivery_value'] = 'unset'
|
||||
|
||||
return os.path.join(config.spec_directory,
|
||||
config.test_file_path_pattern % selection_for_filename)
|
||||
|
||||
|
||||
def handle_deliveries(policy_deliveries):
|
||||
'''
|
||||
Generate <meta> elements and HTTP headers for the given list of
|
||||
PolicyDelivery.
|
||||
TODO(hiroshige): Merge duplicated code here, scope/document.py, etc.
|
||||
'''
|
||||
|
||||
meta = ''
|
||||
headers = {}
|
||||
|
||||
for delivery in policy_deliveries:
|
||||
if delivery.value is None:
|
||||
continue
|
||||
if delivery.key == 'referrerPolicy':
|
||||
if delivery.delivery_type == 'meta':
|
||||
meta += \
|
||||
'<meta name="referrer" content="%s">' % delivery.value
|
||||
elif delivery.delivery_type == 'http-rp':
|
||||
headers['Referrer-Policy'] = delivery.value
|
||||
# TODO(kristijanburnik): Limit to WPT origins.
|
||||
headers['Access-Control-Allow-Origin'] = '*'
|
||||
else:
|
||||
raise Exception(
|
||||
'Invalid delivery_type: %s' % delivery.delivery_type)
|
||||
elif delivery.key == 'mixedContent':
|
||||
assert (delivery.value == 'opt-in')
|
||||
if delivery.delivery_type == 'meta':
|
||||
meta += '<meta http-equiv="Content-Security-Policy" ' + \
|
||||
'content="block-all-mixed-content">'
|
||||
elif delivery.delivery_type == 'http-rp':
|
||||
headers['Content-Security-Policy'] = 'block-all-mixed-content'
|
||||
else:
|
||||
raise Exception(
|
||||
'Invalid delivery_type: %s' % delivery.delivery_type)
|
||||
else:
|
||||
raise Exception('Invalid delivery_key: %s' % delivery.key)
|
||||
return {"meta": meta, "headers": headers}
|
||||
|
||||
|
||||
def generate_selection(config, selection, spec, test_html_template_basename):
|
||||
test_parameters = dump_test_parameters(selection)
|
||||
# Adjust the template for the test invoking JS. Indent it to look nice.
|
||||
|
@ -80,8 +131,7 @@ def generate_selection(config, selection, spec, test_html_template_basename):
|
|||
selection['sanity_checker_js'] = config.sanity_checker_js
|
||||
selection['spec_json_js'] = config.spec_json_js
|
||||
|
||||
test_filename = os.path.join(config.spec_directory,
|
||||
config.test_file_path_pattern % selection)
|
||||
test_filename = get_test_filename(config, selection)
|
||||
test_headers_filename = test_filename + ".headers"
|
||||
test_directory = os.path.dirname(test_filename)
|
||||
|
||||
|
@ -109,13 +159,16 @@ def generate_selection(config, selection, spec, test_html_template_basename):
|
|||
except:
|
||||
pass
|
||||
|
||||
delivery = config.handleDelivery(selection, spec)
|
||||
delivery = handle_deliveries([
|
||||
util.PolicyDelivery(selection['delivery_type'],
|
||||
selection['delivery_key'],
|
||||
selection['delivery_value'])
|
||||
])
|
||||
|
||||
if len(delivery['headers']) > 0:
|
||||
with open(test_headers_filename, "w") as f:
|
||||
for header in delivery['headers']:
|
||||
f.write(header)
|
||||
f.write('\n')
|
||||
f.write('%s: %s\n' % (header, delivery['headers'][header]))
|
||||
|
||||
selection['meta_delivery_method'] = delivery['meta']
|
||||
# Obey the lint and pretty format.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue