@@ -36,122 +36,122 @@ exports.defineAutoTests = function () {
36
36
var createTests = function ( platformOpts ) {
37
37
platformOpts = platformOpts || '' ;
38
38
39
- describe ( 'cordova.InAppBrowser' , function ( ) {
39
+ describe ( 'cordova.InAppBrowser' , function ( ) {
40
40
41
- it ( 'inappbrowser.spec.1 should exist' , function ( ) {
42
- expect ( cordova . InAppBrowser ) . toBeDefined ( ) ;
43
- } ) ;
41
+ it ( 'inappbrowser.spec.1 should exist' , function ( ) {
42
+ expect ( cordova . InAppBrowser ) . toBeDefined ( ) ;
43
+ } ) ;
44
44
45
- it ( 'inappbrowser.spec.2 should contain open function' , function ( ) {
46
- expect ( cordova . InAppBrowser . open ) . toBeDefined ( ) ;
47
- expect ( cordova . InAppBrowser . open ) . toEqual ( jasmine . any ( Function ) ) ;
45
+ it ( 'inappbrowser.spec.2 should contain open function' , function ( ) {
46
+ expect ( cordova . InAppBrowser . open ) . toBeDefined ( ) ;
47
+ expect ( cordova . InAppBrowser . open ) . toEqual ( jasmine . any ( Function ) ) ;
48
+ } ) ;
48
49
} ) ;
49
- } ) ;
50
50
51
- describe ( 'open method' , function ( ) {
51
+ describe ( 'open method' , function ( ) {
52
52
53
- if ( cordova . platformId === 'osx' ) {
54
- pending ( 'Open method not fully supported on OSX.' ) ;
55
- return ;
56
- }
53
+ if ( cordova . platformId === 'osx' ) {
54
+ pending ( 'Open method not fully supported on OSX.' ) ;
55
+ return ;
56
+ }
57
57
58
- var iabInstance ;
59
- var originalTimeout ;
60
- var url = 'https://dist.apache.org/repos/dist/dev/cordova/' ;
61
- var badUrl = 'http://bad-uri/' ;
58
+ var iabInstance ;
59
+ var originalTimeout ;
60
+ var url = 'https://dist.apache.org/repos/dist/dev/cordova/' ;
61
+ var badUrl = 'http://bad-uri/' ;
62
62
63
- beforeEach ( function ( ) {
63
+ beforeEach ( function ( ) {
64
64
// increase timeout to ensure test url could be loaded within test time
65
- originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
66
- jasmine . DEFAULT_TIMEOUT_INTERVAL = 30000 ;
65
+ originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
66
+ jasmine . DEFAULT_TIMEOUT_INTERVAL = 30000 ;
67
67
68
- iabInstance = null ;
69
- } ) ;
68
+ iabInstance = null ;
69
+ } ) ;
70
70
71
- afterEach ( function ( done ) {
71
+ afterEach ( function ( done ) {
72
72
// restore original timeout
73
- jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
73
+ jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
74
74
75
- if ( iabInstance !== null && iabInstance . close ) {
76
- iabInstance . close ( ) ;
77
- }
78
- iabInstance = null ;
79
- // add some extra time so that iab dialog is closed
80
- setTimeout ( done , 2000 ) ;
81
- } ) ;
75
+ if ( iabInstance !== null && iabInstance . close ) {
76
+ iabInstance . close ( ) ;
77
+ }
78
+ iabInstance = null ;
79
+ // add some extra time so that iab dialog is closed
80
+ setTimeout ( done , 2000 ) ;
81
+ } ) ;
82
82
83
- function verifyEvent ( evt , type ) {
84
- expect ( evt ) . toBeDefined ( ) ;
85
- expect ( evt . type ) . toEqual ( type ) ;
86
- // `exit` event does not have url field, browser returns null url for CORS requests
87
- if ( type !== 'exit' && ! isBrowser ) {
88
- expect ( evt . url ) . toEqual ( url ) ;
83
+ function verifyEvent ( evt , type ) {
84
+ expect ( evt ) . toBeDefined ( ) ;
85
+ expect ( evt . type ) . toEqual ( type ) ;
86
+ // `exit` event does not have url field, browser returns null url for CORS requests
87
+ if ( type !== 'exit' && ! isBrowser ) {
88
+ expect ( evt . url ) . toEqual ( url ) ;
89
+ }
89
90
}
90
- }
91
91
92
- function verifyLoadErrorEvent ( evt ) {
93
- expect ( evt ) . toBeDefined ( ) ;
94
- expect ( evt . type ) . toEqual ( 'loaderror' ) ;
95
- expect ( evt . url ) . toEqual ( badUrl ) ;
96
- expect ( evt . code ) . toEqual ( jasmine . any ( Number ) ) ;
97
- expect ( evt . message ) . toEqual ( jasmine . any ( String ) ) ;
98
- }
92
+ function verifyLoadErrorEvent ( evt ) {
93
+ expect ( evt ) . toBeDefined ( ) ;
94
+ expect ( evt . type ) . toEqual ( 'loaderror' ) ;
95
+ expect ( evt . url ) . toEqual ( badUrl ) ;
96
+ expect ( evt . code ) . toEqual ( jasmine . any ( Number ) ) ;
97
+ expect ( evt . message ) . toEqual ( jasmine . any ( String ) ) ;
98
+ }
99
99
100
- it ( 'inappbrowser.spec.3 should return InAppBrowser instance with required methods' , function ( ) {
100
+ it ( 'inappbrowser.spec.3 should return InAppBrowser instance with required methods' , function ( ) {
101
101
iabInstance = cordova . InAppBrowser . open ( url , '_blank' , platformOpts ) ;
102
102
103
- expect ( iabInstance ) . toBeDefined ( ) ;
104
-
105
- expect ( iabInstance . addEventListener ) . toEqual ( jasmine . any ( Function ) ) ;
106
- expect ( iabInstance . removeEventListener ) . toEqual ( jasmine . any ( Function ) ) ;
107
- expect ( iabInstance . close ) . toEqual ( jasmine . any ( Function ) ) ;
108
- expect ( iabInstance . show ) . toEqual ( jasmine . any ( Function ) ) ;
109
- expect ( iabInstance . hide ) . toEqual ( jasmine . any ( Function ) ) ;
110
- expect ( iabInstance . executeScript ) . toEqual ( jasmine . any ( Function ) ) ;
111
- expect ( iabInstance . insertCSS ) . toEqual ( jasmine . any ( Function ) ) ;
112
- } ) ;
103
+ expect ( iabInstance ) . toBeDefined ( ) ;
113
104
114
- it ( 'inappbrowser.spec.4 should support loadstart and loadstop events' , function ( done ) {
115
- var onLoadStart = jasmine . createSpy ( 'loadstart event callback' ) . and . callFake ( function ( evt ) {
116
- verifyEvent ( evt , 'loadstart' ) ;
105
+ expect ( iabInstance . addEventListener ) . toEqual ( jasmine . any ( Function ) ) ;
106
+ expect ( iabInstance . removeEventListener ) . toEqual ( jasmine . any ( Function ) ) ;
107
+ expect ( iabInstance . close ) . toEqual ( jasmine . any ( Function ) ) ;
108
+ expect ( iabInstance . show ) . toEqual ( jasmine . any ( Function ) ) ;
109
+ expect ( iabInstance . hide ) . toEqual ( jasmine . any ( Function ) ) ;
110
+ expect ( iabInstance . executeScript ) . toEqual ( jasmine . any ( Function ) ) ;
111
+ expect ( iabInstance . insertCSS ) . toEqual ( jasmine . any ( Function ) ) ;
117
112
} ) ;
118
113
114
+ it ( 'inappbrowser.spec.4 should support loadstart and loadstop events' , function ( done ) {
115
+ var onLoadStart = jasmine . createSpy ( 'loadstart event callback' ) . and . callFake ( function ( evt ) {
116
+ verifyEvent ( evt , 'loadstart' ) ;
117
+ } ) ;
118
+
119
119
iabInstance = cordova . InAppBrowser . open ( url , '_blank' , platformOpts ) ;
120
- iabInstance . addEventListener ( 'loadstart' , onLoadStart ) ;
121
- iabInstance . addEventListener ( 'loadstop' , function ( evt ) {
122
- verifyEvent ( evt , 'loadstop' ) ;
123
- if ( ! isBrowser ) {
120
+ iabInstance . addEventListener ( 'loadstart' , onLoadStart ) ;
121
+ iabInstance . addEventListener ( 'loadstop' , function ( evt ) {
122
+ verifyEvent ( evt , 'loadstop' ) ;
123
+ if ( ! isBrowser ) {
124
124
// according to documentation, "loadstart" event is not supported on browser
125
125
// https://github.com./apache/cordova-plugin-inappbrowser#browser-quirks-1
126
- expect ( onLoadStart ) . toHaveBeenCalled ( ) ;
127
- }
128
- done ( ) ;
126
+ expect ( onLoadStart ) . toHaveBeenCalled ( ) ;
127
+ }
128
+ done ( ) ;
129
+ } ) ;
129
130
} ) ;
130
- } ) ;
131
131
132
- it ( 'inappbrowser.spec.5 should support exit event' , function ( done ) {
132
+ it ( 'inappbrowser.spec.5 should support exit event' , function ( done ) {
133
133
iabInstance = cordova . InAppBrowser . open ( url , '_blank' , platformOpts ) ;
134
- iabInstance . addEventListener ( 'exit' , function ( evt ) {
135
- verifyEvent ( evt , 'exit' ) ;
136
- done ( ) ;
134
+ iabInstance . addEventListener ( 'exit' , function ( evt ) {
135
+ verifyEvent ( evt , 'exit' ) ;
136
+ done ( ) ;
137
+ } ) ;
138
+ iabInstance . close ( ) ;
139
+ iabInstance = null ;
137
140
} ) ;
138
- iabInstance . close ( ) ;
139
- iabInstance = null ;
140
- } ) ;
141
141
142
- it ( 'inappbrowser.spec.6 should support loaderror event' , function ( done ) {
143
- if ( isBrowser ) {
142
+ it ( 'inappbrowser.spec.6 should support loaderror event' , function ( done ) {
143
+ if ( isBrowser ) {
144
144
// according to documentation, "loaderror" event is not supported on browser
145
145
// https://github.com./apache/cordova-plugin-inappbrowser#browser-quirks-1
146
- pending ( 'Browser platform doesn\'t support loaderror event' ) ;
147
- }
146
+ pending ( 'Browser platform doesn\'t support loaderror event' ) ;
147
+ }
148
148
iabInstance = cordova . InAppBrowser . open ( badUrl , '_blank' , platformOpts ) ;
149
- iabInstance . addEventListener ( 'loaderror' , function ( evt ) {
150
- verifyLoadErrorEvent ( evt ) ;
151
- done ( ) ;
149
+ iabInstance . addEventListener ( 'loaderror' , function ( evt ) {
150
+ verifyLoadErrorEvent ( evt ) ;
151
+ done ( ) ;
152
+ } ) ;
152
153
} ) ;
153
154
} ) ;
154
- } ) ;
155
155
} ;
156
156
if ( isIos ) {
157
157
createTests ( 'usewkwebview=no' ) ;
0 commit comments