gecko-dev/testing/web-platform/tests/upgrade-insecure-requests/support/generate.py
Hiroshige Hayashizaki a291ae9771 Bug 1531345 [wpt PR 15538] - [WPT] Move common.js from {referrer-policy,mixed-content} to common/security-features, a=testonly
Automatic update from web-platform-tests
[WPT] Move common.js from {referrer-policy,mixed-content} to common/security-features

- Moves {referrer-policy,mixed-content}/generic/common.js (which have
  been already the same) to common/security-features/resources/common.js
  and removes a TODO comment about moving/merging common.js.
- Add common/security-features/README.md.
- Rename paths mechanically (mostly by the generators).

Bug: 906850
Change-Id: I3d60bffa5b230c04257f66b49717d5861accb979
Reviewed-on: https://chromium-review.googlesource.com/c/1476192
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634965}

--

wpt-commits: 8805f23ef629338b6d28ae25cc13839e99acea1b
wpt-pr: 15538
2019-03-16 12:13:28 +00:00

48 lines
1.8 KiB
Python

# Usage: execute
# $ python support/generate.py
# at wpt/upgrade-insecure-requests/.
#
# Note: Some tests (link-upgrade.sub.https.html and
# websocket-upgrade.https.html) are not covered by this generator script.
template = '''<!DOCTYPE html>
<html>
<head>
<!-- Generated by wpt/upgrade-insecure-requests/support/generate.py -->
<title>Upgrade Insecure Requests: %(name)s.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./support/testharness-helper.sub.js"></script>
<script src="/common/security-features/resources/common.js"></script>
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
</head>
<body>
<script>
const tests = %(generatorName)s(ResourceType.%(resourceType)s, %(sameOriginOnly)s);
tests.forEach(test => testMap['%(name)s'](test));
</script>
</body>
</html>
'''
# resourceType is |ResourceType| in testharness-helper.sub.js.
for name, resourceType in [
('image', 'IMAGE'), ('iframe', 'FRAME'),
('animation-worklet', 'WORKLET'), ('audio-worklet', 'WORKLET'),
('layout-worklet', 'WORKLET'), ('paint-worklet', 'WORKLET'),
('worker', 'WORKER'),
('module-worker', 'WORKER'),
('worker-subresource-xhr', 'IMAGE'),
('worker-subresource-fetch', 'IMAGE')]:
sameOriginOnly = 'true' if resourceType == 'WORKER' else 'false'
types = [('', 'generateTests'), ('-redirect', 'generateRedirectTests')]
if name == 'module-worker' or resourceType == 'WORKLET':
types.append(('-import', 'generateModuleImportTests'))
for typeName, generatorName in types:
with open('%s%s-upgrade.https.html' % (name, typeName), 'w') as html_file:
html_file.write(template % {
'name': name,
'resourceType': resourceType,
'generatorName': generatorName,
'sameOriginOnly': sameOriginOnly})