tor-browser

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

state-and-event.https.html (1950B)


      1 <!DOCTYPE html>
      2 <meta name="timeout" content="long">
      3 <script src="/common/utils.js"></script>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="../resources/utils.js"></script>
      7 <script src="resources/utils.js"></script>
      8 
      9 <body>
     10 <script>
     11 setup(() => assertSpeculationRulesIsSupported());
     12 
     13 promise_test(async t => {
     14  // The key used for storing a test result in the server.
     15  const key = token();
     16 
     17  // Open the test runner in a popup - it will prerender itself, record the
     18  // test results, and send them back to this harness.
     19  const url = `resources/prerender-state.html?key=${key}`;
     20  window.open(url, '_blank', 'noopener');
     21 
     22  // Wait until the test sends us the results.
     23  let result = await nextValueFromServer(key);
     24  result = JSON.parse(result);
     25 
     26  assert_equals(result.prerenderingTypeOf, "boolean",
     27                "typeof(document.prerendering) is 'boolean'.");
     28  assert_equals(result.onprerenderingChangeTypeOf, "object",
     29                "typeof(document.onprerenderingchange) is 'object'.");
     30 
     31  assert_equals(
     32    result.onprerenderingchangeCalledBeforeActivate, false,
     33    "prerenderingchange event should not be called prior to activation.");
     34  assert_equals(
     35    result.prerenderingValueBeforeActivate, true,
     36    "document.prerendering should be true prior to activation.");
     37 
     38  assert_equals(result.onprerenderingchangeCalledAfterActivate, true,
     39                "prerenderingchange event should be called after activation.");
     40  assert_equals(result.prerenderingValueAfterActivate, false,
     41                "document.prerendering should be false after activation.");
     42  assert_equals(result.eventBubbles, false,
     43                "prerenderingchange event.bubbles should be false.");
     44  assert_equals(result.eventCancelable, false,
     45                "prerenderingchange event.cancelable should be false.");
     46 }, 'Test document.prerendering and its change event.');
     47 </script>