Bug 1477146 [wpt PR 12081] - Fixing Server-Timing header parsing tests, a=testonly

Automatic update from web-platform-testsFixing Server-Timing header parsing tests

The Server-Timing response header is allowed to have a comma-separated
list of timing metrics. We have test code that checks that the right
number of components get parsed. When there are more components than
expected, though, the test code ends up trying to lookup a field from an
undefined value. This caused the test runner to bail out and skip
subsequent tests.

This patch changes the test code to check for an undefined value and
skip ahead as needed.

Change-Id: I2304424978e3d4634c3508b1fefbba809374950e
Reviewed-on: https://chromium-review.googlesource.com/1144200
Reviewed-by: Yoav Weiss <yoav@yoav.ws>
Commit-Queue: Tom McKee <tommckee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576911}

--

wpt-commits: 36dd72261c766fe6e32d2db9b2b53d37918a945c
wpt-pr: 12081
This commit is contained in:
Tom McKee 2018-07-25 18:32:40 +00:00 committed by James Graham
parent d8bc5ca11d
commit 64494e3bd3
3 changed files with 24 additions and 14 deletions

View File

@ -613606,11 +613606,11 @@
"support"
],
"server-timing/server_timing_header-parsing.html": [
"10f756bbf749b7ad8f7c6eb4efe752ee79c44b4a",
"7ec595af5a8c240c0fe0a4b10469fd11e2f56cbf",
"testharness"
],
"server-timing/server_timing_header-parsing.https.html": [
"10f756bbf749b7ad8f7c6eb4efe752ee79c44b4a",
"7ec595af5a8c240c0fe0a4b10469fd11e2f56cbf",
"testharness"
],
"server-timing/service_worker_idl.https.html": [

View File

@ -28,12 +28,17 @@ tests generated by:
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})`)
const actual = serverTiming[i]
if (actual === undefined) {
// Protect against more expected results than actual results.
return
}
test_equals(expectedResult.name, actual.name,
`${fileName} - ${index}name (${expectedResult.name} ?== ${actual.name})`)
test_equals(dur, actual.duration,
`${fileName} - ${index}duration (${dur} ?== ${actual.duration})`)
test_equals(desc, actual.description,
`${fileName} - ${index}description (${desc} ?== ${actual.description})`)
})
})
done()

View File

@ -28,12 +28,17 @@ tests generated by:
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})`)
const actual = serverTiming[i]
if (actual === undefined) {
// Protect against more expected results than actual results.
return
}
test_equals(expectedResult.name, actual.name,
`${fileName} - ${index}name (${expectedResult.name} ?== ${actual.name})`)
test_equals(dur, actual.duration,
`${fileName} - ${index}duration (${dur} ?== ${actual.duration})`)
test_equals(desc, actual.description,
`${fileName} - ${index}description (${desc} ?== ${actual.description})`)
})
})
done()