Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<title>Makes sure that preloaded resources trigger the onerror event</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/preload/resources/preload_helper.js"></script>
var scriptFailed = false;
var styleFailed = false;
var imageFailed = false;
var fontFailed = false;
var videoFailed = false;
var audioFailed = false;
var trackFailed = false;
var gibberishFailed = false;
var fetchFailed = false;
<link rel=preload href="http://invalid/dummy.js" as=script onerror="scriptFailed = true;">
<link rel=preload href="http://invalid/dummy.css" as=style onerror="styleFailed = true;">
<link rel=preload href="http://invalid/square.png" as=image onerror="imageFailed = true;">
<link rel=preload href="http://invalid/Ahem.ttf" as=font crossorigin onerror="fontFailed = true;">
<link rel=preload href="http://invalid/test.mp4" as=video onerror="videoFailed = true;">
<link rel=preload href="http://invalid/test.oga" as=audio onerror="audioFailed = true;">
<link rel=preload href="http://invalid/security/captions.vtt" as=track onerror="trackFailed = true;">
<link rel=preload href="http://invalid/dummy.xml?fetch" as=fetch onerror="fetchFailed = true;">
<link rel=preload href="http://invalid/dummy.xml?foo" as=foobarxmlthing onerror="assert_unreached('invalid as value should not fire error event')">
<link rel=preload href="http://invalid/dummy.xml?empty" onerror="assert_unreached('empty as value should not fire error event')">
<link rel=preload href="http://invalid/dummy.xml?media" as=style media=print onerror="assert_unreached('non-matching media should not fire error event')">
<link rel=preload href="http://invalid/dummy.xml?media" as=style type='text/html' onerror="assert_unreached('invalid mime type should not fire error event')">
setup({single_test: true});
var iterations = 0;
function check_finished() {
if (styleFailed && scriptFailed && imageFailed && fontFailed && videoFailed && audioFailed &&
trackFailed && fetchFailed) {
if (iterations == 10) {
// At least one is expected to fail, but this should give details to the exact failure(s).
assert_true(styleFailed, "style triggered error event");
assert_true(scriptFailed, "script triggered error event");
assert_true(imageFailed, "image triggered error event");
assert_true(fontFailed, "font triggered error event");
assert_true(videoFailed, "video triggered error event");
assert_true(audioFailed, "audio triggered error event");
assert_true(trackFailed, "track triggered error event");
assert_true(fetchFailed, "fetch as triggered error event");
} else {
step_timeout(check_finished, 500);
window.addEventListener("load", function() {
step_timeout(check_finished, 500);