@@ -36,122 +36,122 @@ exports.defineAutoTests = function () {
3636 var createTests = function ( platformOpts ) {
3737 platformOpts = platformOpts || '' ;
3838
39- describe ( 'cordova.InAppBrowser' , function ( ) {
39+ describe ( 'cordova.InAppBrowser' , function ( ) {
4040
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+ } ) ;
4444
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+ } ) ;
4849 } ) ;
49- } ) ;
5050
51- describe ( 'open method' , function ( ) {
51+ describe ( 'open method' , function ( ) {
5252
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+ }
5757
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/' ;
6262
63- beforeEach ( function ( ) {
63+ beforeEach ( function ( ) {
6464 // 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 ;
6767
68- iabInstance = null ;
69- } ) ;
68+ iabInstance = null ;
69+ } ) ;
7070
71- afterEach ( function ( done ) {
71+ afterEach ( function ( done ) {
7272 // restore original timeout
73- jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
73+ jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
7474
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+ } ) ;
8282
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+ }
8990 }
90- }
9191
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+ }
9999
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 ( ) {
101101 iabInstance = cordova . InAppBrowser . open ( url , '_blank' , platformOpts ) ;
102102
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 ( ) ;
113104
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 ) ) ;
117112 } ) ;
118113
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+
119119 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 ) {
124124 // according to documentation, "loadstart" event is not supported on browser
125125 // 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+ } ) ;
129130 } ) ;
130- } ) ;
131131
132- it ( 'inappbrowser.spec.5 should support exit event' , function ( done ) {
132+ it ( 'inappbrowser.spec.5 should support exit event' , function ( done ) {
133133 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 ;
137140 } ) ;
138- iabInstance . close ( ) ;
139- iabInstance = null ;
140- } ) ;
141141
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 ) {
144144 // according to documentation, "loaderror" event is not supported on browser
145145 // 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+ }
148148 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+ } ) ;
152153 } ) ;
153154 } ) ;
154- } ) ;
155155 } ;
156156 if ( isIos ) {
157157 createTests ( 'usewkwebview=no' ) ;
0 commit comments