blob: 02b6af61530b7b4b4e76b59bb718b579e322ae97 [file] [log] [blame]
<!DOCTYPE html>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script>
function printMethodError(method, target)
{
try {
method.call(target);
assert_unreached();
} catch(e) {
console.log(e);
}
}
function printPromiseMethodError(method, target)
{
return method.call(target).then(assert_unreached, (e) => {
console.log("Promise rejected with: " + e);
});
}
function printGetterError(object, getterName, target)
{
const getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName).get;
printMethodError(getter, target);
}
promise_test(function(test) {
// This test prints exceptions to check the format of their messages.
var request = new Request("");
var response = new Response("");
var results = [
printMethodError(response.clone, request),
printPromiseMethodError(response.arrayBuffer, request),
printPromiseMethodError(response.blob, request),
printPromiseMethodError(response.formData, request),
printPromiseMethodError(response.json, request),
printPromiseMethodError(response.text, request),
printGetterError(response, "body", request),
printGetterError(request, "method", response),
printMethodError(request.clone, response),
];
return Promise.all(results);
}, "Exercising TypeError messages in Fetch Request and Response");
</script>