DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (205d1b4e8f69)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name=timeout content=long>
<title>Resource Timing - Check that workerStart is TAO protected</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
</head>
<body>
<script>

const addFrame = url => {
  const iframe = document.createElement("iframe");
  iframe.src = url;
  document.body.appendChild(iframe);
};

const host_info = get_host_info();

// Open window to remote origin with a SW install
let openee;
promise_test(t => {
  return new Promise(resolve => {
    addEventListener("message", e => {
      if (e.data === 'installed') {
        performance.clearResourceTimings();
        resolve();
      }
    });
    openee = window.open(host_info.HTTPS_REMOTE_ORIGIN + "/resource-timing/resources/sw-install.html");
  });
}, "Install a SW")


// Add iframe to remote origin - page without TAO
promise_test(t => {
  return new Promise((resolve, reject) => {
    const observer = new PerformanceObserver(list => {
      const entries = list.getEntries();
      for (entry of entries) {
        if (entry.name.includes("blank_page_green.htm")) {
          observer.disconnect();
          // Observe its performance entry to make sure workerStart is zero
          if (entry.workerStart != 0) {
            reject("workerStart should be zero");
          }
          resolve();
        }
      }
    });
    observer.observe({entryTypes: ["resource"]});
    addFrame(host_info.HTTPS_REMOTE_ORIGIN + "/resource-timing/resources/blank_page_green.htm");
  });
}, "Add TAO-less iframe to remote origin. Make sure workerStart is zero");

// Add iframe to remote origin - page with TAO
promise_test(t => {
  let unregisterPromise = new Promise(resolve => {
    addEventListener("message", e => {
      if (e.data === "unregistered") {
        resolve();
      }
    });
  });
  t.add_cleanup(async () => {
    openee.postMessage("unregister", "*");
    await unregisterPromise;
    // Close the window.
    openee.close();
  });
  return new Promise((resolve, reject) => {
    const observer = new PerformanceObserver(list => {
      const entries = list.getEntries();
      for (entry of entries) {
        if (entry.name.includes("blank-with-tao.html")) {
          // Observe its performance entry to make sure workerStart is zero
          if (entry.workerStart == 0) {
            reject("workerStart should not be zero");
          }
          resolve();
        }
      }
    });
    observer.observe({entryTypes: ["resource"]});
    addFrame(host_info.HTTPS_REMOTE_ORIGIN + "/resource-timing/resources/blank-with-tao.html");
  });
}, "Add TAO iframe to remote origin. Make sure workerStart is not zero");
// Observe its performance entry to make sure workerStart is not zero
</script>
</body>
</html>