This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ var registerElementPatch = require('./register-element');
8
8
var webSocketPatch = require ( './websocket' ) ;
9
9
var eventTargetPatch = require ( './event-target' ) ;
10
10
var propertyDescriptorPatch = require ( './property-descriptor' ) ;
11
+ var geolocationPatch = require ( './geolocation' ) ;
11
12
12
13
function apply ( ) {
13
14
fnPatch . patchSetClearFunction ( global , [
@@ -39,6 +40,8 @@ function apply() {
39
40
definePropertyPatch . apply ( ) ;
40
41
41
42
registerElementPatch . apply ( ) ;
43
+
44
+ geolocationPatch . apply ( ) ;
42
45
}
43
46
44
47
module . exports = {
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ var utils = require ( '../utils' ) ;
4
+
5
+ function apply ( ) {
6
+ if ( global . navigator && global . navigator . geolocation ) {
7
+ utils . patchPrototype ( global . navigator . geolocation , [
8
+ 'getCurrentPosition' ,
9
+ 'watchPosition'
10
+ ] ) ;
11
+ }
12
+ }
13
+
14
+ module . exports = {
15
+ apply : apply
16
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ function supportsGeolocation ( ) {
4
+ return 'geolocation' in navigator ;
5
+ }
6
+ supportsGeolocation . message = 'Geolocation' ;
7
+
8
+ describe ( 'Geolocation' , ifEnvSupports ( supportsGeolocation , function ( ) {
9
+ var testZone = zone . fork ( ) ;
10
+
11
+ it ( 'should work for getCurrentPosition' , function ( done ) {
12
+ testZone . run ( function ( ) {
13
+ navigator . geolocation . getCurrentPosition (
14
+ function ( pos ) {
15
+ expect ( window . zone ) . toBeDirectChildOf ( testZone ) ;
16
+ done ( ) ;
17
+ }
18
+ ) ;
19
+ } ) ;
20
+ } ) ;
21
+
22
+ it ( 'should work for watchPosition' , function ( done ) {
23
+ testZone . run ( function ( ) {
24
+ var watchId ;
25
+ watchId = navigator . geolocation . watchPosition (
26
+ function ( pos ) {
27
+ expect ( window . zone ) . toBeDirectChildOf ( testZone ) ;
28
+ navigator . geolocation . clearWatch ( watchId ) ;
29
+ done ( ) ;
30
+ }
31
+ ) ;
32
+ } ) ;
33
+ } ) ;
34
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments