blob: adb309dc5d2f3df7fca332b95f654fc44c0ecf5e [file] [log] [blame]
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var loaded = 0;
var expectedToLoad = 1;
</script>
<link rel=preload href="/WebKit/preload/resources/square.png?media_all" as=image media="all" onload="++loaded;">
<link rel=preload href="/WebKit/preload/resources/square.png?media_not_all" as=image media="not all">
<script>
var t = async_test('Makes sure that preloaded resources are not downloaded when the media attribute is a mismatch.');
window.setInterval(t.step_func(function() {
function verifyDownloadNumber(url, number) {
var absolute_url = new URL(url, window.location.href);
assert_equals(performance.getEntriesByName(absolute_url).length, number, url);
}
if (loaded == expectedToLoad) {
verifyDownloadNumber("/WebKit/preload/resources/square.png?media_all", 1);
verifyDownloadNumber("/WebKit/preload/resources/square.png?media_not_all", 0);
document.write('<img src="/WebKit/preload/resources/square.png?media_all">');
document.write('<img src="/WebKit/preload/resources/square.png?media_not_all">');
t.done();
}
}), 200);
</script>