OLD | NEW |
(Empty) | |
| 1 var performanceNamespace = window.performance; |
| 2 var namespace_check = false; |
| 3 function wp_test(func, msg, properties) |
| 4 { |
| 5 // only run the namespace check once |
| 6 if (!namespace_check) |
| 7 { |
| 8 namespace_check = true; |
| 9 |
| 10 if (performanceNamespace === undefined || performanceNamespace == null) |
| 11 { |
| 12 // show a single error that window.performance is undefined |
| 13 test(function() { assert_true(performanceNamespace !== undefined && perfor
manceNamespace != null, "window.performance is defined and not null"); }, "windo
w.performance is defined and not null.", {author:"W3C http://www.w3.org/",help:"
http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert
:"The window.performance attribute provides a hosting area for performance relat
ed attributes. "}); |
| 14 } |
| 15 } |
| 16 |
| 17 test(func, msg, properties); |
| 18 } |
| 19 |
| 20 function test_true(value, msg, properties) |
| 21 { |
| 22 wp_test(function () { assert_true(value, msg); }, msg, properties); |
| 23 } |
| 24 |
| 25 function test_equals(value, equals, msg, properties) |
| 26 { |
| 27 wp_test(function () { assert_equals(value, equals, msg); }, msg, properties); |
| 28 } |
| 29 |
| 30 // assert for every entry in `expectedEntries`, there is a matching entry _somew
here_ in `actualEntries` |
| 31 function test_entries(actualEntries, expectedEntries) { |
| 32 test_equals(actualEntries.length, expectedEntries.length) |
| 33 expectedEntries.forEach(function (expectedEntry) { |
| 34 test_true(!!actualEntries.find(function (actualEntry) { |
| 35 return typeof Object.keys(expectedEntry).find(function (key) { |
| 36 return actualEntry[key] !== expectedEntry[key] |
| 37 }) === 'undefined' |
| 38 })) |
| 39 }) |
| 40 } |
OLD | NEW |