single-download-preload.html (3171B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/preload/resources/preload_helper.js"></script> 5 <script> 6 var t = async_test('Makes sure that preloaded resources are not downloaded again when used'); 7 </script> 8 <link rel=preload href="resources/dummy.js?single-download-preload" as=script> 9 <link rel=preload href="resources/dummy.css?single-download-preload" as=style> 10 <link rel=preload href="resources/square.png?single-download-preload" as=image> 11 <link rel=preload href="resources/square.png?background&single-download-preload" as=image> 12 <link rel=preload href="/fonts/CanvasTest.ttf?single-download-preload" as=font crossorigin> 13 <link rel=preload href="resources/white.mp4?single-download-preload" as=video> 14 <link rel=preload href="resources/sound_5.oga?single-download-preload" as=audio> 15 <link rel=preload href="resources/foo.vtt?single-download-preload" as=track> 16 <link rel=preload href="resources/dummy.xml?foo=bar" as=foobarxmlthing> 17 <link rel=preload href="resources/dummy.xml?single-download-preload"> 18 <body> 19 <style> 20 #background { 21 width: 200px; 22 height: 200px; 23 background-image: url(resources/square.png?backgroundi&single-download-preload); 24 } 25 @font-face { 26 font-family:myFont; 27 src: url(/fonts/CanvasTest.ttf?single-download-preload); 28 } 29 span { font-family: myFont, Arial; } 30 </style> 31 <link rel="stylesheet" href="resources/dummy.css?single-download-preload"> 32 <script src="resources/dummy.js?single-download-preload"></script> 33 <div id="background"></div> 34 <img src="resources/square.png?single-download-preload"> 35 <video src="resources/white.mp4?single-download-preload"> 36 <track kind=subtitles src="resources/foo.vtt?single-download-preload" srclang=en> 37 </video> 38 <audio src="resources/sound_5.oga?single-download-preload"></audio> 39 <script> 40 var xhr = new XMLHttpRequest(); 41 xhr.open("GET", "resources/dummy.xml?single-download-preload"); 42 xhr.send(); 43 44 window.addEventListener("load", t.step_func(function() { 45 verifyPreloadAndRTSupport(); 46 setTimeout(t.step_func(function() { 47 verifyLoadedAndNoDoubleDownload("resources/dummy.js?single-download-preload"); 48 verifyLoadedAndNoDoubleDownload("resources/dummy.css?single-download-preload"); 49 verifyLoadedAndNoDoubleDownload("resources/square.png?single-download-preload"); 50 verifyLoadedAndNoDoubleDownload("resources/square.png?background&single-download-preload"); 51 verifyLoadedAndNoDoubleDownload("/fonts/CanvasTest.ttf?single-download-preload"); 52 verifyNumberOfResourceTimingEntries("resources/dummy.xml?foobar", 0); 53 verifyLoadedAndNoDoubleDownload("resources/foo.vtt?single-download-preload"); 54 verifyLoadedAndNoDoubleDownload("resources/dummy.xml?single-download-preload"); 55 // FIXME: We should verify for video and audio as well, but they seem to (flakily?) trigger multiple partial requests. 56 t.done(); 57 }), 3000); 58 })); 59 </script> 60 <span>PASS - this text is here just so that the browser will download the font.</span>