tor-browser

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

none-sw-from-require-corp.https.html (3224B)


      1 <!doctype html>
      2 <html>
      3 <script src=/resources/testharness.js></script>
      4 <script src=/resources/testharnessreport.js></script>
      5 <script src="/common/get-host-info.sub.js"></script>
      6 <script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
      7 <script>
      8 const SCOPE = new URL(location.href).pathname;
      9 const SCRIPT =
     10  'resources/sw.js?' +
     11  `pipe=header(service-worker-allowed,${SCOPE})`;
     12 
     13 function remote(path) {
     14  const REMOTE_ORIGIN = get_host_info().HTTPS_REMOTE_ORIGIN;
     15  return new URL(path, REMOTE_ORIGIN + '/html/cross-origin-embedder-policy/');
     16 }
     17 
     18 promise_test(async (t) => {
     19  const reg = await service_worker_unregister_and_register(t, SCRIPT, SCOPE);
     20  add_completion_callback(() => {
     21      reg.unregister();
     22  });
     23  await new Promise(resolve => {
     24    navigator.serviceWorker.addEventListener('controllerchange', resolve);
     25  });
     26 }, 'setting up');
     27 
     28 promise_test(async (t) => {
     29  await fetch('resources/nothing-same-origin-corp.txt', {mode: 'no-cors'});
     30 }, 'making a same-origin request for CORP: same-origin');
     31 
     32 promise_test(async (t) => {
     33  await fetch('/common/blank.html', {mode: 'no-cors'});
     34 }, 'making a same-origin request for no CORP');
     35 
     36 promise_test(async (t) => {
     37  await fetch('resources/nothing-cross-origin-corp.js', {mode: 'no-cors'});
     38 }, 'making a same-origin request for CORP: cross-origin');
     39 
     40 promise_test(async (t) => {
     41  await promise_rejects_js(
     42    t, TypeError,
     43    fetch(remote('resources/nothing-same-origin-corp.txt'), {mode: 'no-cors'}));
     44 }, 'making a cross-origin request for CORP: same-origin');
     45 
     46 promise_test(async (t) => {
     47  await promise_rejects_js(
     48    t, TypeError, fetch(remote('/common/blank.html'), {mode: 'no-cors'}));
     49 }, 'making a cross-origin request for no CORP');
     50 
     51 promise_test(async (t) => {
     52  await fetch(
     53    remote('resources/nothing-cross-origin-corp.js'),
     54    {mode: 'no-cors'});
     55 }, 'making a cross-origin request for CORP: cross-origin');
     56 
     57 promise_test(async (t) => {
     58  await promise_rejects_js(
     59    t, TypeError,
     60    fetch(remote('resources/nothing-same-origin-corp.txt?passthrough'),
     61      {mode: 'no-cors'}));
     62 }, 'making a cross-origin request for CORP: same-origin [PASS THROUGH]');
     63 
     64 promise_test(async (t) => {
     65  await promise_rejects_js(
     66    t, TypeError,
     67    fetch(remote('/common/blank.html?passthrough'), {mode: 'no-cors'}));
     68 }, 'making a cross-origin request for no CORP [PASS THROUGH]');
     69 
     70 promise_test(async (t) => {
     71  await fetch(
     72    remote('resources/nothing-cross-origin-corp.js?passthrough'),
     73    {mode: 'no-cors'});
     74 }, 'making a cross-origin request for CORP: cross-origin [PASS THROUGH]');
     75 
     76 promise_test(async (t) => {
     77  await promise_rejects_js(
     78    t, TypeError, fetch(remote('/common/blank.html'), {mode: 'cors'}));
     79 }, 'making a cross-origin request with CORS without ACAO');
     80 
     81 promise_test(async (t) => {
     82  const URL = remote(
     83    '/common/blank.html?pipe=header(access-control-allow-origin,*)');
     84  await fetch(URL, {mode: 'cors'});
     85 }, 'making a cross-origin request with CORS');
     86 
     87 promise_test(async (t) => {
     88  const URL = remote('/fetch/api/resources/preflight.py?allow_headers=hoge');
     89  await fetch(URL, {mode: 'cors', headers: {'hoge': 'fuga'}});
     90 }, 'making a cross-origin request with CORS-preflight');
     91 
     92 </script>
     93 </html>