@@ -755,6 +755,18 @@ describe('Viewport fixes', () => {
755755 expect ( viewportValue ) . toBeUndefined ( )
756756 } )
757757
758+ it ( 'should respect forced zoom' , async ( ) => {
759+ await gotoAndWait ( page , `http://localhost:${ port } /blank.html` , {
760+ site : { enabledFeatures : [ 'webCompat' ] } ,
761+ featureSettings : { webCompat : { viewportWidth : 'enabled' } } ,
762+ desktopModeEnabled : false ,
763+ forcedZoomEnabled : true
764+ } , 'document.head.innerHTML += \'<meta name="viewport" content="width=device-width">\'' )
765+
766+ const viewportValue = await page . evaluate ( getViewportValue )
767+ expect ( viewportValue ) . toEqual ( 'initial-scale=1, user-scalable=yes, maximum-scale=10, width=device-width' )
768+ } )
769+
758770 describe ( 'Desktop mode off' , ( ) => {
759771 it ( 'should respect the forcedMobileValue config' , async ( ) => {
760772 await gotoAndWait ( page , `http://localhost:${ port } /blank.html` , {
@@ -775,7 +787,20 @@ describe('Viewport fixes', () => {
775787 const width = await page . evaluate ( 'screen.width' )
776788 const expectedWidth = width < 1280 ? 980 : 1280
777789 const viewportValue = await page . evaluate ( getViewportValue )
778- expect ( viewportValue ) . toEqual ( `width=${ expectedWidth } , initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } ` )
790+ expect ( viewportValue ) . toEqual ( `width=${ expectedWidth } , initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } , user-scalable=yes` )
791+ } )
792+
793+ it ( 'should respect forced zoom' , async ( ) => {
794+ await gotoAndWait ( page , `http://localhost:${ port } /blank.html` , {
795+ site : { enabledFeatures : [ 'webCompat' ] } ,
796+ featureSettings : { webCompat : { viewportWidth : 'enabled' } } ,
797+ desktopModeEnabled : false ,
798+ forcedZoomEnabled : true
799+ } )
800+ const width = await page . evaluate ( 'screen.width' )
801+ const expectedWidth = width < 1280 ? 980 : 1280
802+ const viewportValue = await page . evaluate ( getViewportValue )
803+ expect ( viewportValue ) . toEqual ( `initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } , user-scalable=yes, maximum-scale=10, width=${ expectedWidth } ` )
779804 } )
780805
781806 it ( 'should fix the WebView edge case' , async ( ) => {
@@ -819,7 +844,7 @@ describe('Viewport fixes', () => {
819844 const width = await page . evaluate ( 'screen.width' )
820845 const expectedWidth = width < 1280 ? 980 : 1280
821846 const viewportValue = await page . evaluate ( getViewportValue )
822- expect ( viewportValue ) . toEqual ( `width=${ expectedWidth } , initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } , something-something` )
847+ expect ( viewportValue ) . toEqual ( `width=${ expectedWidth } , initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } , user-scalable=yes, something-something` )
823848 } )
824849
825850 it ( 'should force wide viewport, ignoring the viewport tag 2' , async ( ) => {
@@ -831,7 +856,20 @@ describe('Viewport fixes', () => {
831856 const width = await page . evaluate ( 'screen.width' )
832857 const expectedWidth = width < 1280 ? 980 : 1280
833858 const viewportValue = await page . evaluate ( getViewportValue )
834- expect ( viewportValue ) . toEqual ( `width=${ expectedWidth } , initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } ,something-something` )
859+ expect ( viewportValue ) . toEqual ( `width=${ expectedWidth } , initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } , user-scalable=yes, something-something` )
860+ } )
861+
862+ it ( 'should respect forced zoom' , async ( ) => {
863+ await gotoAndWait ( page , `http://localhost:${ port } /blank.html` , {
864+ site : { enabledFeatures : [ 'webCompat' ] } ,
865+ featureSettings : { webCompat : { viewportWidth : 'enabled' } } ,
866+ desktopModeEnabled : true ,
867+ forcedZoomEnabled : true
868+ } , 'document.head.innerHTML += \'<meta name="viewport" content="width=device-width, initial-scale=2, user-scalable=no, something-something">\'' )
869+ const width = await page . evaluate ( 'screen.width' )
870+ const expectedWidth = width < 1280 ? 980 : 1280
871+ const viewportValue = await page . evaluate ( getViewportValue )
872+ expect ( viewportValue ) . toEqual ( `initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } , user-scalable=yes, maximum-scale=10, width=${ expectedWidth } , something-something` )
835873 } )
836874
837875 it ( 'should ignore the character case in the viewport tag' , async ( ) => {
@@ -843,7 +881,7 @@ describe('Viewport fixes', () => {
843881 const width = await page . evaluate ( 'screen.width' )
844882 const expectedWidth = width < 1280 ? 980 : 1280
845883 const viewportValue = await page . evaluate ( getViewportValue )
846- expect ( viewportValue ) . toEqual ( `width=${ expectedWidth } , initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } , something-something` )
884+ expect ( viewportValue ) . toEqual ( `width=${ expectedWidth } , initial-scale=${ ( width / expectedWidth ) . toFixed ( 3 ) } , user-scalable=yes, something-something` )
847885 } )
848886 } )
849887} )
0 commit comments