@@ -217,6 +217,7 @@ type TestDisplayMediaHandler = (
217217
218218interface TestHostWebContents {
219219 readonly id : number ;
220+ readonly getZoomFactor : ( ) => number ;
220221 readonly mainFrame : { readonly frameTreeNodeId : number } ;
221222 readonly executeJavaScript : ReturnType < typeof vi . fn > ;
222223 readonly isDestroyed : ( ) => boolean ;
@@ -234,6 +235,7 @@ const makeTestHostWebContents = (): TestHostWebContents => {
234235 let handler : TestDisplayMediaHandler | undefined ;
235236 return {
236237 id : 7 ,
238+ getZoomFactor : ( ) => 1 ,
237239 mainFrame : { frameTreeNodeId : 7 } ,
238240 executeJavaScript : vi . fn ( async ( ) => true ) ,
239241 isDestroyed : ( ) => false ,
@@ -481,7 +483,7 @@ describe("PreviewManager", () => {
481483 Effect . gen ( function * ( ) {
482484 const preview = makeFaviconWebContents ( ) ;
483485 const sendInputEvent = vi . fn ( ) ;
484- const hostWebContents = { sendInputEvent } ;
486+ const hostWebContents = { sendInputEvent, getZoomFactor : ( ) => 1 } ;
485487 Object . assign ( preview . webContents , { hostWebContents } ) ;
486488 fromId . mockReturnValue ( preview . webContents ) ;
487489 yield * manager . setMainWindow ( {
@@ -1261,13 +1263,15 @@ describe("PreviewManager", () => {
12611263 effectIt . effect ( "keeps the tab's own zoom instead of the guest's reported zoom" , ( ) =>
12621264 withManager ( ( manager ) =>
12631265 Effect . gen ( function * ( ) {
1266+ const hostWebContents = { getZoomFactor : ( ) => 1.44 } ;
12641267 let effectiveZoom = 0.9 ;
12651268 let zoomReadable = true ;
12661269 let url = "https://example.com" ;
12671270 const listeners = new Map < string , ( ...args : unknown [ ] ) => void > ( ) ;
12681271 const setZoomFactor = vi . fn ( ) ;
12691272 fromId . mockReturnValue ( {
12701273 id : 42 ,
1274+ hostWebContents,
12711275 isDestroyed : ( ) => false ,
12721276 getType : ( ) => "webview" ,
12731277 getURL : ( ) => url ,
@@ -1308,7 +1312,7 @@ describe("PreviewManager", () => {
13081312 yield * manager . registerWebview ( "tab_zoom" , 42 ) ;
13091313
13101314 expect ( states . at ( - 1 ) ?. zoomFactor ) . toBe ( 1 ) ;
1311- expect ( setZoomFactor ) . toHaveBeenCalledWith ( 1 ) ;
1315+ expect ( setZoomFactor ) . toHaveBeenCalledWith ( 1.44 ) ;
13121316
13131317 // An app zoom leaves the guest reporting the inherited level. Navigating
13141318 // must not adopt it as the preview's zoom.
@@ -1326,7 +1330,7 @@ describe("PreviewManager", () => {
13261330
13271331 // Only the preview's own zoom controls move it.
13281332 yield * manager . zoomIn ( "tab_zoom" ) ;
1329- expect ( setZoomFactor ) . toHaveBeenCalledWith ( 1.1 ) ;
1333+ expect ( setZoomFactor ) . toHaveBeenCalledWith ( 1.1 * 1.44 ) ;
13301334 expect ( states . at ( - 1 ) ?. zoomFactor ) . toBe ( 1.1 ) ;
13311335
13321336 zoomReadable = false ;
@@ -1338,6 +1342,7 @@ describe("PreviewManager", () => {
13381342 const replacementSetZoomFactor = vi . fn ( ) ;
13391343 fromId . mockReturnValue ( {
13401344 id : 43 ,
1345+ hostWebContents,
13411346 isDestroyed : ( ) => false ,
13421347 getType : ( ) => "webview" ,
13431348 getURL : ( ) => url ,
@@ -1365,7 +1370,7 @@ describe("PreviewManager", () => {
13651370
13661371 yield * manager . registerWebview ( "tab_zoom" , 43 ) ;
13671372
1368- expect ( replacementSetZoomFactor ) . toHaveBeenCalledWith ( 1.1 ) ;
1373+ expect ( replacementSetZoomFactor ) . toHaveBeenCalledWith ( 1.1 * 1.44 ) ;
13691374 expect ( states . at ( - 1 ) ?. zoomFactor ) . toBe ( 1.1 ) ;
13701375 } ) ,
13711376 ) ,
@@ -1376,9 +1381,11 @@ describe("PreviewManager", () => {
13761381 effectIt . effect ( "re-applies each tab's own zoom when the app window zooms" , ( ) =>
13771382 withManager ( ( manager ) =>
13781383 Effect . gen ( function * ( ) {
1384+ let hostZoom = 1 ;
13791385 const setZoomFactor = vi . fn ( ) ;
13801386 fromId . mockReturnValue ( {
13811387 id : 42 ,
1388+ hostWebContents : { getZoomFactor : ( ) => hostZoom } ,
13821389 isDestroyed : ( ) => false ,
13831390 getType : ( ) => "webview" ,
13841391 getURL : ( ) => "https://example.com" ,
@@ -1409,10 +1416,11 @@ describe("PreviewManager", () => {
14091416 yield * manager . zoomIn ( "tab_reapply" ) ;
14101417 setZoomFactor . mockClear ( ) ;
14111418
1412- yield * manager . reapplyZoom ( ) ;
1413-
1414- expect ( setZoomFactor ) . toHaveBeenCalledTimes ( 1 ) ;
1415- expect ( setZoomFactor ) . toHaveBeenCalledWith ( 1.1 ) ;
1419+ for ( const zoom of [ 1.44 , 0.8 , 1 ] ) {
1420+ hostZoom = zoom ;
1421+ yield * manager . reapplyZoom ( ) ;
1422+ expect ( setZoomFactor ) . toHaveBeenLastCalledWith ( 1.1 * hostZoom ) ;
1423+ }
14161424 } ) ,
14171425 ) ,
14181426 ) ;
0 commit comments