tor-browser

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

none-sw-from-none.https.html (3141B)


      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 fetch(remote('/common/blank.html'), {mode: 'no-cors'});
     48 }, 'making a cross-origin request for no CORP');
     49 
     50 promise_test(async (t) => {
     51  await fetch(
     52    remote('resources/nothing-cross-origin-corp.js'),
     53    {mode: 'no-cors'});
     54 }, 'making a cross-origin request for CORP: cross-origin');
     55 
     56 promise_test(async (t) => {
     57  await promise_rejects_js(
     58    t, TypeError,
     59    fetch(remote('resources/nothing-same-origin-corp.txt?passthrough'),
     60      {mode: 'no-cors'}));
     61 }, 'making a cross-origin request for CORP: same-origin [PASS THROUGH]');
     62 
     63 promise_test(async (t) => {
     64  await fetch(remote('/common/blank.html?passthrough'), {mode: 'no-cors'});
     65 }, 'making a cross-origin request for no CORP [PASS THROUGH]');
     66 
     67 promise_test(async (t) => {
     68  await fetch(
     69    remote('resources/nothing-cross-origin-corp.js?passthrough'),
     70    {mode: 'no-cors'});
     71 }, 'making a cross-origin request for CORP: cross-origin [PASS THROUGH]');
     72 
     73 promise_test(async (t) => {
     74  await promise_rejects_js(
     75    t, TypeError, fetch(remote('/common/blank.html'), {mode: 'cors'}));
     76 }, 'making a cross-origin request with CORS without ACAO');
     77 
     78 promise_test(async (t) => {
     79  const URL = remote(
     80    '/common/blank.html?pipe=header(access-control-allow-origin,*)');
     81  await fetch(URL, {mode: 'cors'});
     82 }, 'making a cross-origin request with CORS');
     83 
     84 promise_test(async (t) => {
     85  const URL = remote('/fetch/api/resources/preflight.py?allow_headers=hoge');
     86  await fetch(URL, {mode: 'cors', headers: {'hoge': 'fuga'}});
     87 }, 'making a cross-origin request with CORS-preflight');
     88 </script>
     89 </html>