11cb0ef41Sopenharmony_ci<!DOCTYPE HTML>
21cb0ef41Sopenharmony_ci<meta charset=utf-8>
31cb0ef41Sopenharmony_ci<title>PerformanceObservers: resource</title>
41cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
51cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
61cb0ef41Sopenharmony_ci<script src="performanceobservers.js"></script>
71cb0ef41Sopenharmony_ci<h1>PerformanceObservers: resource</h1>
81cb0ef41Sopenharmony_ci<p>
91cb0ef41Sopenharmony_ciNew resources will <a href="https://w3c.github.io/performance-timeline/#dfn-queue-a-performanceentry">queue a PerformanceEntry</a>.
101cb0ef41Sopenharmony_ci</p>
111cb0ef41Sopenharmony_ci<div id="log"></div>
121cb0ef41Sopenharmony_ci<script>
131cb0ef41Sopenharmony_ci  async_test(function (t) {
141cb0ef41Sopenharmony_ci    function path(pathname) {
151cb0ef41Sopenharmony_ci      var filename = pathname.substring(pathname.lastIndexOf('/')+1);
161cb0ef41Sopenharmony_ci      return pathname.substring(0, pathname.length - filename.length);
171cb0ef41Sopenharmony_ci    }
181cb0ef41Sopenharmony_ci    var gUniqueCounter = 0;
191cb0ef41Sopenharmony_ci    function generateUniqueValues() {
201cb0ef41Sopenharmony_ci      return Date.now() + "-" + (++gUniqueCounter);
211cb0ef41Sopenharmony_ci    }
221cb0ef41Sopenharmony_ci    var stored_entries = [];
231cb0ef41Sopenharmony_ci    var img_location = document.location.origin + path(document.location.pathname)
241cb0ef41Sopenharmony_ci       + "resources/square.png?random=";
251cb0ef41Sopenharmony_ci    var img1 = img_location + generateUniqueValues();
261cb0ef41Sopenharmony_ci    var img2 = img_location + generateUniqueValues();
271cb0ef41Sopenharmony_ci    var observer = new PerformanceObserver(
281cb0ef41Sopenharmony_ci        t.step_func(function (entryList, obs) {
291cb0ef41Sopenharmony_ci          stored_entries =
301cb0ef41Sopenharmony_ci            stored_entries.concat(entryList.getEntriesByType("resource"));
311cb0ef41Sopenharmony_ci          if (stored_entries.length >= 2) {
321cb0ef41Sopenharmony_ci            checkEntries(stored_entries,
331cb0ef41Sopenharmony_ci              [{ entryType: "resource", name: img1},
341cb0ef41Sopenharmony_ci               { entryType: "resource", name: img2}]);
351cb0ef41Sopenharmony_ci            observer.disconnect();
361cb0ef41Sopenharmony_ci            t.done();
371cb0ef41Sopenharmony_ci          }
381cb0ef41Sopenharmony_ci        })
391cb0ef41Sopenharmony_ci      );
401cb0ef41Sopenharmony_ci    observer.observe({entryTypes: ["resource"]});
411cb0ef41Sopenharmony_ci    var img = document.createElement("img");
421cb0ef41Sopenharmony_ci    img.src = img1;
431cb0ef41Sopenharmony_ci    document.body.appendChild(img);
441cb0ef41Sopenharmony_ci    img = document.createElement("img");
451cb0ef41Sopenharmony_ci    img.src = img2;
461cb0ef41Sopenharmony_ci    document.body.appendChild(img);
471cb0ef41Sopenharmony_ci  }, "resource entries are observable");
481cb0ef41Sopenharmony_ci</script>
49