Update web-platform-tests to revision fef3eb9bbb033d1d7150f4c70ecc1a5f59bcf115

This commit is contained in:
Ms2ger 2015-04-29 21:28:37 +02:00
parent 7ee605db11
commit 14e48d959c
15 changed files with 302 additions and 131 deletions

View file

@ -22,12 +22,12 @@ cache_test(function(cache) {
cache_test(function(cache) {
return assert_promise_rejects(
cache.add('javascript://this-is-not-http-mmkay'),
'NetworkError',
'Cache.add should throw a NetworkError for non-HTTP/HTTPS URLs.');
new TypeError(),
'Cache.add should throw a TypeError for non-HTTP/HTTPS URLs.');
}, 'Cache.add called with non-HTTP/HTTPS URL');
cache_test(function(cache) {
var request = new Request('../resources/simple.txt', {method: 'POST', body: 'Hello'});
var request = new Request('../resources/simple.txt');
return cache.add(request)
.then(function(result) {
assert_equals(result, undefined,
@ -36,28 +36,18 @@ cache_test(function(cache) {
}, 'Cache.add called with Request object');
cache_test(function(cache) {
var request = new Request('../resources/simple.txt', {method: 'POST', body: 'Hello'});
return request.text()
.then(function() {
assert_false(request.bodyUsed);
})
.then(function() {
return cache.add(request);
});
}, 'Cache.add called with Request object with a used body');
cache_test(function(cache) {
var request = new Request('../resources/simple.txt', {method: 'POST', body: 'Hello'});
var request = new Request('../resources/simple.txt');
return cache.add(request)
.then(function(result) {
assert_equals(result, undefined,
'Cache.add should resolve with undefined on success.');
})
.then(function() {
return assert_promise_rejects(
cache.add(request),
new TypeError(),
'Cache.add should throw TypeError if same request is added twice.');
return cache.add(request);
})
.then(function(result) {
assert_equals(result, undefined,
'Cache.add should resolve with undefined on success.');
});
}, 'Cache.add called twice with the same Request object');
@ -137,8 +127,8 @@ cache_test(function(cache) {
var request = new Request('../resources/simple.txt');
return assert_promise_rejects(
cache.addAll([request, request]),
new TypeError(),
'Cache.addAll should throw TypeError if the same request is added ' +
'InvalidStateError',
'Cache.addAll should throw InvalidStateError if the same request is added ' +
'twice.');
}, 'Cache.addAll called with the same Request object specified twice');

View file

@ -43,8 +43,8 @@ cache_test(function(cache) {
}, 'Cache.delete called with a string URL');
cache_test(function(cache) {
var request = new Request(test_url, { method: 'POST', body: 'Abc' });
return cache.put(request.clone(), new_test_response())
var request = new Request(test_url);
return cache.put(request, new_test_response())
.then(function() {
return cache.delete(request);
})
@ -52,33 +52,9 @@ cache_test(function(cache) {
assert_true(result,
'Cache.delete should resolve with "true" if an entry ' +
'was successfully deleted.');
assert_false(request.bodyUsed,
'Cache.delete should not consume request body.');
});
}, 'Cache.delete called with a Request object');
cache_test(function(cache) {
var request = new Request(test_url, { method: 'POST', body: 'Abc' });
return cache.put(request.clone(), new_test_response())
.then(function() {
return request.text();
})
.then(function() {
assert_true(request.bodyUsed,
'[https://fetch.spec.whatwg.org/#body-mixin] ' +
'Request.bodyUsed should be true after text() method ' +
'resolves.');
})
.then(function() {
return cache.delete(request);
})
.then(function(result) {
assert_true(result,
'Cache.delete should resolve with "true" if an entry ' +
'was successfully deleted.');
});
}, 'Cache.delete with a Request object containing used body');
cache_test(function(cache) {
return cache.delete(test_url)
.then(function(result) {

View file

@ -181,32 +181,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
});
}, 'Cache.match with new Request');
cache_test(function(cache) {
var request = new Request('https://example.com/foo', {
method: 'POST',
body: 'Hello world!'
});
var response = new Response('Booyah!', {
status: 200,
headers: {'Content-Type': 'text/plain'}
});
return cache.put(request.clone(), response.clone())
.then(function() {
assert_false(
request.bodyUsed,
'[https://fetch.spec.whatwg.org/#concept-body-used-flag] ' +
'Request.bodyUsed flag should be initially false.');
})
.then(function() {
return cache.match(request);
})
.then(function(result) {
assert_false(request.bodyUsed,
'Cache.match should not consume Request body.');
});
}, 'Cache.match with Request containing non-empty body');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll(entries.a.request,
{ignoreSearch: true})
@ -464,6 +438,15 @@ cache_test(function(cache) {
});
}, 'Cache.match invoked multiple times for the same Request/Response');
prepopulated_cache_test(simple_entries, function(cache, entries) {
var request = new Request(entries.a.request, { method: 'POST' });
return cache.match(request)
.then(function(result) {
assert_equals(result, undefined,
'Cache.match should not find a match');
});
}, 'Cache.match with POST Request');
// Helpers ---
// Run |test_function| with a Cache object as its only parameter. Prior to the

View file

@ -67,29 +67,6 @@ cache_test(function(cache) {
});
}, 'Cache.put with Response without a body');
cache_test(function(cache) {
var request = new Request(test_url, {
method: 'POST',
body: 'Hello'
});
var response = new Response(test_body);
assert_false(request.bodyUsed,
'[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' +
'Request.bodyUsed should be initially false.');
return cache.put(request, response.clone())
.then(function() {
assert_true(request.bodyUsed,
'Cache.put should consume Request body.');
})
.then(function() {
return cache.match(request);
})
.then(function(result) {
assert_object_equals(result, response,
'Cache.put should store response body.');
});
}, 'Cache.put with Request containing a body');
cache_test(function(cache) {
var request = new Request(test_url);
var response = new Response(test_body);
@ -294,18 +271,11 @@ cache_test(function(cache) {
cache_test(function(cache) {
var request = new Request(test_url, {method: 'POST', body: test_body});
assert_false(request.bodyUsed,
'[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' +
'Request.bodyUsed should be initially false.');
var copy = new Request(request);
assert_true(request.bodyUsed,
'[https://fetch.spec.whatwg.org/#dom-request] ' +
'Request constructor should set input\'s used flag.');
return assert_promise_rejects(
cache.put(request, new Response(test_body)),
new TypeError(),
'Cache.put should throw a TypeError for a request with used body.');
}, 'Cache.put with a used request body');
'Cache.put should throw a TypeError for a POST request.');
}, 'Cache.put with a POST request');
cache_test(function(cache) {
var response = new Response(test_body);

View file

@ -111,8 +111,11 @@ promise_test(function(test) {
return self.caches.match(transaction.request, {cacheName: 'foo'});
})
.then(function(response) {
assert_equals(response, undefined,
'The response should not be found.');
assert_unreached('The match with bad cache name should reject.');
})
.catch(function(err) {
assert_equals(err.name, 'NotFoundError',
'The match should reject with NotFoundError.');
return self.caches.has('foo');
})
.then(function(has_foo) {

View file

@ -106,6 +106,7 @@ promise_test(function(t) {
promise_test(function(t) {
var cache_name = 'cache-storage/open';
var url = '../resources/simple.txt';
var cache;
return self.caches.delete(cache_name)
.then(function() {
@ -115,21 +116,26 @@ promise_test(function(t) {
cache = result;
})
.then(function() {
return self.caches.open(cache_name);
})
.then(function(result) {
assert_equals(result, cache,
'CacheStorage.open should return the named Cache ' +
'object if it exists.');
return cache.add('../resources/simple.txt');
})
.then(function() {
return self.caches.open(cache_name);
})
.then(function(result) {
assert_equals(result, cache,
'CacheStorage.open should return the same ' +
'instance of an existing Cache object.');
});
assert_true(result instanceof Cache,
'CacheStorage.open should return a Cache object');
assert_not_equals(result, cache,
'CacheStorage.open should return a new Cache ' +
'object each time its called.');
return Promise.all([cache.keys(), result.keys()]);
})
.then(function(results) {
var expected_urls = results[0].map(function(r) { return r.url });
var actual_urls = results[1].map(function(r) { return r.url });
assert_array_equals(actual_urls, expected_urls,
'CacheStorage.open should return a new Cache ' +
'object for the same backing store.');
})
}, 'CacheStorage.open with existing cache');
promise_test(function(t) {

View file

@ -23,7 +23,7 @@ function wait_for_message(id) {
self.addEventListener('message', function listener(e) {
if (e.data.id === id) {
resolve(e.data);
self.removeEventListener(listener);
self.removeEventListener('message', listener);
}
});
});