OLD | NEW |
1 /*global self*/ | 1 /*global self*/ |
2 /*jshint latedef: nofunc*/ | 2 /*jshint latedef: nofunc*/ |
3 /* | 3 /* |
4 Distributed under both the W3C Test Suite License [1] and the W3C | 4 Distributed under both the W3C Test Suite License [1] and the W3C |
5 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the | 5 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the |
6 policies and contribution forms [3]. | 6 policies and contribution forms [3]. |
7 | 7 |
8 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license | 8 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license |
9 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license | 9 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license |
10 [3] http://www.w3.org/2004/10/27-testcases | 10 [3] http://www.w3.org/2004/10/27-testcases |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 name, | 651 name, |
652 Array.isArray(properties) ? properties[i] : properties)
; | 652 Array.isArray(properties) ? properties[i] : properties)
; |
653 }); | 653 }); |
654 } | 654 } |
655 | 655 |
656 function on_event(object, event, callback) | 656 function on_event(object, event, callback) |
657 { | 657 { |
658 object.addEventListener(event, callback, false); | 658 object.addEventListener(event, callback, false); |
659 } | 659 } |
660 | 660 |
| 661 function step_timeout(f, t) { |
| 662 var outer_this = this; |
| 663 var args = Array.prototype.slice.call(arguments, 2); |
| 664 return setTimeout(function() { |
| 665 f.apply(outer_this, args); |
| 666 }, t * tests.timeout_multiplier); |
| 667 } |
| 668 |
661 expose(test, 'test'); | 669 expose(test, 'test'); |
662 expose(async_test, 'async_test'); | 670 expose(async_test, 'async_test'); |
663 expose(promise_test, 'promise_test'); | 671 expose(promise_test, 'promise_test'); |
664 expose(promise_rejects, 'promise_rejects'); | 672 expose(promise_rejects, 'promise_rejects'); |
665 expose(generate_tests, 'generate_tests'); | 673 expose(generate_tests, 'generate_tests'); |
666 expose(setup, 'setup'); | 674 expose(setup, 'setup'); |
667 expose(done, 'done'); | 675 expose(done, 'done'); |
668 expose(on_event, 'on_event'); | 676 expose(on_event, 'on_event'); |
| 677 expose(step_timeout, 'step_timeout'); |
669 | 678 |
670 /* | 679 /* |
671 * Return a string truncated to the given length, with ... added at the end | 680 * Return a string truncated to the given length, with ... added at the end |
672 * if it was longer. | 681 * if it was longer. |
673 */ | 682 */ |
674 function truncate(s, len) | 683 function truncate(s, len) |
675 { | 684 { |
676 if (s.length > len) { | 685 if (s.length > len) { |
677 return s.substring(0, len - 3) + "..."; | 686 return s.substring(0, len - 3) + "..."; |
678 } | 687 } |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 { | 1099 { |
1091 assert(!object.hasOwnProperty(property_name), | 1100 assert(!object.hasOwnProperty(property_name), |
1092 "assert_not_exists", description, | 1101 "assert_not_exists", description, |
1093 "unexpected property ${p} found", {p:property_name}); | 1102 "unexpected property ${p} found", {p:property_name}); |
1094 } | 1103 } |
1095 expose(assert_not_exists, "assert_not_exists"); | 1104 expose(assert_not_exists, "assert_not_exists"); |
1096 | 1105 |
1097 function _assert_inherits(name) { | 1106 function _assert_inherits(name) { |
1098 return function (object, property_name, description) | 1107 return function (object, property_name, description) |
1099 { | 1108 { |
1100 assert(typeof object === "object", | 1109 assert(typeof object === "object" || typeof object === "function", |
1101 name, description, | 1110 name, description, |
1102 "provided value is not an object"); | 1111 "provided value is not an object"); |
1103 | 1112 |
1104 assert("hasOwnProperty" in object, | 1113 assert("hasOwnProperty" in object, |
1105 name, description, | 1114 name, description, |
1106 "provided value is an object but has no hasOwnProperty method
"); | 1115 "provided value is an object but has no hasOwnProperty method
"); |
1107 | 1116 |
1108 assert(!object.hasOwnProperty(property_name), | 1117 assert(!object.hasOwnProperty(property_name), |
1109 name, description, | 1118 name, description, |
1110 "property ${p} found on object expected in prototype chain", | 1119 "property ${p} found on object expected in prototype chain", |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 } | 1169 } |
1161 | 1170 |
1162 var code_name_map = { | 1171 var code_name_map = { |
1163 INDEX_SIZE_ERR: 'IndexSizeError', | 1172 INDEX_SIZE_ERR: 'IndexSizeError', |
1164 HIERARCHY_REQUEST_ERR: 'HierarchyRequestError', | 1173 HIERARCHY_REQUEST_ERR: 'HierarchyRequestError', |
1165 WRONG_DOCUMENT_ERR: 'WrongDocumentError', | 1174 WRONG_DOCUMENT_ERR: 'WrongDocumentError', |
1166 INVALID_CHARACTER_ERR: 'InvalidCharacterError', | 1175 INVALID_CHARACTER_ERR: 'InvalidCharacterError', |
1167 NO_MODIFICATION_ALLOWED_ERR: 'NoModificationAllowedError', | 1176 NO_MODIFICATION_ALLOWED_ERR: 'NoModificationAllowedError', |
1168 NOT_FOUND_ERR: 'NotFoundError', | 1177 NOT_FOUND_ERR: 'NotFoundError', |
1169 NOT_SUPPORTED_ERR: 'NotSupportedError', | 1178 NOT_SUPPORTED_ERR: 'NotSupportedError', |
| 1179 INUSE_ATTRIBUTE_ERR: 'InUseAttributeError', |
1170 INVALID_STATE_ERR: 'InvalidStateError', | 1180 INVALID_STATE_ERR: 'InvalidStateError', |
1171 SYNTAX_ERR: 'SyntaxError', | 1181 SYNTAX_ERR: 'SyntaxError', |
1172 INVALID_MODIFICATION_ERR: 'InvalidModificationError', | 1182 INVALID_MODIFICATION_ERR: 'InvalidModificationError', |
1173 NAMESPACE_ERR: 'NamespaceError', | 1183 NAMESPACE_ERR: 'NamespaceError', |
1174 INVALID_ACCESS_ERR: 'InvalidAccessError', | 1184 INVALID_ACCESS_ERR: 'InvalidAccessError', |
1175 TYPE_MISMATCH_ERR: 'TypeMismatchError', | 1185 TYPE_MISMATCH_ERR: 'TypeMismatchError', |
1176 SECURITY_ERR: 'SecurityError', | 1186 SECURITY_ERR: 'SecurityError', |
1177 NETWORK_ERR: 'NetworkError', | 1187 NETWORK_ERR: 'NetworkError', |
1178 ABORT_ERR: 'AbortError', | 1188 ABORT_ERR: 'AbortError', |
1179 URL_MISMATCH_ERR: 'URLMismatchError', | 1189 URL_MISMATCH_ERR: 'URLMismatchError', |
1180 QUOTA_EXCEEDED_ERR: 'QuotaExceededError', | 1190 QUOTA_EXCEEDED_ERR: 'QuotaExceededError', |
1181 TIMEOUT_ERR: 'TimeoutError', | 1191 TIMEOUT_ERR: 'TimeoutError', |
1182 INVALID_NODE_TYPE_ERR: 'InvalidNodeTypeError', | 1192 INVALID_NODE_TYPE_ERR: 'InvalidNodeTypeError', |
1183 DATA_CLONE_ERR: 'DataCloneError' | 1193 DATA_CLONE_ERR: 'DataCloneError' |
1184 }; | 1194 }; |
1185 | 1195 |
1186 var name = code in code_name_map ? code_name_map[code] : code; | 1196 var name = code in code_name_map ? code_name_map[code] : code; |
1187 | 1197 |
1188 var name_code_map = { | 1198 var name_code_map = { |
1189 IndexSizeError: 1, | 1199 IndexSizeError: 1, |
1190 HierarchyRequestError: 3, | 1200 HierarchyRequestError: 3, |
1191 WrongDocumentError: 4, | 1201 WrongDocumentError: 4, |
1192 InvalidCharacterError: 5, | 1202 InvalidCharacterError: 5, |
1193 NoModificationAllowedError: 7, | 1203 NoModificationAllowedError: 7, |
1194 NotFoundError: 8, | 1204 NotFoundError: 8, |
1195 NotSupportedError: 9, | 1205 NotSupportedError: 9, |
| 1206 InUseAttributeError: 10, |
1196 InvalidStateError: 11, | 1207 InvalidStateError: 11, |
1197 SyntaxError: 12, | 1208 SyntaxError: 12, |
1198 InvalidModificationError: 13, | 1209 InvalidModificationError: 13, |
1199 NamespaceError: 14, | 1210 NamespaceError: 14, |
1200 InvalidAccessError: 15, | 1211 InvalidAccessError: 15, |
1201 TypeMismatchError: 17, | 1212 TypeMismatchError: 17, |
1202 SecurityError: 18, | 1213 SecurityError: 18, |
1203 NetworkError: 19, | 1214 NetworkError: 19, |
1204 AbortError: 20, | 1215 AbortError: 20, |
1205 URLMismatchError: 21, | 1216 URLMismatchError: 21, |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 }; | 1426 }; |
1416 }; | 1427 }; |
1417 | 1428 |
1418 Test.prototype.unreached_func = function(description) | 1429 Test.prototype.unreached_func = function(description) |
1419 { | 1430 { |
1420 return this.step_func(function() { | 1431 return this.step_func(function() { |
1421 assert_unreached(description); | 1432 assert_unreached(description); |
1422 }); | 1433 }); |
1423 }; | 1434 }; |
1424 | 1435 |
| 1436 Test.prototype.step_timeout = function(f, timeout) { |
| 1437 var test_this = this; |
| 1438 var args = Array.prototype.slice.call(arguments, 2); |
| 1439 return setTimeout(this.step_func(function() { |
| 1440 return f.apply(test_this, args); |
| 1441 }, timeout * tests.timeout_multiplier)); |
| 1442 } |
| 1443 |
1425 Test.prototype.add_cleanup = function(callback) { | 1444 Test.prototype.add_cleanup = function(callback) { |
1426 this.cleanup_callbacks.push(callback); | 1445 this.cleanup_callbacks.push(callback); |
1427 }; | 1446 }; |
1428 | 1447 |
1429 Test.prototype.force_timeout = function() { | 1448 Test.prototype.force_timeout = function() { |
1430 this.set_status(this.TIMEOUT); | 1449 this.set_status(this.TIMEOUT); |
1431 this.phase = this.phases.HAS_RESULT; | 1450 this.phase = this.phases.HAS_RESULT; |
1432 }; | 1451 }; |
1433 | 1452 |
1434 Test.prototype.set_timeout = function() | 1453 Test.prototype.set_timeout = function() |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2631 tests.status.status = tests.status.ERROR; | 2650 tests.status.status = tests.status.ERROR; |
2632 tests.status.message = e.message; | 2651 tests.status.message = e.message; |
2633 tests.status.stack = e.stack; | 2652 tests.status.stack = e.stack; |
2634 } | 2653 } |
2635 }); | 2654 }); |
2636 | 2655 |
2637 test_environment.on_tests_ready(); | 2656 test_environment.on_tests_ready(); |
2638 | 2657 |
2639 })(); | 2658 })(); |
2640 // vim: set expandtab shiftwidth=4 tabstop=4: | 2659 // vim: set expandtab shiftwidth=4 tabstop=4: |
OLD | NEW |