tor-browser

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

test_audioWorkletGlobalScopeRegisterProcessor.html (3402B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for AudioWorklet</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      7  <script type="application/javascript" src="common.js"></script>
      8 </head>
      9 <body>
     10 
     11 <script type="application/javascript">
     12 
     13 function configureTest() {
     14 
     15  var expected_errors = [
     16    "TypeError: AudioWorkletGlobalScope.registerProcessor: Argument 2 is not a constructor.",
     17    "NotSupportedError: AudioWorkletGlobalScope.registerProcessor: Argument 1 should not be an empty string.",
     18    "TypeError: AudioWorkletGlobalScope.registerProcessor: Argument 2 is not an object.",
     19    "TypeError: AudioWorkletGlobalScope.registerProcessor: Element 0 in parameterDescriptors can't be converted to a dictionary.",
     20    "NotSupportedError: AudioWorkletGlobalScope.registerProcessor: Argument 1 is invalid: a class with the same name is already registered.",
     21    "TypeError: AudioWorkletGlobalScope.registerProcessor: Missing required 'name' member of AudioParamDescriptor.",
     22    "TypeError: AudioWorkletGlobalScope.registerProcessor: 'defaultValue' member of AudioParamDescriptor is not a finite floating-point value.",
     23    "TypeError: AudioWorkletGlobalScope.registerProcessor: 'minValue' member of AudioParamDescriptor is not a finite floating-point value.",
     24    "TypeError: AudioWorkletGlobalScope.registerProcessor: 'maxValue' member of AudioParamDescriptor is not a finite floating-point value.",
     25    "NotSupportedError: AudioWorkletGlobalScope.registerProcessor: Duplicated name \"test\" in parameterDescriptors.",
     26    "TypeError: AudioWorkletGlobalScope.registerProcessor: Element 0 in parameterDescriptors can't be converted to a dictionary.",
     27    "InvalidStateError: AudioWorkletGlobalScope.registerProcessor: In parameterDescriptors, test defaultValue is out of the range defined by minValue and maxValue.",
     28    "InvalidStateError: AudioWorkletGlobalScope.registerProcessor: In parameterDescriptors, test defaultValue is out of the range defined by minValue and maxValue.",
     29    "InvalidStateError: AudioWorkletGlobalScope.registerProcessor: In parameterDescriptors, test minValue should be smaller than maxValue.",
     30    ];
     31 
     32  var expected_errors_i = 0;
     33 
     34  const ConsoleAPIStorage = SpecialPowers.Cc[
     35    "@mozilla.org/consoleAPI-storage;1"
     36  ].getService(SpecialPowers.Ci.nsIConsoleAPIStorage);
     37 
     38  function observe(aSubject) {
     39    var obj = aSubject.wrappedJSObject;
     40    if (obj.arguments[0] == expected_errors[expected_errors_i]) {
     41      ok(true, "Expected error received: " + obj.arguments[0]);
     42      expected_errors_i++;
     43    }
     44 
     45    if (expected_errors_i == expected_errors.length) {
     46      // All errors have been received, this test has been completed
     47      // succesfully!
     48      ConsoleAPIStorage.removeLogEventListener(observe);
     49      SimpleTest.finish();
     50    }
     51  }
     52  ConsoleAPIStorage.addLogEventListener(observe, SpecialPowers.wrap(document).nodePrincipal);
     53 }
     54 
     55 // This function is called into an iframe.
     56 function runTestInIframe() {
     57  ok(window.isSecureContext, "Test should run in secure context");
     58  var audioContext = new AudioContext();
     59  ok(audioContext.audioWorklet instanceof AudioWorklet,
     60     "AudioContext.audioWorklet should be an instance of AudioWorklet");
     61  audioContext.audioWorklet.addModule("worklet_test_audioWorkletGlobalScopeRegisterProcessor.js")
     62 }
     63 </script>
     64 </body>
     65 </html>