@@ -28,6 +28,10 @@ class FakeWebContents extends EventEmitter {
2828 return this . destroyed ;
2929 }
3030
31+ public getZoomLevel ( ) : number {
32+ return this . zoomLevel ;
33+ }
34+
3135 public setZoomLevel ( level : number ) : void {
3236 this . setZoomLevelCalls . push ( level ) ;
3337 this . zoomLevel = level ;
@@ -98,7 +102,6 @@ describe("window zoom", () => {
98102
99103 window . webContents . emit ( "zoom-changed" , { preventDefault : vi . fn ( ) } , "in" ) ;
100104 vi . runAllTimers ( ) ;
101- vi . advanceTimersByTime ( 5 * 60 * 1000 ) ;
102105 window . webContents . zoomLevel = 0 ;
103106
104107 window . emit ( "resize" ) ;
@@ -166,17 +169,29 @@ describe("window zoom", () => {
166169 } ,
167170 ) ;
168171
169- it ( "debounces repeated resize restorations " , ( ) => {
172+ it ( "skips redundant restoration during a resize storm " , ( ) => {
170173 const window = createWindow ( ) ;
171174 setupWindowZoom ( window ) ;
172- window . webContents . zoomLevel = 0 ;
175+ window . webContents . zoomLevel = 0.5 ;
173176
174177 window . emit ( "resize" ) ;
178+ vi . runAllTimers ( ) ;
179+ vi . advanceTimersByTime ( 16 ) ;
175180 window . emit ( "resize" ) ;
176- window . emit ( "resized" ) ;
177181 vi . runAllTimers ( ) ;
182+ const callsBeforeReset = [ ...window . webContents . setZoomLevelCalls ] ;
178183
179- expect ( window . webContents . setZoomLevelCalls ) . toEqual ( [ 0.5 ] ) ;
184+ window . webContents . zoomLevel = 0 ;
185+ window . emit ( "resize" ) ;
186+ vi . runAllTimers ( ) ;
187+
188+ expect ( {
189+ callsBeforeReset,
190+ callsAfterReset : window . webContents . setZoomLevelCalls ,
191+ } ) . toEqual ( {
192+ callsBeforeReset : [ ] ,
193+ callsAfterReset : [ 0.5 ] ,
194+ } ) ;
180195 } ) ;
181196
182197 it ( "ignores queued zoom work after the window is destroyed" , ( ) => {
0 commit comments