| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 1 | <!DOCTYPE html> | 
 | 2 | <script src="/resources/testharness.js"></script> | 
 | 3 | <script src="/resources/testharnessreport.js"></script> | 
| Yoav Weiss | 82ed307 | 2017-02-08 13:51:58 | [diff] [blame] | 4 | <script src="/preload/resources/preload_helper.js"></script> | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 5 | <script> | 
 | 6 |  var t = async_test('Makes sure that preloaded resources are not downloaded again when used'); | 
 | 7 | </script> | 
| Dragana Damjanovic | e7327c5 | 2017-08-02 10:55:47 | [diff] [blame] | 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> | 
| Geoffrey Sneddon | d56bf78 | 2018-03-15 16:41:44 | [diff] [blame] | 12 | <link rel=preload href="/fonts/CanvasTest.ttf?single-download-preload" as=font crossorigin> | 
| Dragana Damjanovic | e7327c5 | 2017-08-02 10:55:47 | [diff] [blame] | 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> | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 16 | <link rel=preload href="resources/dummy.xml?foo=bar" as=foobarxmlthing> | 
| Dragana Damjanovic | e7327c5 | 2017-08-02 10:55:47 | [diff] [blame] | 17 | <link rel=preload href="resources/dummy.xml?single-download-preload"> | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 18 | <body> | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 19 | <style> | 
 | 20 |  #background { | 
 | 21 |  width: 200px; | 
 | 22 |  height: 200px; | 
| Dragana Damjanovic | e7327c5 | 2017-08-02 10:55:47 | [diff] [blame] | 23 |  background-image: url(resources/square.png?backgroundi&single-download-preload); | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 24 |  } | 
 | 25 |  @font-face { | 
| Luke Zielinski | c66230e | 2019-09-06 18:17:53 | [diff] [blame] | 26 |  font-family:myFont; | 
| Geoffrey Sneddon | d56bf78 | 2018-03-15 16:41:44 | [diff] [blame] | 27 |  src: url(/fonts/CanvasTest.ttf?single-download-preload); | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 28 |  } | 
| Luke Zielinski | c66230e | 2019-09-06 18:17:53 | [diff] [blame] | 29 |  span { font-family: myFont, Arial; } | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 30 | </style> | 
| Dragana Damjanovic | e7327c5 | 2017-08-02 10:55:47 | [diff] [blame] | 31 | <link rel="stylesheet" href="resources/dummy.css?single-download-preload"> | 
 | 32 | <script src="resources/dummy.js?single-download-preload"></script> | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 33 | <div id="background"></div> | 
| Dragana Damjanovic | e7327c5 | 2017-08-02 10:55:47 | [diff] [blame] | 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> | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 37 | </video> | 
| Dragana Damjanovic | e7327c5 | 2017-08-02 10:55:47 | [diff] [blame] | 38 | <audio src="resources/sound_5.oga?single-download-preload"></audio> | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 39 | <script> | 
 | 40 |  var xhr = new XMLHttpRequest(); | 
| Dragana Damjanovic | e7327c5 | 2017-08-02 10:55:47 | [diff] [blame] | 41 |  xhr.open("GET", "resources/dummy.xml?single-download-preload"); | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 42 |  xhr.send(); | 
 | 43 |  | 
 | 44 |  window.addEventListener("load", t.step_func(function() { | 
| Yoav Weiss | 82ed307 | 2017-02-08 13:51:58 | [diff] [blame] | 45 |  verifyPreloadAndRTSupport(); | 
 | 46 |  setTimeout(t.step_func(function() { | 
| Kunihiko Sakamoto | eb5aa00 | 2019-02-05 03:35:20 | [diff] [blame] | 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"); | 
| Yoav Weiss | 82ed307 | 2017-02-08 13:51:58 | [diff] [blame] | 55 |  // FIXME: We should verify for video and audio as well, but they seem to (flakily?) trigger multiple partial requests. | 
 | 56 |  t.done(); | 
| Kunihiko Sakamoto | eb5aa00 | 2019-02-05 03:35:20 | [diff] [blame] | 57 |  }), 3000); | 
| Yoav Weiss | e8172dd | 2016-12-19 08:42:18 | [diff] [blame] | 58 |  })); | 
 | 59 | </script> | 
 | 60 | <span>PASS - this text is here just so that the browser will download the font.</span> |