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

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: better test 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
scheib 2014/12/08 16:40:13 Maybe include a first test before anything that us
Marijn Kruisselbrink 2014/12/11 04:43:37 Done.
11 testRunner.setGeofencingMockProvider(true);
12
13 // Returns a promise that resolves to the first message received by |port|.
14 // Removes any message event handlers that might exist on the |port|.
15 function wait_for_reply(t, port) {
16 return new Promise(function(resolve) {
17 port.onmessage = t.step_func(function(event) {
18 port.onmessage = null;
19 resolve(event.data);
20 });
21 });
22 }
23
24 promise_test(function(test) {
25 var registration;
26 var port;
27 return service_worker_unregister_and_register(test, sw_url, sw_scope)
28 .then(test.step_func(function(r) {
29 registration = r;
30 return wait_for_activated(test, registration);
31 })).then(test.step_func(function() {
32 var channel = new MessageChannel();
33 port = channel.port1;
34 registration.active.postMessage({port: channel.port2}, [channel.port2] );
35 return wait_for_reply(test, port);
36 })).then(test.step_func(function(reply) {
37 assert_equals(reply, 'setup');
38 return registration.geofencing.registerRegion(
39 new CircularGeofencingRegion({id: 'myid',
40 latitude: 37.421999,
41 longitude: -122.084015,
42 radius: 10}));
43 })).then(test.step_func(function() {
44 testRunner.setGeofencingMockPosition(37.422, -122.084015);
scheib 2014/12/08 16:40:13 What is the initial position of the Mock? Should t
Marijn Kruisselbrink 2014/12/11 04:43:37 The initial position is "no position", which isn't
45 return wait_for_reply(test, port);
46 })).then(test.step_func(function(reply) {
47 assert_equals(reply.event, 'geofenceenter');
48 assert_equals(reply.id, 'myid');
49 testRunner.setGeofencingMockPosition(37.423, -122.084015);
50 return wait_for_reply(test, port);
51 })).then(test.step_func(function(reply) {
52 assert_equals(reply.event, 'geofenceleave');
53 assert_equals(reply.id, 'myid');
54 return registration.geofencing.registerRegion(
55 new CircularGeofencingRegion({id: 'bigregion',
56 latitude: 37.421999,
57 longitude: -122.084015,
58 radius: 200}));
59 })).then(test.step_func(function() {
60 return wait_for_reply(test, port);
61 })).then(test.step_func(function(reply) {
62 assert_equals(reply.event, 'geofenceenter');
63 assert_equals(reply.id, 'bigregion');
64 return service_worker_unregister(test, sw_scope);
65 }));
66 }, 'Tests basic enter and leave events.');
67
68 </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