tor-browser

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

audioworklet-throw-onmessage.https.html (2027B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <meta charset="utf-8" />
      5    <title>
      6      Test the behaviour of AudioWorkletProcessor when an `onmessage` handler
      7      throws.
      8    </title>
      9    <script src="/resources/testharness.js"></script>
     10    <script src="/resources/testharnessreport.js"></script>
     11    <script src="/webaudio/js/helpers.js"></script>
     12  </head>
     13 
     14  <body>
     15    <script id="processor" type="worklet">
     16      registerProcessor("test-throw", class param extends AudioWorkletProcessor {
     17        constructor() {
     18          super()
     19          this.i = 0;
     20          this.port.onmessage = function(arg) {
     21            throw "asdasd";
     22          }
     23        }
     24        process(input, output, parameters) {
     25          this.i++;
     26          this.port.postMessage(this.i);
     27          return true;
     28        }
     29      });
     30    </script>
     31    <script>
     32      var latestIndexReceived = 0;
     33      var node = null;
     34      var ac = null;
     35      promise_setup(function() {
     36        ac = new AudioContext();
     37        var url = URLFromScriptsElements(["processor"]);
     38        return ac.audioWorklet.addModule(url).then(function() {
     39          node = new AudioWorkletNode(ac, "test-throw");
     40          node.port.onmessage = function(e) {
     41            latestIndexReceived = parseInt(e.data);
     42          };
     43        });
     44      });
     45      promise_test(async t => {
     46        var currentIndex = latestIndexReceived;
     47        await t.step_wait(() => {
     48          return latestIndexReceived > currentIndex;
     49        }, "Process is still being called");
     50 
     51        node.port.postMessage("asdasd"); // This throws on the processor side.
     52        node.onprocessorerror = function() {
     53          assert_true(false, "onprocessorerror must not be called.");
     54        };
     55        currentIndex = latestIndexReceived;
     56        await t.step_wait(() => {
     57          return latestIndexReceived > currentIndex + 2;
     58        }, "Process is still being called");
     59      }, `Throwing in an onmessage handler in the AudioWorkletGlobalScope shouldn't stop AudioWorkletProcessor`);
     60    </script>
     61  </body>
     62 </html>