tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

preloader-link-media.html (1476B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="resources/dummy.js?pipe=trickle(d1)"></script>
      6 <link rel="stylesheet" media="print" href="resources/dummy.css?print">
      7 <link rel="stylesheet" href="resources/dummy.css?non-print">
      8 <script>
      9  let t = async_test("Non-matching link media is not preloaded");
     10  window.addEventListener("load", t.step_func_done(function() {
     11    let entries = performance.getEntriesByType('resource');
     12    let found_print = null;
     13    let found_non_print = null;
     14    for (let entry of entries) {
     15      if (entry.name.includes("?print")) {
     16        assert_equals(found_print, null);
     17        found_print = entry.startTime;
     18      }
     19      if (entry.name.includes("?non-print")) {
     20        assert_equals(found_non_print, null);
     21        found_non_print = entry.startTime;
     22      }
     23    }
     24    assert_not_equals(found_print, null, "Should've loaded print sheet");
     25    assert_not_equals(found_non_print, null, "Should've loaded non-print sheet");
     26    // We can assert_greater_than (rather than greater_than_equal) because if
     27    // the non-print sheet has been preloaded but the print one hasn't, we have
     28    // the trickle mechanism to try to guarantee that enough time has passed
     29    // between one load and the next.
     30    assert_greater_than(found_print, found_non_print, "Non-print sheet should've started loading before print sheet")
     31  }));
     32 </script>