@@ -354,6 +354,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
354354 '<div id="info">' +
355355 'Make sure http://cordova.apache.org and http://google.co.uk and https://www.google.co.uk are white listed. </br>' +
356356 'Make sure http://www.apple.com is not in the white list.</br>' +
357+ 'Make sure your config.xml contains: <preference name="AllowedSchemes" value="custom" >/<br/>' +
357358 'In iOS, starred <span style="vertical-align:super">*</span> tests will put the app in a state with no way to return. </br>' +
358359 '<h4>User-Agent: <span id="user-agent"> </span></hr>' +
359360 '</div>' ;
@@ -492,16 +493,20 @@ exports.defineManualTests = function (contentEl, createActionButton) {
492493 '<p/> <div id="openHardwareBackDefaultAfterNo"></div>' +
493494 'Expected result: consistently open browsers with with the appropriate option: hardwareback=defaults to yes then hardwareback=no then hardwareback=defaults to yes. By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser' ;
494495
496+ var customscheme_tests = '<h1>customscheme</h1>' +
497+ '<p/> <div id="openCustomscheme"></div>' +
498+ 'Expected result: open an alert dialog with the text "Results verified". Works only on Android and iOS.' ;
499+
495500 // CB-7490 We need to wrap this code due to Windows security restrictions
496501 // see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details
497502 if ( window . MSApp && window . MSApp . execUnsafeLocalFunction ) {
498503 MSApp . execUnsafeLocalFunction ( function ( ) {
499504 contentEl . innerHTML = info_div + platform_info + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests +
500- css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests ;
505+ css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests + customscheme_tests ;
501506 } ) ;
502507 } else {
503508 contentEl . innerHTML = info_div + platform_info + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests +
504- css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests ;
509+ css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests + customscheme_tests ;
505510 }
506511
507512 document . getElementById ( 'user-agent' ) . textContent = navigator . userAgent ;
@@ -732,4 +737,30 @@ exports.defineManualTests = function (contentEl, createActionButton) {
732737 } ) ;
733738 } ) ;
734739 } , 'openHardwareBackDefaultAfterNo' ) ;
740+
741+ // Customscheme
742+ createActionButton ( 'customscheme' , function ( ) {
743+
744+ var ref = cordova . InAppBrowser . open ( 'about:blank' , '_blank' , 'hidden=yes' + ( platformOpts ? ',' + platformOpts : '' ) ) ;
745+ var openedCustomscheme = false ;
746+ ref . addEventListener ( 'loadstop' , function ( e ) {
747+ // Avoid showing the alert twice on iOS, since loadstop is also being called after the customscheme event.
748+ if ( ! openedCustomscheme ) {
749+ openedCustomscheme = true ;
750+ ref . executeScript ( { code : 'window.location.replace("custom://test");' } ) ;
751+ }
752+ } ) ;
753+ ref . addEventListener ( 'customscheme' , function ( e ) {
754+ if ( e && e . url === 'custom://test' ) {
755+ alert ( 'Results verified' ) ; // eslint-disable-line no-undef
756+ } else {
757+ alert ( 'Got: ' + e . url ) ; // eslint-disable-line no-undef
758+ }
759+ ref . close ( ) ;
760+ } ) ;
761+ ref . addEventListener ( 'loaderror' , function ( e ) {
762+ alert ( 'Load error: ' + e . message + '\nYou may need to set the AllowedSchemes preference' ) ; // eslint-disable-line no-undef
763+ ref . close ( ) ;
764+ } ) ;
765+ } , 'openCustomscheme' ) ;
735766} ;
0 commit comments