<!DOCTYPE html>
<html>
  <head>
    <title>
      Test Connecting 0-output channel ScriptProcessor to Another Node
    </title>
    <script src="../../imported/w3c/web-platform-tests/resources/testharness.js"></script>
    <script src="../../resources/testharnessreport.js"></script>
    <script src="../resources/audit-util.js"></script>
    <script src="../resources/audit.js"></script>
  </head>
  <body>
    <script id="layout-test-code">
      let audit = Audit.createTaskRunner();
      let context;
      let scriptNode1;
      let scriptNode2;
      let analyzer;

      audit.define('initialize', (task, should) => {
        should(function() {
          context = new OfflineAudioContext(1, 1024, 44100);
        }, 'context = new OfflineAudioContext(1, 1024, 44100)').notThrow();
        should(function() {
          analyzer = context.createAnalyser();
        }, 'analyzer = context.createAnalyser()').notThrow();
        should(
            function() {
              scriptNode1 = context.createScriptProcessor(1024, 11, 0);
            },
            'scriptNode1 = context.createScriptProcessor(1024, 11, 0)')
            .notThrow();
        should(
            function() {
              scriptNode2 = context.createScriptProcessor(1024, 1, 1);
            },
            'scriptNode2 = context.createScriptProcessor(1024, 1, 1)')
            .notThrow();
        task.done();
      });

      audit.define('test', (task, should) => {
        should(function() {
          scriptNode1.connect(analyzer);
        }, 'scriptNode1.connect(analyzer)').throw(DOMException, 'InvalidAccessError');
        should(function() {
          scriptNode2.connect(analyzer);
        }, 'scriptNode2.connect(analyzer)').notThrow();
        task.done();
      });

      audit.run();
    </script>
  </body>
</html>
