Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype for fetch metadata test generation #13

Draft
wants to merge 127 commits into
base: master-coop-coep
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
3a8e85e
PARTIAL [fetch] Prototype tool for test generation
jugglinmike Nov 27, 2019
00180cb
Increase veracity
jugglinmike Nov 29, 2019
cc555e4
Replace some test with generated equivalents
jugglinmike Nov 30, 2019
936571e
Correct metadata
jugglinmike Dec 4, 2019
5421a2b
Start to almost experiment with iteration
jugglinmike Dec 4, 2019
deeb5cb
Introduce Jinja
jugglinmike Dec 5, 2019
2772197
Redo kind of
jugglinmike Dec 6, 2019
6e781b6
Parameterize script tags
jugglinmike Dec 6, 2019
dd2492c
Remove experiment
jugglinmike Dec 6, 2019
342923a
Add tests for Application Cache manifest download
jugglinmike Dec 6, 2019
c0c5aee
Reduce repetition in generated output
jugglinmike Dec 6, 2019
a450b56
Improve formatting
jugglinmike Dec 6, 2019
9283d98
Re-introduce utility resource
jugglinmike Dec 6, 2019
0cc2c84
Check in resource
jugglinmike Dec 6, 2019
d67f78e
Add some tests for form submission
jugglinmike Dec 7, 2019
aaa2544
Extend template
jugglinmike Dec 7, 2019
83b8c46
Improve names of generated tests
jugglinmike Dec 7, 2019
3d253d1
Refactor heavily
jugglinmike Dec 9, 2019
43eba8e
Improve test titles
jugglinmike Dec 9, 2019
431c69d
Split form submission
jugglinmike Dec 9, 2019
dada5a7
Support POST redirection
jugglinmike Dec 9, 2019
fb208d4
Reformat cases
jugglinmike Dec 9, 2019
2f5606b
Introduce support for template filtering
jugglinmike Dec 9, 2019
a1c42d1
Further segment tests for Sec-Fetch-Mode
jugglinmike Dec 9, 2019
74df861
Make "mode" tests more targetted
jugglinmike Dec 10, 2019
e4451c4
Improve template names
jugglinmike Dec 10, 2019
befda28
Refine further
jugglinmike Dec 10, 2019
fd4d431
Refactor heavily again
jugglinmike Dec 10, 2019
b9b4dd0
Refactor again
jugglinmike Dec 10, 2019
2253d1d
Extend template for `img` element
jugglinmike Dec 10, 2019
b1a701a
Improve formatting
jugglinmike Dec 10, 2019
4b4764e
Add template and tests for `fetch` method
jugglinmike Dec 10, 2019
029648c
Add templates for naviation via global property
jugglinmike Dec 10, 2019
519dc87
Concatenate description properties
jugglinmike Dec 10, 2019
d6cfff0
Correct protocol usage
jugglinmike Dec 10, 2019
65517a9
Further subdivide redirection tests
jugglinmike Dec 11, 2019
ed424a6
Correct construction of form requests
jugglinmike Dec 11, 2019
426d000
Add tests for font requests
jugglinmike Dec 11, 2019
09bd2d9
Improve formatting slightly
jugglinmike Dec 11, 2019
f834704
Remove dead code
jugglinmike Dec 11, 2019
870eafb
Add template for CORS preflight
jugglinmike Dec 11, 2019
01210aa
Add README file
jugglinmike Dec 12, 2019
7225a11
Add initial tests for Sec-Fetch-Dest
jugglinmike Dec 12, 2019
011df04
Add tests for dedicated workers
jugglinmike Dec 12, 2019
949baf0
Add support to make URL construction more concise
jugglinmike Dec 13, 2019
7efd512
Release handle immediately and reduce nesting
jugglinmike Dec 13, 2019
6e853a3
Generate subtests up-front
jugglinmike Dec 13, 2019
8215b02
Warn about unused templates
jugglinmike Dec 13, 2019
8c933a8
Improve subtest titles
jugglinmike Dec 13, 2019
482e0c4
Correct variable name
jugglinmike Dec 13, 2019
247077e
Add more HTTP redirection tests
jugglinmike Dec 13, 2019
3158186
Correct syntax error
jugglinmike Dec 13, 2019
3aeb1de
Correct URL specification
jugglinmike Dec 13, 2019
abbf82d
Correct scheme used by tests
jugglinmike Dec 13, 2019
0088182
Invoke `importScripts` with URL
jugglinmike Dec 14, 2019
1a70215
Add more redirection tests
jugglinmike Dec 14, 2019
01eccaf
Enable more tests for dedicated workers
jugglinmike Dec 14, 2019
1cb94c5
Add more cases and correct template sets
jugglinmike Dec 14, 2019
4fdb1bb
Rename templates
jugglinmike Dec 14, 2019
c2a1c83
Add tests for video element
jugglinmike Dec 14, 2019
e8ee357
Trigger navigation from parent context
jugglinmike Dec 14, 2019
49be243
Add some tests for Sec-Fetch-User
jugglinmike Dec 14, 2019
fafaf6d
Extend `location` tests to support user activation
jugglinmike Dec 14, 2019
b72ed1c
Add precondition for appCache
jugglinmike Apr 29, 2020
3ab6a2e
Explain code used to induce a preflight request
jugglinmike Apr 29, 2020
fbf93be
Correct guard against false positives
jugglinmike Apr 29, 2020
d7887af
Use more appropriate variable name
jugglinmike Apr 29, 2020
409f506
Normalize test structure
jugglinmike Apr 29, 2020
7c1aa9c
Reduce reliance on polling
jugglinmike Apr 29, 2020
441aa53
Relocate comment
jugglinmike Apr 29, 2020
dcc015e
Change terminology
jugglinmike Apr 29, 2020
294a8c9
Rename template
jugglinmike Apr 29, 2020
b11bfdc
Generate absolute URLs consistently
jugglinmike Apr 30, 2020
f5063f5
Update script that detects accidental modification
jugglinmike Apr 30, 2020
a92e9ee
Programmatically generate test provenance
jugglinmike Apr 30, 2020
6e78190
Remove outdated files
jugglinmike May 2, 2020
7eef86b
Move header names
jugglinmike Apr 30, 2020
84c90d8
Build subtest titles in templates
jugglinmike May 1, 2020
8da4245
Group all subtests by template
jugglinmike May 1, 2020
d1fe665
Poll for video poster loading on the client
jugglinmike May 1, 2020
18d05d2
Normalize test file names
jugglinmike May 11, 2020
f3e0d2a
Generalize generator & increase case literalness
jugglinmike May 11, 2020
6f9b8da
Improve terminology and reduce repetition
jugglinmike May 12, 2020
9d2b386
Add tests for HTML audio element
jugglinmike May 12, 2020
62ff43e
Add tests for AudioWorklet
jugglinmike May 12, 2020
3d86674
Document rationale
jugglinmike May 13, 2020
1e56fa6
Add tests for frames and iframes
jugglinmike May 13, 2020
00f7f54
Improve subtest title filter
jugglinmike May 13, 2020
f8e0bdf
Add tests for anchor element
jugglinmike May 13, 2020
9d7d743
Remove empty line
jugglinmike May 13, 2020
e49f4bc
Add trailing newline to generated files
jugglinmike May 13, 2020
ebbd785
Refactor tests to support anchor's `download` attr
jugglinmike May 13, 2020
6481173
Tolerate slow UAs
jugglinmike May 13, 2020
ad92b5f
Improve coverage for Sec-Fetch-Mode
jugglinmike May 13, 2020
4a2e89c
Correct expected value
jugglinmike May 13, 2020
67fc599
Add tests for area element
jugglinmike May 13, 2020
02cde36
Add tests for <meta> Refresh
jugglinmike May 13, 2020
6b2a81c
Add tests for Refresh header
jugglinmike May 13, 2020
b0f196c
PARTIAL: Begin test for History API
jugglinmike May 14, 2020
f020452
Remove faulty History tests
jugglinmike May 14, 2020
f235c9d
Complete tests for History navigation
jugglinmike May 14, 2020
6047a40
Rename video poster template
jugglinmike May 14, 2020
92be624
Add tests for embed element
jugglinmike May 14, 2020
2ac0831
Add tests for CSS font-face
jugglinmike May 14, 2020
d33d196
Add tests for link[rel=icon] element
jugglinmike May 15, 2020
32dc732
Add tests for SVG image element
jugglinmike May 15, 2020
ab82d8c
Rename template for HTML img element
jugglinmike May 15, 2020
e04c57e
Add tests for CSS background-image
jugglinmike May 15, 2020
3bad1d2
Relocate tentative filename flag
jugglinmike May 15, 2020
969fb7a
Update documentation
jugglinmike May 15, 2020
e4e4581
Improve example
jugglinmike May 15, 2020
e6f77cf
Add tests for all other CSS image sources
jugglinmike May 15, 2020
1181823
Add tests for img element's srcset attribute
jugglinmike May 15, 2020
93f3ae0
Add tests for picture element
jugglinmike May 15, 2020
31e2360
Add tests for input[type=image]
jugglinmike May 15, 2020
884260d
fixup! Add tests for picture element
jugglinmike May 16, 2020
6073c84
Add tests for Link HTTP header
jugglinmike May 16, 2020
d6b270b
Add document titles
jugglinmike May 16, 2020
688b382
Remove duplicated template
jugglinmike May 16, 2020
b7dea63
Add more tests for Link HTTP header
jugglinmike May 16, 2020
e681c3f
Remove unnecessary code
jugglinmike May 16, 2020
957a932
Move repetition into template
jugglinmike May 16, 2020
b1e565e
Add documentation
jugglinmike May 16, 2020
dae0379
Improve documentation
jugglinmike Aug 24, 2020
f625beb
Document rationale for skipped templates
jugglinmike Aug 24, 2020
992bbeb
Expand template
jugglinmike Aug 24, 2020
ac68f68
Add tests for `img` following change to env
jugglinmike Aug 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions common/refresh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def main(request, response):
"""
Respond with a blank HTML document and a `Refresh` header which describes
an immediate redirect to the URL specified by the requests `location` query
string parameter
"""
headers = [
('Content-Type', 'text/html'),
('Refresh', '0; URL={}'.format(request.GET.first('location')))
]
return (200, headers, '')
2 changes: 2 additions & 0 deletions fetch/api/resources/redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def main(request, response):

