tor-browser

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

fetch-audio-tainting.https.html (1724B)


      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="resources/test-helpers.sub.js?pipe=sub"></script>
      6 <script>
      7 promise_test(async (t) => {
      8    const SCOPE = 'resources/empty.html';
      9    const SCRIPT = 'resources/fetch-rewrite-worker.js';
     10    const host_info = get_host_info();
     11    const REMOTE_ORIGIN = host_info.HTTPS_REMOTE_ORIGIN;
     12 
     13    const reg = await service_worker_unregister_and_register(t, SCRIPT, SCOPE);
     14    await wait_for_state(t, reg.installing, 'activated');
     15    const frame = await with_iframe(SCOPE);
     16 
     17    const doc = frame.contentDocument;
     18    const win = frame.contentWindow;
     19 
     20    const context = new win.AudioContext();
     21    try {
     22      context.suspend();
     23      const audio = doc.createElement('audio');
     24      audio.autoplay = true;
     25      const source = context.createMediaElementSource(audio);
     26      const spn = context.createScriptProcessor(16384, 1, 1);
     27      source.connect(spn).connect(context.destination);
     28      const url = `${REMOTE_ORIGIN}/webaudio/resources/sin_440Hz_-6dBFS_1s.wav`;
     29      audio.src = '/test?url=' + encodeURIComponent(url);
     30      doc.body.appendChild(audio);
     31 
     32      await new Promise((resolve) => {
     33        audio.addEventListener('playing', resolve);
     34      });
     35      await context.resume();
     36      const event = await new Promise((resolve) => {
     37        spn.addEventListener('audioprocess', resolve);
     38      });
     39      const data = event.inputBuffer.getChannelData(0);
     40      for (const e of data) {
     41        assert_equals(e, 0);
     42      }
     43    } finally {
     44      context.close();
     45    }
     46  }, 'Verify CORS XHR of fetch() in a Service Worker');
     47 </script>