Update web-platform-tests to revision 314de955a5102650136404f6439f22f8d838e0f4

This commit is contained in:
WPT Sync Bot 2018-05-23 21:10:23 -04:00
parent 521748c01e
commit 6b4094e2a4
133 changed files with 1609 additions and 628 deletions

View file

@ -13,15 +13,18 @@ function crossOriginUrl(path) {
}
function verify(options) {
var url = options.mode === 'cross-origin' ? crossOriginUrl(options.resource)
const url = options.mode === 'cross-origin' ? crossOriginUrl(options.resource)
: resourceUrl(options.resource);
var entryList = options.performance.getEntriesByName(url);
if (entryList.length === 0 && options.allow_no_performance_entry) {
const entryList = options.performance.getEntriesByName(url);
if (options.should_no_performance_entry) {
// The performance timeline may not have an entry for a resource
// which failed to load.
assert_equals(entryList.length, 0, options.description);
return;
}
var entry = entryList[0];
assert_equals(entryList.length, 1, options.description);
const entry = entryList[0];
assert_equals(entry.entryType, 'resource', options.description);
assert_greater_than(entry.workerStart, 0, options.description);
assert_greater_than_equal(entry.workerStart, entry.startTime, options.description);
assert_less_than_equal(entry.workerStart, entry.fetchStart, options.description);
@ -42,12 +45,12 @@ function verify(options) {
}
}
async_test(function(t) {
var worker_url = 'resources/resource-timing-worker.js';
var scope = 'resources/resource-timing-iframe.sub.html';
var registration;
promise_test(function(t) {
const worker_url = 'resources/resource-timing-worker.js';
const scope = 'resources/resource-timing-iframe.sub.html';
let registration;
service_worker_unregister_and_register(t, worker_url, scope)
return service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
registration = r;
return wait_for_state(t, r.installing, 'activated');
@ -56,7 +59,7 @@ async_test(function(t) {
return with_iframe(scope);
})
.then(function(frame) {
var performance = frame.contentWindow.performance;
const performance = frame.contentWindow.performance;
verify({
performance: performance,
resource: 'resources/dummy.js',
@ -96,28 +99,45 @@ async_test(function(t) {
resource: 'resources/missing.jpg',
mode: 'same-origin',
description: 'Network fallback load failure',
allow_no_performance_entry: true,
should_no_performance_entry: true,
});
verify({
performance: performance,
resource: 'resources/missing.jpg',
mode: 'cross-origin',
description: 'Network fallback cross-origin load failure',
allow_no_performance_entry: true,
should_no_performance_entry: true,
});
// Tests for respondWith(fetch()).
verify({
performance: performance,
resource: 'resources/missing.jpg?SWRespondsWithFetch',
mode: 'same-origin',
description: 'Resource in iframe, nonexistent but responded with fetch to another.',
});
verify({
performance: performance,
resource: 'resources/dummy.txt?SWFetched',
mode: 'same-origin',
description: 'Resource fetched as response from missing.jpg?SWRespondsWithFetch.',
should_no_performance_entry: true,
});
// Test for a normal resource that is unaffected by the Service Worker.
verify({
performance: performance,
resource: 'resources/empty-worker.js',
mode: 'same-origin',
description: 'Resource untouched by the Service Worker.',
});
frame.remove();
return registration.unregister();
})
.then(function() {
t.done();
})
.catch(unreached_rejection(t));
});
}, 'Controlled resource loads');
test(function() {
var url = resourceUrl('resources/test-helpers.sub.js');
var entry = window.performance.getEntriesByName(url)[0];
test(() => {
const url = resourceUrl('resources/test-helpers.sub.js');
const entry = window.performance.getEntriesByName(url)[0];
assert_equals(entry.workerStart, 0, 'Non-controlled');
}, 'Non-controlled resource loads');

View file

@ -6,3 +6,5 @@
<img src="https://{{domains[www1]}}:{{ports[https][0]}}/service-workers/service-worker/resources/square.png">
<img src="missing.jpg">
<img src="https://{{domains[www1]}}:{{ports[https][0]}}/service-workers/service-worker/resources/missing.jpg">
<img src='missing.jpg?SWRespondsWithFetch'>
<script src='empty-worker.js'></script>

View file

@ -6,4 +6,7 @@ self.addEventListener('fetch', function(event) {
setTimeout(_ => resolve(new Response('// Empty javascript')), 50);
}));
}
else if (event.request.url.indexOf('missing.jpg?SWRespondsWithFetch') != -1) {
event.respondWith(fetch('dummy.txt?SWFetched'));
}
});