tor-browser

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

request-reset-attributes.https.html (3080B)


      1 <!DOCTYPE html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="/common/get-host-info.sub.js"></script>
      5 <script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
      6 <body>
      7 <script>
      8 const worker = 'resources/request-reset-attributes-worker.js';
      9 
     10 function wait(ms) {
     11  return new Promise(resolve => step_timeout(resolve, ms));
     12 }
     13 
     14 promise_test(async (t) => {
     15    const scope = 'resources/hello.txt?name=isReloadNavigation';
     16    let frame;
     17    let reg;
     18 
     19    try {
     20      reg = await service_worker_unregister_and_register(t, worker, scope);
     21      await wait_for_state(t, reg.installing, 'activated');
     22      frame = await with_iframe(scope);
     23      assert_equals(frame.contentDocument.body.textContent,
     24                    'old: false, new: false');
     25      await new Promise((resolve) => {
     26        frame.onload = resolve;
     27        frame.contentWindow.location.reload();
     28      });
     29      assert_equals(frame.contentDocument.body.textContent,
     30                    'old: true, new: false');
     31    } finally {
     32      if (frame) {
     33        frame.remove();
     34      }
     35      if (reg) {
     36        await reg.unregister();
     37      }
     38    }
     39  }, 'Request.isReloadNavigation is reset with non-empty RequestInit');
     40 
     41 promise_test(async (t) => {
     42    const scope = 'resources/hello.html?name=isHistoryNavigation';
     43    let frame;
     44    let reg;
     45 
     46    try {
     47      reg = await service_worker_unregister_and_register(t, worker, scope);
     48      await wait_for_state(t, reg.installing, 'activated');
     49      frame = await with_iframe(scope);
     50      assert_equals(frame.contentDocument.body.textContent,
     51                    'old: false, new: false');
     52      // Use step_timeout(0) to ensure the history entry is created for Blink
     53      // and WebKit. See https://bugs.webkit.org/show_bug.cgi?id=42861.
     54      await wait(0);
     55      await new Promise((resolve) => {
     56        frame.onload = resolve;
     57        frame.src = 'resources/hello.html?ignore';
     58      });
     59      await wait(0);
     60      await new Promise((resolve) => {
     61        frame.onload = resolve;
     62        frame.contentWindow.history.go(-1);
     63      });
     64      assert_equals(frame.contentDocument.body.textContent,
     65                    'old: true, new: false');
     66    } finally {
     67      if (frame) {
     68        frame.remove();
     69      }
     70      if (reg) {
     71        await reg.unregister();
     72      }
     73    }
     74 }, 'Request.isHistoryNavigation is reset with non-empty RequestInit');
     75 
     76 promise_test(async (t) => {
     77    const scope = 'resources/hello.txt?name=mode';
     78    let frame;
     79    let reg;
     80 
     81    try {
     82      reg = await service_worker_unregister_and_register(t, worker, scope);
     83      await wait_for_state(t, reg.installing, 'activated');
     84      frame = await with_iframe(scope);
     85      assert_equals(frame.contentDocument.body.textContent,
     86                    'old: navigate, new: same-origin');
     87    } finally {
     88      if (frame) {
     89        frame.remove();
     90      }
     91      if (reg) {
     92        await reg.unregister();
     93      }
     94    }
     95  }, 'Request.mode is reset with non-empty RequestInit when it\'s "navigate"');
     96 </script>