Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(993)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/server-timing/resources/webperftestharness.js

Issue 2799093004: Enable ServerTiming support
Patch Set: update code formatting and comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 Distributed under both the W3C Test Suite License [1] and the W3C
3 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
4 policies and contribution forms [3].
5
6 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
7 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
8 [3] http://www.w3.org/2004/10/27-testcases
9 */
panicker 2017/04/06 22:48:19 Could you provide some context on this test helper
cvazac 2017/04/06 23:50:00 Yes, I added the 4th copy of `wp_test()` :), here
panicker 2017/04/07 23:01:32 Please let's not add the 4th copy :) You could eit
10
11 var namespace_check = false
12 function wp_test(func, msg, properties) {
13 if (!namespace_check) {
14 namespace_check = true
15 var performanceNamespace = window.performance
16 if (performanceNamespace === undefined || performanceNamespace == null) {
17 // show a single error that window.performance is undefined
18 test(function () {
19 assert_true(performanceNamespace !== undefined && performanceNamespace ! = null, "window.performance is defined and not null")
20 }, "window.performance is defined and not null.", {
21 author: "W3C http://www.w3.org/",
22 help: "http://www.w3.org/TR/navigation-timing/#sec-window.performance-at tribute",
23 assert: "The window.performance attribute provides a hosting area for pe rformance related attributes. "
24 })
25 }
26 }
27
28 test(func, msg, properties)
29 }
30
31 function test_true(value, msg, properties) {
32 wp_test(function () {
33 assert_true(value, msg)
34 }, msg, properties)
35 }
36
37 function test_equals(value, equals, msg, properties) {
38 wp_test(function () {
39 assert_equals(value, equals, msg)
40 }, msg, properties)
41 }
42
43 // assert for every entry in `expectedEntries`, there is a matching entry _somew here_ in `actualEntries`
44 function test_entries(actualEntries, expectedEntries) {
45 test_equals(actualEntries.length, expectedEntries.length)
46 expectedEntries.forEach(function (expectedEntry) {
47 test_true(!!actualEntries.find(function (actualEntry) {
48 return typeof Object.keys(expectedEntry).find(function (key) {
49 return actualEntry[key] !== expectedEntry[key]
50 }) === 'undefined'
51 }))
52 })
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698