OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 if (self.importScripts) { | 3 if (self.importScripts) { |
4 if ('ServiceWorkerGlobalScope' in self && self instanceof ServiceWorkerGlobalS
cope) { | 4 if ('ServiceWorkerGlobalScope' in self && self instanceof ServiceWorkerGlobalS
cope) { |
5 importScripts('../../serviceworker/resources/worker-testharness.js'); | 5 importScripts('../../serviceworker/resources/worker-testharness.js'); |
6 } else { | 6 } else { |
7 importScripts('../../resources/testharness.js'); | 7 importScripts('../../resources/testharness.js'); |
8 } | 8 } |
9 } | 9 } |
10 | 10 |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 unhandledReasons.push(ev.reason); | 483 unhandledReasons.push(ev.reason); |
484 }); | 484 }); |
485 } | 485 } |
486 }; | 486 }; |
487 var handled = function(ev) { | 487 var handled = function(ev) { |
488 if (ev.promise === p) { | 488 if (ev.promise === p) { |
489 t.step(function() { | 489 t.step(function() { |
490 assert_array_equals(unhandledPromises, [p]); | 490 assert_array_equals(unhandledPromises, [p]); |
491 assert_array_equals(unhandledReasons, [e]); | 491 assert_array_equals(unhandledReasons, [e]); |
492 assert_equals(ev.promise, p); | 492 assert_equals(ev.promise, p); |
493 assert_equals(ev.reason, e); | 493 assert_equals(ev.reason, undefined); |
494 }); | 494 }); |
495 } | 495 } |
496 }; | 496 }; |
497 addEventListener('unhandledrejection', unhandled); | 497 addEventListener('unhandledrejection', unhandled); |
498 addEventListener('rejectionhandled', handled); | 498 addEventListener('rejectionhandled', handled); |
499 ensureCleanup(t, unhandled, handled); | 499 ensureCleanup(t, unhandled, handled); |
500 | 500 |
501 p = new Promise(function() { | 501 p = new Promise(function() { |
502 throw e; | 502 throw e; |
503 }); | 503 }); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 function ensureCleanup(t, unhandled, handled) { | 659 function ensureCleanup(t, unhandled, handled) { |
660 t.add_cleanup(function() { | 660 t.add_cleanup(function() { |
661 if (unhandled) | 661 if (unhandled) |
662 removeEventListener('unhandledrejection', unhandled); | 662 removeEventListener('unhandledrejection', unhandled); |
663 if (handled) | 663 if (handled) |
664 removeEventListener('rejectionhandled', handled); | 664 removeEventListener('rejectionhandled', handled); |
665 }); | 665 }); |
666 } | 666 } |
667 | 667 |
668 done(); | 668 done(); |
OLD | NEW |