Update web-platform-tests to revision e29e596073468910d8655a8ec23262f17543e147

This commit is contained in:
WPT Sync Bot 2018-10-03 21:30:54 -04:00
parent e56db1f322
commit 5e2118728a
67 changed files with 1403 additions and 821 deletions

View file

@ -0,0 +1,37 @@
<html manifest="resources/appcache-iframe.manifest">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const initPromise = new Promise(resolve => {
applicationCache.addEventListener('cached', resolve, false);
applicationCache.addEventListener('noupdate', resolve, false);
});
function with_iframe(url) {
return new Promise(resolve => {
let frame = document.createElement('iframe');
frame.src = url;
frame.onload = () => { resolve(frame); };
document.body.appendChild(frame);
add_result_callback(() => frame.remove());
});
}
promise_test(async t => {
await initPromise;
const frame =
await with_iframe('resources/appcache-iframe.py?type=cached');
const msgEvent = await new Promise(r => window.onmessage = r);
assert_equals(msgEvent.data, 'Done: cached');
}, 'iframe should be loaded from application caches.');
promise_test(async t => {
await initPromise;
const frame =
await with_iframe('resources/appcache-iframe.py?type=fallingback');
const msgEvent = await new Promise(r => window.onmessage = r);
assert_equals(msgEvent.data, 'Done: fallbacked');
}, 'iframe should be loaded from application caches for fallback.');
</script>
</html>

View file

@ -0,0 +1,5 @@
def main(request, response):
type = request.GET['type']
if request.GET['type'] == 'fallingback':
return 404, [('Content-Type', 'text/plain')], "Page not found"
return [('Content-Type', 'text/plain')], type

View file

@ -0,0 +1,8 @@
CACHE MANIFEST
appcache-iframe.py?type=cached
appcache-data.py?type=cached
FALLBACK:
appcache-iframe.py?type=fallingback appcache-iframe.py?type=fallbacked
appcache-data.py?type=fallingback appcache-data.py?type=fallbacked

View file

@ -0,0 +1,43 @@
script = '''
<script>
function fetchCachedFileTest() {
return fetch('appcache-data.py?type=cached')
.then(res => res.text(),
_ => { throw new Error('Failed to fetch cached file'); })
.then(text => {
if (text != 'cached') {
throw new Error('cached file missmatch');
}
});
}
function fetchNotInCacheFileTest() {
return fetch('appcache-data.py?type=not-in-cache')
.then(_ => { throw new Error('Fetching not-in-cache file must fail'); },
_ => {});
}
function fetchFallbackFileTest() {
return fetch('appcache-data.py?type=fallingback')
.then(res => res.text(),
_ => { throw new Error('Failed to fetch fallingback file'); })
.then(text => {
if (text != 'fallbacked') {
throw new Error('fallbacked file miss match');
}
});
}
fetchCachedFileTest()
.then(fetchNotInCacheFileTest)
.then(fetchFallbackFileTest)
.then(_ => window.parent.postMessage('Done: %s'),
error => window.parent.postMessage(error.toString()));
</script>
'''
def main(request, response):
type = request.GET['type']
if request.GET['type'] == 'fallingback':
return 404, [('Content-Type', 'text/plain')], "Page not found"
return [('Content-Type', 'text/html')], script % type

View file

@ -91,6 +91,7 @@ initPromise
.then(importFallbackScriptTest)
.then(fetchCachedFileTest)
.then(fetchNotInCacheFileTest)
.then(fetchFallbackFileTest)
.then(_ => postMessage('Done: %s'),
error => postMessage(error.toString()));
'''