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

Add a few tests for whether CSS subresources are critical #5525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>background-image blocks load</title>
<link rel=help href="https://github.com/w3c/csswg-drafts/issues/1088">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=foo></div>
<style>
#foo {
width: 100px;
height: 100px;
background: url("/images/blue.png?pipe=trickle(d1)");
}
</style>
<script>
var t1 = performance.timing.responseStart;

async_test(function(t) {
window.addEventListener("load", t.step_func_done(function() {
var t2 = Date.now();
var diff = t2 - t1;
assert_greater_than(diff, 1000, "ms after style");
}));
}, "load waits for background-image");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>unused @font-face blocks load</title>
<link rel=help href="https://github.com/w3c/csswg-drafts/issues/1088">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
@font-face {
font-family: Revalia;
src: url("/fonts/Revalia.woff?pipe=trickle(d1)");
}
</style>
<script>
var t1 = performance.timing.responseStart;

async_test(function(t) {
window.addEventListener("load", t.step_func_done(function() {
var t2 = Date.now();
var diff = t2 - t1;
assert_less_than(diff, 1000, "ms after style");
}));
}, "load doesn't wait for unused @font-face");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>used @font-face blocks load</title>
<link rel=help href="https://github.com/w3c/csswg-drafts/issues/1088">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
@font-face {
font-family: Revalia;
src: url("/fonts/Revalia.woff?pipe=trickle(d1)");
}
#foo {
font: 25px/1 Revalia;
}
</style>
<div id=foo>XXX</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 2/4 font-using tests in this PR, the id=foo element comes before the <style> that includes the font, and in the other 2/4 it is the opposite. Can we make this consistent? (Not that it really matters much...)

<script>
var t1 = performance.timing.responseStart;

async_test(function(t) {
window.addEventListener("load", t.step_func_done(function() {
var t2 = Date.now();
var diff = t2 - t1;
assert_greater_than(diff, 1000, "ms after style");
}));
}, "load waits for used @font-face");
</script>
25 changes: 25 additions & 0 deletions css/css-values/subresource-criticality/tentative/import.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>@import blocks load</title>
<link rel=help href="https://github.com/w3c/csswg-drafts/issues/1088">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
</script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this <script></script> needed?

<style>
@import "support/import.css?pipe=trickle(d1)";
</style>
<div id=foo>XXX</div>
<script>
var t1 = performance.timing.responseStart;

async_test(function(t) {
window.addEventListener("load", t.step_func_done(function() {
var t2 = Date.now();
var diff = t2 - t1;
assert_greater_than(diff, 1000, "ms after style");
var style = getComputedStyle(document.querySelector("#foo"));
assert_equals(style.getPropertyValue("color"), "rgb(0, 0, 255)", "#foo.color");
}));
}, "load waits for @import");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>list-style blocks load</title>
<link rel=help href="https://github.com/w3c/csswg-drafts/issues/1088">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<ul id=foo><li>XXX</ul>
<style>
#foo {
list-style: url("/images/blue.png?pipe=trickle(d1)");
}
</style>
<script>
var t1 = performance.timing.responseStart;

async_test(function(t) {
window.addEventListener("load", t.step_func_done(function() {
var t2 = Date.now();
var diff = t2 - t1;
assert_greater_than(diff, 1000, "ms after style");
}));
}, "load waits for list-style");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#foo {
color: blue;
}