Commit bc4eee30 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Convert fast/preload/style.html and style-base.html with testharness

This test converts the two web tests with W3C testharness.js, which is a
more preferred test framework. It's also a preparation for
crrev.com/c/2451598

Bug: 1087854
Change-Id: Ibd58fe188c75258f66568f93a41ea4b994915b6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2453491
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814344}
parent e66972b8
CONSOLE MESSAGE: line 9: PASS
This test requires content_shell --run-web-tests to see the log of what resources are loaded.
<base href="resources/foo.html">
<style>
@charset "ascii";
/* */
@import "style1.css";
</style>
<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
if (window.testRunner)
testRunner.dumpAsText();
window.addEventListener('DOMContentLoaded', function() {
if (window.internals) {
var success = internals.isPreloaded("resources/style1.css");
console.log(success ? "PASS" : "FAIL");
}
}, false);
async_test(test => {
window.addEventListener('DOMContentLoaded', test.step_func(function() {
assert_own_property(window, 'internals', 'This test requires internals.isPreloaded()');
assert_true(internals.isPreloaded('resources/style1.css'), 'resources/style1.css should be preloaded');
test.done();
}));
}, 'Preload scanner should preload resources/style1.css');
</script>
This test requires content_shell --run-web-tests to see the log of what resources are loaded.
<script src=non-existant.js></script>
......
CONSOLE MESSAGE: line 9: PASS
This test requires DumpRenderTree to see the log of what resources are loaded.
<style>
@charset "ascii";
/* */
@import "resources/style1.css";
em {
@import "resources/fail.css";
}
@import "resources/fail.css";
</style>
<style>
@media print {
@import "resources/fail.css";
}
@import "resources/fail.css";
</style>
<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
if (window.testRunner)
testRunner.dumpAsText();
window.addEventListener('DOMContentLoaded', function() {
if (window.internals) {
var success = internals.isPreloaded("resources/style1.css") && !internals.isPreloaded("resources/fail.css");
console.log(success ? "PASS" : "FAIL");
}
}, false);
async_test(test => {
window.addEventListener('DOMContentLoaded', test.step_func(function() {
assert_own_property(window, 'internals', 'This test requires internals.isPreloaded()');
assert_true(internals.isPreloaded('resources/style1.css'), 'resources/style1.css should be preloaded');
assert_false(internals.isPreloaded('resources/fail.css'), 'resources/fail.css should not be preloaded');
test.done();
}));
}, 'Preload scanner should preload resources/style1.css but not resources/fail.css');
</script>
This test requires DumpRenderTree to see the log of what resources are loaded.
<script src=resources/non-existant.js></script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment