| 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 throw new Error("Unsupported test environment"); | 476 throw new Error("Unsupported test environment"); |
| 477 } | 477 } |
| 478 | 478 |
| 479 var test_environment = create_test_environment(); | 479 var test_environment = create_test_environment(); |
| 480 | 480 |
| 481 function is_shared_worker(worker) { | 481 function is_shared_worker(worker) { |
| 482 return 'SharedWorker' in self && worker instanceof SharedWorker; | 482 return 'SharedWorker' in self && worker instanceof SharedWorker; |
| 483 } | 483 } |
| 484 | 484 |
| 485 function is_service_worker(worker) { | 485 function is_service_worker(worker) { |
| 486 return 'ServiceWorker' in self && worker instanceof ServiceWorker; | 486 // The worker object may be from another execution context, |
| 487 // so do not use instanceof here. |
| 488 return 'ServiceWorker' in self && |
| 489 Object.prototype.toString.call(worker) == '[object ServiceWorker]'; |
| 487 } | 490 } |
| 488 | 491 |
| 489 /* | 492 /* |
| 490 * API functions | 493 * API functions |
| 491 */ | 494 */ |
| 492 | 495 |
| 493 function test(func, name, properties) | 496 function test(func, name, properties) |
| 494 { | 497 { |
| 495 var test_name = name ? name : test_environment.next_default_test_name(); | 498 var test_name = name ? name : test_environment.next_default_test_name(); |
| 496 properties = properties ? properties : {}; | 499 properties = properties ? properties : {}; |
| (...skipping 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2789 done(); | 2792 done(); |
| 2790 }; | 2793 }; |
| 2791 | 2794 |
| 2792 addEventListener("error", error_handler, false); | 2795 addEventListener("error", error_handler, false); |
| 2793 addEventListener("unhandledrejection", function(e){ error_handler(e.reason);
}, false); | 2796 addEventListener("unhandledrejection", function(e){ error_handler(e.reason);
}, false); |
| 2794 | 2797 |
| 2795 test_environment.on_tests_ready(); | 2798 test_environment.on_tests_ready(); |
| 2796 | 2799 |
| 2797 })(); | 2800 })(); |
| 2798 // vim: set expandtab shiftwidth=4 tabstop=4: | 2801 // vim: set expandtab shiftwidth=4 tabstop=4: |
| OLD | NEW |