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 other execution context, |
falken
2017/05/29 01:07:04
s/other/another
leonhsl(Using Gerrit)
2017/05/29 13:09:54
Acknowledged.
leonhsl(Using Gerrit)
2017/06/10 02:57:44
Done.
| |
487 // so do not use instanceof here. | |
488 return 'ServiceWorker' in self && | |
489 Object.prototype.toString.call(worker) == '[object ServiceWorker]'; | |
leonhsl(Using Gerrit)
2017/05/28 09:12:59
Another optional solution without changing testhar
Mike West
2017/05/29 08:02:44
I'm not sure we can do that via this update mechan
| |
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 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2785 done(); | 2788 done(); |
2786 }; | 2789 }; |
2787 | 2790 |
2788 addEventListener("error", error_handler, false); | 2791 addEventListener("error", error_handler, false); |
2789 addEventListener("unhandledrejection", function(e){ error_handler(e.reason); }, false); | 2792 addEventListener("unhandledrejection", function(e){ error_handler(e.reason); }, false); |
2790 | 2793 |
2791 test_environment.on_tests_ready(); | 2794 test_environment.on_tests_ready(); |
2792 | 2795 |
2793 })(); | 2796 })(); |
2794 // vim: set expandtab shiftwidth=4 tabstop=4: | 2797 // vim: set expandtab shiftwidth=4 tabstop=4: |
OLD | NEW |