Update web-platform-tests to revision 81962ac8802223d038b188b6f9cb88a0a9c5beee

This commit is contained in:
WPT Sync Bot 2018-05-18 22:02:29 -04:00
parent fe1a057bd1
commit 24183668c4
1960 changed files with 29853 additions and 10555 deletions

View file

@ -0,0 +1 @@
@igrigorik

View file

@ -9,10 +9,10 @@
setup({explicit_done: true})
const hostInfo = get_host_info()
const resourceUrl = 'server-timing/resources/blue.png'
const urls = {
'same-origin': `${hostInfo.HTTP_ORIGIN}/${resourceUrl}`,
'cross-origin': `${hostInfo.HTTP_REMOTE_ORIGIN}/${resourceUrl}`
'same-origin': `${hostInfo.HTTP_ORIGIN}/server-timing/resources/blue.png`,
'cross-origin': `${hostInfo.HTTP_REMOTE_ORIGIN}/server-timing/resources/blue.png`,
'cross-origin-tao': `${hostInfo.HTTP_REMOTE_ORIGIN}/server-timing/resources/blue_tao.png`
}
Object.keys(urls).forEach(function(key) {
const img = document.createElement('img')
@ -28,6 +28,7 @@
}
assertServerTimingEntries(urls['same-origin'], 1)
assertServerTimingEntries(urls['cross-origin'], 0)
assertServerTimingEntries(urls['cross-origin-tao'], 1)
done()
})
</script>

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<head>
<meta charset='utf-8' />
<script src="/resources/testharness.js"></script>
<script src='/resources/testharnessreport.js'></script>
<script>
setup({explicit_done: true})
window.addEventListener('load', function(){
assert_not_equals(typeof performance.getEntriesByType('navigation')[0].serverTiming, 'undefined',
'An instance of `PerformanceNavigationTiming` should have a `serverTiming` attribute.')
done()
})
</script>
</head>

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<head>
<meta charset='utf-8' />
<script src="/resources/testharness.js"></script>
<script src='/resources/testharnessreport.js'></script>
<script>
setup({explicit_done: true})
window.addEventListener('load', function(){
assert_not_equals(typeof performance.getEntriesByType('resource')[0].serverTiming, 'undefined',
'An instance of `PerformanceResourceTiming` should have a `serverTiming` attribute.')
done()
})
</script>
</head>

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

View file

@ -0,0 +1,2 @@
Timing-Allow-Origin: *
Server-Timing: metric2; dur=2.1; desc=blue.png

View file

@ -0,0 +1,49 @@
<!DOCTYPE html>
<!--
tests generated by:
https://github.com/cvazac/generate-server-timing-tests
-->
<head>
<meta charset='utf-8' />
<script src="/resources/testharness.js"></script>
<script src='/resources/testharnessreport.js'></script>
<script src="/common/performance-timeline-utils.js"></script>
<script>
setup({explicit_done: true})
const tests = []
const urlToIndex = {}
function testServerTiming(script, expectedResults) {
const url = script.src
tests[urlToIndex[url]] = {url, expectedResults}
}
function runTests() {
tests.forEach(function({url, expectedResults}) {
const {serverTiming} = performance.getEntriesByName(url)[0]
const fileName = url.substring(url.lastIndexOf('/') + 1)
test_equals(serverTiming.length, expectedResults.length, `${fileName} - count (${serverTiming.length} ?== ${expectedResults.length})`)
expectedResults.forEach(function(expectedResult, i) {
const dur = expectedResult.dur || 0
const desc = expectedResult.desc || ''
const index = expectedResults.length === 1 ? '' : `[${i}].`
test_equals(expectedResult.name, serverTiming[i].name,
`${fileName} - ${index}name (${expectedResult.name} ?== ${serverTiming[i].name})`)
test_equals(dur, serverTiming[i].duration,
`${fileName} - ${index}duration (${dur} ?== ${serverTiming[i].duration})`)
test_equals(desc, serverTiming[i].description,
`${fileName} - ${index}description (${desc} ?== ${serverTiming[i].description})`)
})
})
done()
}
for (let i = 0; i <= 83; i++) {
const script = document.createElement('script')
script.src = `./resources/parsing/${i}.js`
document.getElementsByTagName('head')[0].appendChild(script)
urlToIndex[script.src] = i
}
window.addEventListener('load', runTests)
</script>
</head>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<head>
<meta charset='utf-8' />
<script src="/resources/testharness.js"></script>
<script src='/resources/testharnessreport.js'></script>
<script>
(async () => {
const scope = 'does/not/exist'
let registration = await navigator.serviceWorker.getRegistration(scope)
if (registration)
await registration.unregister()
registration = await navigator.serviceWorker.register('./sw.js', {scope})
fetch_tests_from_worker(registration.installing)
})()
</script>
</head>

View file

@ -0,0 +1,19 @@
importScripts('/resources/testharness.js')
promise_test((test) => {
return fetch('./sw.js').then((response) => {
return new Promise((resolve, reject) => {
step_timeout(() => {
const entry = performance.getEntriesByName(response.url)[0]
if (!entry) {
reject('no entry: ' + response.url)
}
assert_not_equals(typeof entry.serverTiming,
'undefined',
'An instance of `PerformanceResourceTiming` should have a `serverTiming` attribute in the Service Worker context.')
resolve()
}, 250)
})
})
})

View file

@ -0,0 +1,45 @@
<!DOCTYPE html>
<head>
<meta charset='utf-8' />
<script src="/resources/testharness.js"></script>
<script src='/resources/testharnessreport.js'></script>
<script src="/common/performance-timeline-utils.js"></script>
<script>
setup({explicit_done: true})
window.addEventListener('load', function() {
// there should be exactly three server-timing entries, 2 for document, 1 for img#one
test_entries(performance.getEntriesByType('navigation')[0].serverTiming, [{
duration: 1.1,
name: 'metric1',
description: 'document',
}, {
duration: 1.2,
name: 'metric1',
description: 'document',
}])
test_entries(performance.getEntriesByName(document.querySelector('img#one').src)[0].serverTiming, [{
duration: 2.1,
name: 'metric2',
description: 'blue.png',
}])
new PerformanceObserver(function(entryList, observer) {
// there should be exactly one server-timing entry, 1 for img#two
test_entries(entryList.getEntriesByName(document.querySelector('img#two').src)[0].serverTiming, [{
duration: 3.1,
name: 'metric3',
description: 'green.png',
}])
observer.disconnect()
done()
}).observe({entryTypes: ['resource']})
var img = document.createElement('img')
img.id = 'two'
img.src = './resources/green.png'
document.getElementsByTagName('script')[0].parentNode.appendChild(img)
})
</script>
</head>
<img id='one' src='resources/blue.png'>

View file

@ -0,0 +1 @@
Server-Timing: metric1; dur=1.1; desc=document, metric1; dur=1.2; desc=document