@@ -13,6 +13,7 @@ import {
1313 createFakeStdin ,
1414 getFakeFirefox ,
1515 getFakeRemoteFirefox ,
16+ ZipFile ,
1617} from '../helpers.js' ;
1718
1819// Fake result for client.installTemporaryAddon().then(installResult => ...)
@@ -833,6 +834,84 @@ describe('util/extension-runners/firefox-android', () => {
833834 sinon . assert . calledOnce ( anotherCallback ) ;
834835 } ) ;
835836
837+ it ( 'opens a single URL when specified via --start-url' , async ( ) => {
838+ const { params, fakeADBUtils } = prepareSelectedDeviceAndAPKParams ( ) ;
839+ params . startUrl = 'https://example.com/' ;
840+
841+ let pushedBackgroundJs ;
842+ fakeADBUtils . pushFile = sinon . spy ( async ( _ , localZipPath ) => {
843+ if ( localZipPath . includes ( 'web-ext-internal-helper-to-open-start-urls.xpi' ) ) {
844+ const zipFile = new ZipFile ( ) ;
845+ await zipFile . open ( localZipPath ) ;
846+ pushedBackgroundJs = await zipFile . getAsText ( 'background.js' ) ;
847+ await zipFile . close ( ) ;
848+ }
849+ } ) ;
850+
851+ const runnerInstance = new FirefoxAndroidExtensionRunner ( params ) ;
852+ await runnerInstance . run ( ) ;
853+
854+ const { installTemporaryAddon } = runnerInstance . remoteFirefox ;
855+
856+ sinon . assert . calledTwice ( installTemporaryAddon ) ;
857+
858+ sinon . assert . calledWithMatch (
859+ installTemporaryAddon ,
860+ `${ runnerInstance . selectedArtifactsDir } /${ builtFileName } .xpi` ,
861+ ) ;
862+
863+ sinon . assert . calledWithMatch (
864+ installTemporaryAddon ,
865+ `${ runnerInstance . selectedArtifactsDir } /web-ext-internal-helper-to-open-start-urls.xpi` ,
866+ ) ;
867+ sinon . assert . calledWithMatch (
868+ fakeADBUtils . pushFile ,
869+ 'emulator-1' ,
870+ sinon . match ( / \b w e b - e x t - i n t e r n a l - h e l p e r - t o - o p e n - s t a r t - u r l s \. x p i $ / ) ,
871+ `${ runnerInstance . selectedArtifactsDir } /web-ext-internal-helper-to-open-start-urls.xpi` ,
872+ ) ;
873+ assert . include ( pushedBackgroundJs , '["https://example.com/"]' ) ;
874+ } ) ;
875+
876+ it ( 'opens a multiple URL when specified via --start-url' , async ( ) => {
877+ const { params, fakeADBUtils } = prepareSelectedDeviceAndAPKParams ( ) ;
878+ params . startUrl = [ 'about:blank' , 'http://localhost' ] ;
879+
880+ let pushedBackgroundJs ;
881+ fakeADBUtils . pushFile = sinon . spy ( async ( _ , localZipPath ) => {
882+ if ( localZipPath . includes ( 'web-ext-internal-helper-to-open-start-urls.xpi' ) ) {
883+ const zipFile = new ZipFile ( ) ;
884+ await zipFile . open ( localZipPath ) ;
885+ pushedBackgroundJs = await zipFile . getAsText ( 'background.js' ) ;
886+ await zipFile . close ( ) ;
887+ }
888+ } ) ;
889+
890+ const runnerInstance = new FirefoxAndroidExtensionRunner ( params ) ;
891+ await runnerInstance . run ( ) ;
892+
893+ sinon . assert . calledWithMatch (
894+ fakeADBUtils . pushFile ,
895+ 'emulator-1' ,
896+ sinon . match ( / \b w e b - e x t - i n t e r n a l - h e l p e r - t o - o p e n - s t a r t - u r l s \. x p i $ / ) ,
897+ `${ runnerInstance . selectedArtifactsDir } /web-ext-internal-helper-to-open-start-urls.xpi` ,
898+ ) ;
899+ assert . include ( pushedBackgroundJs , '["about:blank","http://localhost"]' ) ;
900+ } ) ;
901+
902+ it ( 'does not install helper extension without --start-url' , async ( ) => {
903+ const { params } = prepareSelectedDeviceAndAPKParams ( ) ;
904+
905+ const runnerInstance = new FirefoxAndroidExtensionRunner ( params ) ;
906+ await runnerInstance . run ( ) ;
907+
908+ const { installTemporaryAddon } = runnerInstance . remoteFirefox ;
909+ sinon . assert . calledOnce ( installTemporaryAddon ) ;
910+ const seenPath = installTemporaryAddon . firstCall . args [ 0 ] ;
911+ assert . include ( seenPath , '.xpi' ) ;
912+ assert . notInclude ( seenPath , 'web-ext-internal-helper-to-open-start-urls.xpi' ) ;
913+ } ) ;
914+
836915 it ( 'logs warnings on the unsupported CLI options' , async ( ) => {
837916 const params = prepareSelectedDeviceAndAPKParams ( ) ;
838917
@@ -856,10 +935,6 @@ describe('util/extension-runners/firefox-android', () => {
856935 params : { preInstall : true } ,
857936 expectedMessage : / A n d r o i d t a r g e t d o e s n o t s u p p o r t - - p r e - i n s t a l l / ,
858937 } ,
859- {
860- params : { startUrl : 'http://fake-start-url.org' } ,
861- expectedMessage : / A n d r o i d t a r g e t d o e s n o t s u p p o r t - - s t a r t - u r l / ,
862- } ,
863938 {
864939 params : { args : [ '-headless=false' ] } ,
865940 expectedMessage : / A n d r o i d t a r g e t d o e s n o t s u p p o r t - - a r g s / ,
0 commit comments