OLD | NEW |
(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 */ |
| 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 } |
OLD | NEW |