blob: f07a9419f3d7b92f7b429a49e92d1de8095ddc0b [file] [log] [blame]
<!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>