if "redirect_status" in request.GET:
status = int(request.GET['redirect_status'])
elif "redirect_status" in request.POST:
status = int(request.POST['redirect_status'])

stashed_data['count'] += 1

Expand Down
296 changes: 296 additions & 0 deletions fetch/metadata/generated/appcache-manifest.https.sub.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
<!DOCTYPE html>
<!--
This test was procedurally generated. Please do not modify it directly.
Sources:
- fetch/metadata/tools/fetch-metadata.conf.yml
- fetch/metadata/tools/templates/appcache-manifest.sub.https.html
-->
<html lang="en">
<meta charset="utf-8">
<title>HTTP headers on request for Appcache manifest</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/fetch/metadata/resources/helper.sub.js"></script>
<body>
<script>
'use strict';

function induceRequest(url) {
const iframe = document.createElement('iframe');
iframe.src =
'/fetch/metadata/resources/appcache-iframe.sub.html?manifest=' + encodeURIComponent(url);

return new Promise((resolve) => {
addEventListener('message', function onMessage(event) {
if (event.source !== iframe.contentWindow) {
return;
}
removeEventListener('message', onMessage);
resolve(event.data);
});

document.body.appendChild(iframe);
})
.then((message) => {
if (message !== 'okay') {
throw message;
}
})
.then(() => iframe.remove());
}

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameOrigin', 'httpOrigin']))
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-site');
});
}, 'sec-fetch-site - HTTPS downgrade (header not sent)');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['httpOrigin', 'sameOrigin']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'cross-site');
});
}, 'sec-fetch-site - HTTPS upgrade');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameOrigin', 'httpOrigin', 'sameOrigin']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'cross-site');
});
}, 'sec-fetch-site - HTTPS downgrade-upgrade');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameOrigin', 'crossSite', 'sameOrigin']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'cross-site');
});
}, 'sec-fetch-site - Same-Origin -> Cross-Site -> Same-Origin redirect');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['crossSite', 'sameOrigin']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'cross-site');
});
}, 'sec-fetch-site - Cross-Site -> Same Origin');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['crossSite', 'sameSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'cross-site');
});
}, 'sec-fetch-site - Cross-Site -> Same-Site');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['crossSite', 'crossSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'cross-site');
});
}, 'sec-fetch-site - Cross-Site -> Cross-Site');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameOrigin', 'sameOrigin']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'same-origin');
});
}, 'sec-fetch-site - Same-Origin -> Same Origin');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameOrigin', 'sameSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'same-site');
});
}, 'sec-fetch-site - Same-Origin -> Same-Site');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameOrigin', 'crossSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'cross-site');
});
}, 'sec-fetch-site - Same-Origin -> Cross-Site');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameSite', 'sameOrigin']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'same-site');
});
}, 'sec-fetch-site - Same-Site -> Same Origin');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameSite', 'sameSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'same-site');
});
}, 'sec-fetch-site - Same-Site -> Same-Site');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameSite', 'crossSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'cross-site');
});
}, 'sec-fetch-site - Same-Site -> Cross-Site');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, ['sameOrigin', 'httpOrigin', 'sameOrigin']))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_equals(headers['sec-fetch-site'], 'cross-site');
});
}, 'sec-fetch-site - HTTPS downgrade-upgrade');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, []))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_equals(headers['sec-fetch-mode'], 'no-cors');
});
}, 'sec-fetch-mode');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, []))
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-dest');
assert_equals(headers['sec-fetch-dest'], 'empty');
});
}, 'sec-fetch-dest');

promise_test(() => {
const key = '{{uuid()}}';
assert_precondition(
!!window.applicationCache,
'Application Cache is not supported.'
);

return induceRequest(makeRequestURL(key, []))
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-user');
});
}, 'sec-fetch-user');
</script>
</body>
</html>
Loading