| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>ExtendableEvent: waitUntil</title> | 2 <title>ExtendableEvent: waitUntil</title> |
| 3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="resources/test-helpers.js"></script> | 5 <script src="resources/test-helpers.js"></script> |
| 6 <script> | 6 <script> |
| 7 // Temporary measure to diagnose timeouts on Win XP. Let the W3C harness | 7 // Temporary measure to diagnose timeouts on Win XP. Let the W3C harness |
| 8 // timeout before run-webkit-tests does, so it can report the particular | 8 // timeout before run-webkit-tests does, so it can report the particular |
| 9 // test that timed out. | 9 // test that timed out. |
| 10 // FIXME: Remove after the cause of timeout is fixed. | 10 // FIXME: Remove after the cause of timeout is fixed. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 assert_equals(message, 'SYNC', | 26 assert_equals(message, 'SYNC', |
| 27 'Should receive sync message from worker.'); | 27 'Should receive sync message from worker.'); |
| 28 obj.synced = true; | 28 obj.synced = true; |
| 29 channel.port1.postMessage('ACK'); | 29 channel.port1.postMessage('ACK'); |
| 30 }); | 30 }); |
| 31 worker.postMessage({port: channel.port2}, [channel.port2]); | 31 worker.postMessage({port: channel.port2}, [channel.port2]); |
| 32 } | 32 } |
| 33 | 33 |
| 34 async_test(function(t) { | 34 async_test(function(t) { |
| 35 // Passing scope as the test switch for worker script. | 35 // Passing scope as the test switch for worker script. |
| 36 var scope = 'install-fulfilled'; | 36 var scope = 'resources/install-fulfilled'; |
| 37 var onRegister = function(worker) { | 37 var onRegister = function(worker) { |
| 38 var obj = {}; | 38 var obj = {}; |
| 39 wait_for_state(t, worker, 'installed') | 39 wait_for_state(t, worker, 'installed') |
| 40 .then(function() { | 40 .then(function() { |
| 41 assert_true( | 41 assert_true( |
| 42 obj.synced, | 42 obj.synced, |
| 43 'state should be "installed" after the waitUntil promise ' + | 43 'state should be "installed" after the waitUntil promise ' + |
| 44 'for "oninstall" is fulfilled.'); | 44 'for "oninstall" is fulfilled.'); |
| 45 service_worker_unregister_and_done(t, scope); | 45 service_worker_unregister_and_done(t, scope); |
| 46 }) | 46 }) |
| 47 .catch(unreached_rejection(t)); | 47 .catch(unreached_rejection(t)); |
| 48 syncWorker(t, worker, obj); | 48 syncWorker(t, worker, obj); |
| 49 }; | 49 }; |
| 50 runTest(t, scope, onRegister); | 50 runTest(t, scope, onRegister); |
| 51 }, 'Test install event waitUntil fulfilled', properties); | 51 }, 'Test install event waitUntil fulfilled', properties); |
| 52 | 52 |
| 53 async_test(function(t) { | 53 async_test(function(t) { |
| 54 var scope = 'activate-fulfilled'; | 54 var scope = 'resources/activate-fulfilled'; |
| 55 var onRegister = function(worker) { | 55 var onRegister = function(worker) { |
| 56 var obj = {}; | 56 var obj = {}; |
| 57 wait_for_state(t, worker, 'activating') | 57 wait_for_state(t, worker, 'activating') |
| 58 .then(function() { | 58 .then(function() { |
| 59 syncWorker(t, worker, obj); | 59 syncWorker(t, worker, obj); |
| 60 return wait_for_state(t, worker, 'activated'); | 60 return wait_for_state(t, worker, 'activated'); |
| 61 }) | 61 }) |
| 62 .then(function() { | 62 .then(function() { |
| 63 assert_true( | 63 assert_true( |
| 64 obj.synced, | 64 obj.synced, |
| 65 'state should be "activated" after the waitUntil promise ' + | 65 'state should be "activated" after the waitUntil promise ' + |
| 66 'for "onactivate" is fulfilled.'); | 66 'for "onactivate" is fulfilled.'); |
| 67 service_worker_unregister_and_done(t, scope); | 67 service_worker_unregister_and_done(t, scope); |
| 68 }) | 68 }) |
| 69 .catch(unreached_rejection(t)); | 69 .catch(unreached_rejection(t)); |
| 70 }; | 70 }; |
| 71 runTest(t, scope, onRegister); | 71 runTest(t, scope, onRegister); |
| 72 }, 'Test activate event waitUntil fulfilled', properties); | 72 }, 'Test activate event waitUntil fulfilled', properties); |
| 73 | 73 |
| 74 async_test(function(t) { | 74 async_test(function(t) { |
| 75 var scope = 'install-rejected'; | 75 var scope = 'resources/install-rejected'; |
| 76 var onRegister = function(worker) { | 76 var onRegister = function(worker) { |
| 77 wait_for_state(t, worker, 'redundant') | 77 wait_for_state(t, worker, 'redundant') |
| 78 .then(function() { | 78 .then(function() { |
| 79 service_worker_unregister_and_done(t, scope); | 79 service_worker_unregister_and_done(t, scope); |
| 80 }) | 80 }) |
| 81 .catch(unreached_rejection(t)); | 81 .catch(unreached_rejection(t)); |
| 82 }; | 82 }; |
| 83 runTest(t, scope, onRegister); | 83 runTest(t, scope, onRegister); |
| 84 }, 'Test install event waitUntil rejected', properties); | 84 }, 'Test install event waitUntil rejected', properties); |
| 85 | 85 |
| 86 async_test(function(t) { | 86 async_test(function(t) { |
| 87 var scope = 'activate-rejected'; | 87 var scope = 'resources/activate-rejected'; |
| 88 var onRegister = function(worker) { | 88 var onRegister = function(worker) { |
| 89 wait_for_state(t, worker, 'redundant') | 89 wait_for_state(t, worker, 'redundant') |
| 90 .then(function() { | 90 .then(function() { |
| 91 service_worker_unregister_and_done(t, scope); | 91 service_worker_unregister_and_done(t, scope); |
| 92 }) | 92 }) |
| 93 .catch(unreached_rejection(t)); | 93 .catch(unreached_rejection(t)); |
| 94 }; | 94 }; |
| 95 runTest(t, scope, onRegister); | 95 runTest(t, scope, onRegister); |
| 96 }, 'Test activate event waitUntil rejected.', properties); | 96 }, 'Test activate event waitUntil rejected.', properties); |
| 97 | 97 |
| 98 async_test(function(t) { | 98 async_test(function(t) { |
| 99 var scope = 'activate-multiple-fulfilled'; | 99 var scope = 'resources/activate-multiple-fulfilled'; |
| 100 var onRegister = function(worker) { | 100 var onRegister = function(worker) { |
| 101 var obj1 = {}; | 101 var obj1 = {}; |
| 102 var obj2 = {}; | 102 var obj2 = {}; |
| 103 wait_for_state(t, worker, 'activating') | 103 wait_for_state(t, worker, 'activating') |
| 104 .then(function() { | 104 .then(function() { |
| 105 syncWorker(t, worker, obj1); | 105 syncWorker(t, worker, obj1); |
| 106 syncWorker(t, worker, obj2); | 106 syncWorker(t, worker, obj2); |
| 107 return wait_for_state(t, worker, 'activated'); | 107 return wait_for_state(t, worker, 'activated'); |
| 108 }) | 108 }) |
| 109 .then(function() { | 109 .then(function() { |
| 110 assert_true( | 110 assert_true( |
| 111 obj1.synced && obj2.synced, | 111 obj1.synced && obj2.synced, |
| 112 'state should be "activated" after all waitUntil promises ' + | 112 'state should be "activated" after all waitUntil promises ' + |
| 113 'for "onactivate" are fulfilled.'); | 113 'for "onactivate" are fulfilled.'); |
| 114 service_worker_unregister_and_done(t, scope); | 114 service_worker_unregister_and_done(t, scope); |
| 115 }) | 115 }) |
| 116 .catch(unreached_rejection(t)); | 116 .catch(unreached_rejection(t)); |
| 117 }; | 117 }; |
| 118 runTest(t, scope, onRegister); | 118 runTest(t, scope, onRegister); |
| 119 }, 'Test ExtendableEvent multiple waitUntil fulfilled.', properties); | 119 }, 'Test ExtendableEvent multiple waitUntil fulfilled.', properties); |
| 120 | 120 |
| 121 async_test(function(t) { | 121 async_test(function(t) { |
| 122 var scope = 'activate-reject-precedence'; | 122 var scope = 'resources/activate-reject-precedence'; |
| 123 var onRegister = function(worker) { | 123 var onRegister = function(worker) { |
| 124 wait_for_state(t, worker, 'redundant') | 124 wait_for_state(t, worker, 'redundant') |
| 125 .then(function() { | 125 .then(function() { |
| 126 service_worker_unregister_and_done(t, scope); | 126 service_worker_unregister_and_done(t, scope); |
| 127 }) | 127 }) |
| 128 .catch(unreached_rejection(t)); | 128 .catch(unreached_rejection(t)); |
| 129 }; | 129 }; |
| 130 runTest(t, scope, onRegister); | 130 runTest(t, scope, onRegister); |
| 131 }, 'Test ExtendableEvent waitUntil reject precedence.', properties); | 131 }, 'Test ExtendableEvent waitUntil reject precedence.', properties); |
| 132 </script> | 132 </script> |
| OLD | NEW |