OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>Basic test for some stuff</title> | |
jsbell
2014/10/08 18:51:57
Real title
Marijn Kruisselbrink
2014/10/08 23:00:31
Done.
| |
3 <script src="../resources/testharness.js"></script> | |
4 <script src="../resources/testharnessreport.js"></script> | |
5 <script src="../serviceworker/resources/test-helpers.js"></script> | |
6 <script> | |
7 // Copied from http/tests/serviceworker/resources/worker-test-harness.js, can be | |
8 // removed once this makes it into testharness.js itself. | |
9 function promise_test(func, name, properties) { | |
10 properties = properties || {}; | |
11 var test = async_test(name, properties); | |
12 Promise.resolve(test.step(func, test, test)) | |
13 .then(function() { test.done(); }) | |
14 .catch(test.step_func(function(value) { | |
15 throw value; | |
16 })); | |
17 } | |
18 | |
19 var sw_url = 'resources/emptyworker.js'; | |
20 var sw_scope = window.location.origin + '/service-worker-scope' + | |
jsbell
2014/10/08 18:51:57
Don't need window.location.origin here - the scope
Marijn Kruisselbrink
2014/10/08 23:00:32
Okay, I just copied this from some of the existing
| |
21 window.location.pathname; | |
22 | |
23 promise_test(function(test) { | |
24 return service_worker_unregister_and_register(test, sw_url, | |
25 sw_scope + '/register') | |
26 .then(function(r) { | |
27 return r.geofencing.registerRegion( | |
28 new CircularGeofencingRegion({latitude: 37.421999, | |
29 longitude: -122.084015})) | |
30 .then(test.unreached_func('Promise should not have resolved')) | |
31 .catch(function() { }); | |
jsbell
2014/10/08 18:51:56
Assert something about the rejection here, so you
Marijn Kruisselbrink
2014/10/08 23:00:32
I now did that by copying even more code from work
jsbell
2014/10/08 23:13:54
Yeah, sorry about that. We'd been hoping to upstre
| |
32 }); | |
33 }, 'registerRegion should fail'); | |
34 | |
35 promise_test(function(test) { | |
36 return service_worker_unregister_and_register(test, sw_url, | |
37 sw_scope + '/unregister') | |
38 .then(function(r) { | |
39 return r.geofencing.unregisterRegion("") | |
jsbell
2014/10/08 18:51:57
Prefer single quotes: ''
Marijn Kruisselbrink
2014/10/08 23:00:32
Done.
| |
40 .then(test.unreached_func('Promise should not have resolved')) | |
41 .catch(function() { }); | |
jsbell
2014/10/08 18:51:56
Assert something about the rejection here.
Marijn Kruisselbrink
2014/10/08 23:00:32
Done.
| |
42 }); | |
43 }, 'unregisterRegion should fail'); | |
44 | |
45 promise_test(function(test) { | |
46 return service_worker_unregister_and_register(test, sw_url, | |
47 sw_scope + '/getregions') | |
48 .then(function(r) { | |
49 return r.geofencing.getRegisteredRegions() | |
50 .then(test.unreached_func('Promise should not have resolved')) | |
51 .catch(function() { }); | |
jsbell
2014/10/08 18:51:57
Assert something about the rejection here.
Marijn Kruisselbrink
2014/10/08 23:00:32
Done.
| |
52 }); | |
53 }, 'getRegisteredRegions should fail'); | |
54 | |
55 </script> | |
OLD | NEW |