Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: LayoutTests/http/tests/geofencing/event_triggering.html

Issue 702983002: Update geofencing layout tests to use mock service. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix after rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Tests registering regions and receiving events.</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="../resources/testharness-helpers.js"></script>
6 <script src="../serviceworker/resources/test-helpers.js"></script>
7 <script>
8 var sw_url = 'resources/worker-passes-events-back.js';
9 var sw_scope = 'resources/service-worker-scope' + window.location.pathname;
10
11 test(function(test) {
12 assert_exists(window, 'testRunner');
13 test.done();
14 }, 'window.testRunner is required for the following tests.');
15
16 testRunner.setGeofencingMockProvider(true);
17
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|.
20 function wait_for_reply(t, port) {
21 return new Promise(function(resolve) {
22 port.onmessage = t.step_func(function(event) {
23 port.onmessage = null;
24 resolve(event.data);
25 });
26 });
27 }
28
29 promise_test(function(test) {
30 var registration;
31 var port;
32 return service_worker_unregister_and_register(test, sw_url, sw_scope)
33 .then(test.step_func(function(r) {
34 registration = r;
35 return wait_for_state(test, r.installing, 'activated');
36 })).then(test.step_func(function() {
37 var channel = new MessageChannel();
38 port = channel.port1;
39 registration.active.postMessage({port: channel.port2}, [channel.port2] );
40 return wait_for_reply(test, port);
41 })).then(test.step_func(function(reply) {
42 assert_equals(reply, 'setup');
43 return registration.geofencing.registerRegion(
44 new CircularGeofencingRegion({id: 'myid',
45 latitude: 37.421999,
46 longitude: -122.084015,
47 radius: 10}));
48 })).then(test.step_func(function() {
49 testRunner.setGeofencingMockPosition(37.422, -122.084015);
50 return wait_for_reply(test, port);
51 })).then(test.step_func(function(reply) {
52 assert_equals(reply.event, 'geofenceenter');
53 assert_equals(reply.id, 'myid');
54 testRunner.setGeofencingMockPosition(37.423, -122.084015);
55 return wait_for_reply(test, port);
56 })).then(test.step_func(function(reply) {
57 assert_equals(reply.event, 'geofenceleave');
58 assert_equals(reply.id, 'myid');
59 return registration.geofencing.registerRegion(
60 new CircularGeofencingRegion({id: 'bigregion',
61 latitude: 37.421999,
62 longitude: -122.084015,
63 radius: 200}));
64 })).then(test.step_func(function() {
65 return wait_for_reply(test, port);
66 })).then(test.step_func(function(reply) {
67 assert_equals(reply.event, 'geofenceenter');
68 assert_equals(reply.id, 'bigregion');
69 return service_worker_unregister(test, sw_scope);
70 }));
71 }, 'Tests basic enter and leave events.');
72
73 </script>
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/geofencing/apis_not_implemented.html ('k') | LayoutTests/http/tests/geofencing/resources/worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698