chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/open-with-invalid-argument-is-noop.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
async_test(t => {
  const xhr = new XMLHttpRequest();
  xhr.open('GET', 'resources/get.txt');
  xhr.onload = t.step_func(() => {
    assert_equals(xhr.responseText, 'PASS');
    t.done();
  });

  assert_throws_dom('SyntaxError', () => {
    xhr.open('FOO BAR', 'nonexistent');
  }, 'open() should throw for a SyntaxError for an invalid method');

  xhr.send();
}, 'open() with an invalid method is no-op');

async_test(t => {
  const xhr = new XMLHttpRequest();
  xhr.open('GET', 'resources/get.txt');
  xhr.onload = t.step_func(() => {
    assert_equals(xhr.responseText, 'PASS');
    t.done();
  });

  assert_throws_dom('SecurityError', () => {
    xhr.open('CONNECT', 'nonexistent');
  }, 'open() should throw for a SecurityError for a forbidden method');

  xhr.send();
}, 'open() with a forbidden method is no-op');

async_test(t => {
  const xhr = new XMLHttpRequest();
  xhr.open('GET', 'resources/get.txt');
  xhr.onload = t.step_func(() => {
    assert_equals(xhr.responseText, 'PASS');
    t.done();
  });

  assert_throws_dom('SyntaxError', () => {
    xhr.open('GET', 'http://localhost:foobar/');
  }, 'open() should throw for a SyntaxError for an invalid URL');

  xhr.send();
}, 'open() with an invalid URL is no-op');
</script>