Bug 1176988 - Patch 3 - Tests. r=jdm

Update web-platform-tests expected data
This commit is contained in:
Nikhil Marathe 2015-08-26 08:59:04 -07:00
parent eef87c3ddd
commit 03f2de8e31
3 changed files with 18 additions and 5 deletions

View File

@ -1,4 +1,4 @@
function fetchXHR(name, onload, onerror, headers) {
function fetchXHRWithMethod(name, method, onload, onerror, headers) {
expectAsyncResult();
onload = onload || function() {
@ -11,7 +11,7 @@ function fetchXHR(name, onload, onerror, headers) {
};
var x = new XMLHttpRequest();
x.open('GET', name, true);
x.open(method, name, true);
x.onload = function() { onload(x) };
x.onerror = function() { onerror(x) };
headers = headers || [];
@ -21,6 +21,10 @@ function fetchXHR(name, onload, onerror, headers) {
x.send();
}
function fetchXHR(name, onload, onerror, headers) {
return fetchXHRWithMethod(name, 'GET', onload, onerror, headers);
}
fetchXHR('bare-synthesized.txt', function(xhr) {
my_ok(xhr.status == 200, "load should be successful");
my_ok(xhr.responseText == "synthesized response body", "load should have synthesized response");
@ -297,3 +301,11 @@ fetch(new Request('body-blob', {method: 'POST', body: new Blob(new String('my bo
my_ok(body == 'my bodymy body', "the Blob body of the intercepted fetch should be visible in the SW");
finish();
});
['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'].forEach(function(method) {
fetchXHRWithMethod('xhr-method-test.txt', method, function(xhr) {
my_ok(xhr.status == 200, method + " load should be successful");
my_ok(xhr.responseText == ("intercepted " + method), method + " load should have synthesized response");
finish();
});
});

View File

@ -268,4 +268,8 @@ onfetch = function(ev) {
var url = 'http://example.com/tests/dom/security/test/cors/file_CrossSiteXHR_server.sjs?status=200';
ev.respondWith(fetch(url, { mode: 'no-cors' }));
}
else if (ev.request.url.includes('xhr-method-test.txt')) {
ev.respondWith(new Response('intercepted ' + ev.request.method));
}
};

View File

@ -3,9 +3,6 @@
[XMLHttpRequest: setRequestHeader() - headers that are allowed (Authorization)]
expected: FAIL
[XMLHttpRequest: setRequestHeader() - headers that are allowed (Pragma)]
expected: FAIL
[XMLHttpRequest: setRequestHeader() - headers that are allowed (Content-Transfer-Encoding)]
expected: FAIL