@@ -755,6 +755,18 @@ describe('Viewport fixes', () => {
755
755
expect ( viewportValue ) . toBeUndefined ( )
756
756
} )
757
757
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
+
758
770
describe ( 'Desktop mode off' , ( ) => {
759
771
it ( 'should respect the forcedMobileValue config' , async ( ) => {
760
772
await gotoAndWait ( page , `http://localhost:${ port } /blank.html` , {
@@ -775,7 +787,20 @@ describe('Viewport fixes', () => {
775
787
const width = await page . evaluate ( 'screen.width' )
776
788
const expectedWidth = width < 1280 ? 980 : 1280
777
789
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 } ` )
779
804
} )
780
805
781
806
it ( 'should fix the WebView edge case' , async ( ) => {
@@ -819,7 +844,7 @@ describe('Viewport fixes', () => {
819
844
const width = await page . evaluate ( 'screen.width' )
820
845
const expectedWidth = width < 1280 ? 980 : 1280
821
846
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` )
823
848
} )
824
849
825
850
it ( 'should force wide viewport, ignoring the viewport tag 2' , async ( ) => {
@@ -831,7 +856,20 @@ describe('Viewport fixes', () => {
831
856
const width = await page . evaluate ( 'screen.width' )
832
857
const expectedWidth = width < 1280 ? 980 : 1280
833
858
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` )
835
873
} )
836
874
837
875
it ( 'should ignore the character case in the viewport tag' , async ( ) => {
@@ -843,7 +881,7 @@ describe('Viewport fixes', () => {
843
881
const width = await page . evaluate ( 'screen.width' )
844
882
const expectedWidth = width < 1280 ? 980 : 1280
845
883
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` )
847
885
} )
848
886
} )
849
887
} )
0 commit comments