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

HTML: Add tentative tests for speculative HTML parsing #24521

Merged
merged 27 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8c6d3bc
HTML: Add tentative tests for preload scanner
zcorpan Jul 8, 2020
482b116
Add a few more picture tests
zcorpan Jul 8, 2020
4a45e7b
Compare request headers in speculative and non-speculative cases
zcorpan Sep 2, 2020
10011f6
Add more tests for script element
zcorpan Sep 2, 2020
38a4cee
Add more tests for img element
zcorpan Sep 2, 2020
742d712
Make the tests source array more readable
zcorpan Sep 3, 2020
1e84012
Fix bugs in checking headers, use 1000ms delay, rename directory
zcorpan Sep 3, 2020
6e1cc6f
Test handling of <meta charset>
zcorpan Sep 3, 2020
5770a36
Isolate normalization of headers, and trim() the value
zcorpan Sep 3, 2020
ed2c3df
Update update-built-tests.sh
zcorpan Sep 3, 2020
c851990
Don't try to compare headers when none exist; increase delay to 1500
zcorpan Sep 3, 2020
97d14e9
Test <base href>; comment on how encodingcheck works
zcorpan Sep 3, 2020
78f5e4a
Test that the speculative parser correctly simulates/runs the treebui…
zcorpan Sep 3, 2020
fac39d4
Add generate.py to lint.ignore
zcorpan Sep 3, 2020
130f246
Mark tests as tentative + tweaks and cleanup
zcorpan Sep 4, 2020
5e8d013
Test <link rel=stylesheet>
zcorpan Sep 4, 2020
c778009
Test <link rel=preload>, SVG <image>, HTML <image>, <video poster>
zcorpan Sep 4, 2020
404f65f
Test <template>
zcorpan Oct 13, 2020
432983c
Test <meta name=viewport> (only valid for mobile)
zcorpan Oct 13, 2020
5f148ba
Test CSP
zcorpan Oct 13, 2020
733aaaf
Test <meta name=referrer>
zcorpan Oct 13, 2020
1481185
Fix a mistake in document.write <meta charset> test
zcorpan Oct 26, 2020
c258849
Insert extra characters to avoid the character encoding scanner seein…
zcorpan Oct 29, 2020
eb3a68b
Change the pass condition of the meta charset test: speculative parse…
zcorpan Oct 29, 2020
b9339c8
Remove Python 3 lint exclusion
zcorpan Aug 31, 2021
655a2c3
Use == instead of 'is' in generate.py
zcorpan Sep 8, 2021
fc10383
Re-add 'Fix a mistake in document.write <meta charset> test'
zcorpan Sep 14, 2021
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
3 changes: 2 additions & 1 deletion common/slow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time

def main(request, response):
time.sleep(2)
delay = float(request.GET.first(b"delay", 2000)) / 1000
time.sleep(delay)
return 200, [], b''
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): base-href-script-src</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'base-href-script-src', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<base href=//{{domains[www1]}}:{{ports[http][0]}}><script src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;"><\/script>
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): image-src</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'image-src', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<image src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;">
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): img-data-src</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, false)
.then(compare_with_nonspeculative(uuid, 'img-data-src', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<img data-src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;">
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): img-src-crossorigin</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'img-src-crossorigin', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<img src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;" crossorigin>
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): img-src-loading-lazy</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, false)
.then(compare_with_nonspeculative(uuid, 'img-src-loading-lazy', false))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<img src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;" loading=lazy>
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): img-src-referrerpolicy-no-referrer</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'img-src-referrerpolicy-no-referrer', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<img src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;" referrerpolicy=no-referrer>
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): img-src</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'img-src', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<img src="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;">
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): img-srcset</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'img-srcset', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<img srcset="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;">
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): link-no-rel</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, false)
.then(compare_with_nonspeculative(uuid, 'link-no-rel', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<link href="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;">
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): link-rel-alternate-stylesheet</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, false)
.then(compare_with_nonspeculative(uuid, 'link-rel-alternate-stylesheet', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<link rel="alternate stylesheet" href="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;">
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): link-rel-preload-as-font-crossorigin</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'link-rel-preload-as-font-crossorigin', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<link rel=preload as=font href="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;" crossorigin>
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): link-rel-preload-as-image</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'link-rel-preload-as-image', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<link rel=preload as=image href="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;">
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): link-rel-preload-as-script</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'link-rel-preload-as-script', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<link rel=preload as=script href="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;">
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): link-rel-preload-as-style</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'link-rel-preload-as-style', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<link rel=preload as=style href="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;">
`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- DO NOT EDIT. This file has been generated. Source:
/html/syntax/speculative-parsing/tools/generate.py
-->
<meta charset=utf-8>
<title>Speculative parsing, document.write(): link-rel-stylesheet-crossorigin</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script>
<script src=/html/syntax/speculative-parsing/resources/speculative-parsing-util.js></script>
<script>
setup({single_test: true});
const uuid = token();
expect_fetched_onload(uuid, true)
.then(compare_with_nonspeculative(uuid, 'link-rel-stylesheet-crossorigin', true))
.then(done);
document.write(`
<script src="/common/slow.py?delay=1500"><\/script>
<script>
document.write('<plaintext>');
<\/script>
<\!-- speculative case in document.write -->
<link rel=stylesheet href="/html/syntax/speculative-parsing/resources/stash.py?action=put&amp;uuid=${uuid}&amp;encodingcheck=&Gbreve;" crossorigin>
`);
</script>
Loading