Bug 1415740 P2 Add a WPT test to verify we report workerStart on cross-origin no-cors requests, like <img>. r=baku

--HG--
rename : testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.html => testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.sub.html
This commit is contained in:
Ben Kelly 2017-11-10 00:33:59 -08:00
Родитель 6c269afe1a
Коммит 2a3257bb20
3 изменённых файлов: 36 добавлений и 12 удалений

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

@ -281871,7 +281871,7 @@
{}
]
],
"service-workers/service-worker/resources/resource-timing-iframe.html": [
"service-workers/service-worker/resources/resource-timing-iframe.sub.html": [
[
{}
]
@ -578701,7 +578701,7 @@
"testharness"
],
"service-workers/service-worker/resource-timing.https.html": [
"9ca1caf0b8216eda8956be0d98eb7b5ab2d92a43",
"a835a0baeb4fcc0c44e6be28502f89308464acc5",
"testharness"
],
"service-workers/service-worker/resources/404.py": [
@ -579460,8 +579460,8 @@
"c939271e717288203a5a298b95a7328100bd7c80",
"support"
],
"service-workers/service-worker/resources/resource-timing-iframe.html": [
"0fc85a13c536aad45a87fb073fdcebf371d4476d",
"service-workers/service-worker/resources/resource-timing-iframe.sub.html": [
"c18c96a25dec48ae9d53359d4ca987ba857878a1",
"support"
],
"service-workers/service-worker/resources/resource-timing-worker.js": [

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

@ -8,13 +8,25 @@ function resourceUrl(path) {
return get_host_info()['HTTPS_ORIGIN'] + base_path() + path;
}
function verify(performance, resource, description) {
var entry = performance.getEntriesByName(resourceUrl(resource))[0];
function crossOriginUrl(path) {
return get_host_info()['HTTPS_REMOTE_ORIGIN'] + base_path() + path;
}
function verify(performance, resource, mode, description) {
var url = mode === 'cross-origin' ? crossOriginUrl(resource)
: resourceUrl(resource);
var entryList = performance.getEntries();
var entry = performance.getEntriesByName(url)[0];
assert_greater_than(entry.workerStart, 0, description);
assert_greater_than_equal(entry.workerStart, entry.startTime, description);
assert_less_than_equal(entry.workerStart, entry.fetchStart, description);
assert_greater_than_equal(entry.responseStart, entry.fetchStart, description);
assert_greater_than_equal(entry.responseEnd, entry.responseStart, description);
if (mode === 'cross-origin') {
assert_equals(entry.responseStart, 0, description);
assert_greater_than_equal(entry.responseEnd, entry.fetchStart, description);
} else {
assert_greater_than_equal(entry.responseStart, entry.fetchStart, description);
assert_greater_than_equal(entry.responseEnd, entry.responseStart, description);
}
assert_greater_than(entry.responseEnd, entry.fetchStart, description);
assert_greater_than(entry.duration, 0, description);
if (resource.indexOf('redirect.py') != -1) {
@ -27,7 +39,7 @@ function verify(performance, resource, description) {
async_test(function(t) {
var worker_url = 'resources/resource-timing-worker.js';
var scope = 'resources/resource-timing-iframe.html';
var scope = 'resources/resource-timing-iframe.sub.html';
var registration;
service_worker_unregister_and_register(t, worker_url, scope)
@ -40,10 +52,20 @@ async_test(function(t) {
})
.then(function(frame) {
var performance = frame.contentWindow.performance;
verify(performance, 'resources/dummy.js', 'Generated response');
verify(performance, 'resources/empty.js', 'Network fallback');
verify(performance, 'resources/dummy.js', 'same-origin',
'Generated response');
verify(performance, 'resources/empty.js', 'same-origin',
'Network fallback');
verify(performance, 'resources/redirect.py?Redirect=empty.js',
'Redirect');
'same-origin', 'Redirect');
verify(performance, 'resources/missing.jpg', 'same-origin',
'Network fallback image');
// Test that worker start is available on cross-origin no-cors
// subresources.
verify(performance, 'resources/missing.jpg', 'cross-origin',
'Network fallback cross-origin image');
frame.remove();
return registration.unregister();
})

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

@ -2,3 +2,5 @@
<script src="empty.js"></script>
<script src="dummy.js"></script>
<script src="redirect.py?Redirect=empty.js"></script>
<img src="missing.jpg">
<img src="https://{{domains[www1]}}:{{ports[https][0]}}/service-workers/service-worker/resources/missing.jpg">