| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Tests registering regions and receiving events.</title> | 2 <title>Tests registering regions and receiving events.</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/testharness-helpers.js"></script> | 5 <script src="../resources/testharness-helpers.js"></script> |
| 6 <script src="../serviceworker/resources/test-helpers.js"></script> | 6 <script src="../serviceworker/resources/test-helpers.js"></script> |
| 7 <script> | 7 <script> |
| 8 var sw_url = 'resources/worker-passes-events-back.js'; | 8 var sw_url = 'resources/worker-passes-events-back.js'; |
| 9 var sw_scope = 'resources/service-worker-scope' + window.location.pathname; | 9 var sw_scope = 'resources/service-worker-scope' + window.location.pathname; |
| 10 | 10 |
| 11 test(function(test) { | 11 test(function(test) { |
| 12 assert_exists(window, 'testRunner'); | 12 assert_true(window.testRunner instanceof Object); |
| 13 test.done(); | 13 test.done(); |
| 14 }, 'window.testRunner is required for the following tests.'); | 14 }, 'window.testRunner is required for the following tests.'); |
| 15 | 15 |
| 16 testRunner.setGeofencingMockProvider(true); | 16 testRunner.setGeofencingMockProvider(true); |
| 17 | 17 |
| 18 // Returns a promise that resolves to the first message received by |port|. | 18 // Returns a promise that resolves to the first message received by |port|. |
| 19 // Removes any message event handlers that might exist on the |port|. | 19 // Removes any message event handlers that might exist on the |port|. |
| 20 function wait_for_reply(t, port) { | 20 function wait_for_reply(t, port) { |
| 21 return new Promise(function(resolve) { | 21 return new Promise(function(resolve) { |
| 22 port.onmessage = t.step_func(function(event) { | 22 port.onmessage = t.step_func(function(event) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 })).then(test.step_func(function() { | 64 })).then(test.step_func(function() { |
| 65 return wait_for_reply(test, port); | 65 return wait_for_reply(test, port); |
| 66 })).then(test.step_func(function(reply) { | 66 })).then(test.step_func(function(reply) { |
| 67 assert_equals(reply.event, 'geofenceenter'); | 67 assert_equals(reply.event, 'geofenceenter'); |
| 68 assert_equals(reply.id, 'bigregion'); | 68 assert_equals(reply.id, 'bigregion'); |
| 69 return service_worker_unregister(test, sw_scope); | 69 return service_worker_unregister(test, sw_scope); |
| 70 })); | 70 })); |
| 71 }, 'Tests basic enter and leave events.'); | 71 }, 'Tests basic enter and leave events.'); |
| 72 | 72 |
| 73 </script> | 73 </script> |
| OLD | NEW |