Revision 6a53accb3f4093ae4cd2dc8f7a086cd33c0b947f authored by Chris Nardi on 19 March 2018, 18:03:21 UTC, committed by Chris Nardi on 19 March 2018, 18:03:21 UTC
https://github.com/w3c/fxtf-drafts/issues/231 was resolved by allowing this grammar in the spec.
1 parent 730eca9
preload-with-type.html
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/preload/resources/preload_helper.js"></script>
<script src="/common/media.js"></script>
<script>
var t = async_test('Makes sure that preloaded resources with a type attribute trigger the onload event');
var scriptLoaded = false;
var styleLoaded = false;
var imageLoaded = false;
var fontLoaded = false;
var videoLoaded = false;
var audioLoaded = false;
var trackLoaded = false;
var gibberishLoaded = 0;
var getFormat = function(url) {
var dot = url.lastIndexOf('.');
if (dot != -1) {
var extension = url.substring(dot + 1);
if (extension.startsWith("og"))
return "ogg";
return extension;
}
return null;
};
var videoURL = getVideoURI("resources/A4");
var audioURL = getAudioURI("resources/sound_5");
var videoFormat = getFormat(videoURL);
var audioFormat = getFormat(audioURL);
</script>
<link rel=preload href="resources/dummy.js" as=script type="text/javascript" onload="scriptLoaded = true;">
<link rel=preload href="resources/dummy.css" as=style type="text/css" onload="styleLoaded = true;">
<link rel=preload href="resources/square.png" as=image type="image/png" onload="imageLoaded = true;">
<link rel=preload href="/fonts/CanvasTest.ttf" as=font type="font/ttf" crossorigin onload="fontLoaded = true;">
<script>
document.write('<link rel=preload href="' + videoURL + '" as=video type="video/' + videoFormat + '" onload="videoLoaded = true;">');
document.write('<link rel=preload href="' + audioURL + '" as=audio type="audio/' + audioFormat + '" onload="audioLoaded = true;">');
</script>
<link rel=preload href="resources/foo.vtt" as=track type="text/vtt" onload="trackLoaded = true;">
<link rel=preload href="resources/dummy.js" as=script type="application/foobar" onload="gibberishLoaded++;">
<link rel=preload href="resources/dummy.css" as=style type="text/foobar" onload="gibberishLoaded++;">
<link rel=preload href="resources/square.png" as=image type="image/foobar" onload="gibberishLoaded++;">
<link rel=preload href="/fonts/CanvasTest.ttf" as=font type="font/foobar" crossorigin onload="gibberishLoaded++;">
<script>
document.write('<link rel=preload href="' + videoURL + '" as=video type="video/foobar" onload="gibberishLoaded++;">');
document.write('<link rel=preload href="' + audioURL + '" as=audio type="audio/foobar" onload="gibberishLoaded++;">');
</script>
<link rel=preload href="resources/foo.vtt" as=track type="text/foobar" onload="gibberishLoaded++;">
<body>
<script src="resources/dummy.js?pipe=trickle(d5)&preload-with-type"></script>
<script>
window.onload = t.step_func(function() {
verifyPreloadAndRTSupport();
assert_true(styleLoaded, "style triggered load event");
assert_true(scriptLoaded, "script triggered load event");
assert_true(imageLoaded, "image triggered load event");
assert_true(fontLoaded, "font triggered load event");
assert_true(videoLoaded, "video triggered load event");
assert_true(audioLoaded, "audio triggered load event");
assert_true(trackLoaded, "track triggered load event");
assert_equals(gibberishLoaded, 0, "resources with gibberish type should not be loaded");
t.done();
});
</script>
</body>
</html>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...