Bug 983301 Add a test for FetchEvent.respondWith(5). r=bz

This commit is contained in:
Ben Kelly 2015-08-06 18:12:14 -07:00
Родитель 83a7cbf448
Коммит c7e4c1b91c
2 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -96,6 +96,11 @@ fetchXHR('nonresponse2.txt', null, function(xhr) {
finish();
});
fetchXHR('nonpromise.txt', null, function(xhr) {
my_ok(xhr.status == 0, "load should not complete");
finish();
});
fetchXHR('headers.txt', function(xhr) {
my_ok(xhr.status == 200, "load should be successful");
my_ok(xhr.responseText == "1", "request header checks should have passed");

Просмотреть файл

@ -76,6 +76,17 @@ onfetch = function(ev) {
ev.respondWith(Promise.resolve({}));
}
else if (ev.request.url.includes("nonpromise.txt")) {
try {
// This should coerce to Promise(5) instead of throwing
ev.respondWith(5);
} catch (e) {
// test is expecting failure, so return a success if we get a thrown
// exception
ev.respondWith(new Response('respondWith(5) threw ' + e));
}
}
else if (ev.request.url.includes("headers.txt")) {
var ok = true;
ok &= ev.request.headers.get("X-Test1") == "header1";