@@ -48,10 +48,10 @@ function subtractSizes (sizeA, sizeB) {
4848
4949export default class BrowserProvider {
5050 constructor ( plugin ) {
51- this . plugin = plugin ;
52- this . initPromise = Promise . resolve ( false ) ;
51+ this . plugin = plugin ;
52+ this . initPromise = Promise . resolve ( false ) ;
5353
54- this . isMultiBrowser = this . plugin . isMultiBrowser ;
54+ this . isMultiBrowser = this . plugin . isMultiBrowser ;
5555 // HACK: The browser window has different border sizes in normal and maximized modes. So, we need to be sure that the window is
5656 // not maximized before resizing it in order to keep the mechanism of correcting the client area size working. When browser is started,
5757 // we are resizing it for the first time to switch the window to normal mode, and for the second time - to restore the client area size.
@@ -195,7 +195,17 @@ export default class BrowserProvider {
195195 }
196196
197197 async closeBrowser ( browserId ) {
198- await this . plugin . closeBrowser ( browserId ) ;
198+ var isLocalBrowser = await this . plugin . isLocalBrowser ( browserId ) ;
199+ var customActionsInfo = await this . plugin . hasCustomActionForBrowser ( browserId ) ;
200+ var hasCustomCloseBrowser = customActionsInfo . hasCloseBrowser ;
201+ var usePluginsCloseBrowser = hasCustomCloseBrowser || ! isLocalBrowser ;
202+
203+ if ( usePluginsCloseBrowser ) {
204+ await this . plugin . closeBrowser ( browserId ) ;
205+ return ;
206+ }
207+
208+ await browserTools . close ( this . windowDescriptors [ browserId ] ) ;
199209 }
200210
201211 async getBrowserList ( ) {
@@ -207,10 +217,12 @@ export default class BrowserProvider {
207217 }
208218
209219 async resizeWindow ( browserId , width , height , currentWidth , currentHeight ) {
210- var isLocalBrowser = await this . plugin . isLocalBrowser ( browserId ) ;
211- var supportedFeatures = await this . plugin . hasCustomActionForBrowser ( browserId ) ;
220+ var isLocalBrowser = await this . plugin . isLocalBrowser ( browserId ) ;
221+ var customActionsInfo = await this . plugin . hasCustomActionForBrowser ( browserId ) ;
222+ var hasCustomResizeWindow = customActionsInfo . hasResizeWindow ;
223+
212224
213- if ( isLocalBrowser && ! supportedFeatures . hasResizeWindow ) {
225+ if ( isLocalBrowser && ! hasCustomResizeWindow ) {
214226 await this . _resizeLocalBrowserWindow ( browserId , width , height , currentWidth , currentHeight ) ;
215227 return ;
216228 }
@@ -219,30 +231,34 @@ export default class BrowserProvider {
219231 }
220232
221233 async canResizeWindowToDimensions ( browserId , width , height ) {
222- var isLocalBrowser = await this . plugin . isLocalBrowser ( browserId ) ;
223- var supportedFeatures = await this . plugin . hasCustomActionForBrowser ( browserId ) ;
234+ var isLocalBrowser = await this . plugin . isLocalBrowser ( browserId ) ;
235+ var customActionsInfo = await this . plugin . hasCustomActionForBrowser ( browserId ) ;
236+ var hasCustomCanResizeToDimensions = customActionsInfo . hasCanResizeWindowToDimensions ;
237+
224238
225- if ( isLocalBrowser && ! supportedFeatures . hasCanResizeWindowToDimensions )
239+ if ( isLocalBrowser && ! hasCustomCanResizeToDimensions )
226240 return await this . _canResizeLocalBrowserWindowToDimensions ( browserId , width , height ) ;
227241
228242 return await this . plugin . canResizeWindowToDimensions ( browserId , width , height ) ;
229243 }
230244
231245 async maximizeWindow ( browserId ) {
232- var isLocalBrowser = await this . plugin . isLocalBrowser ( browserId ) ;
233- var supportedFeatures = await this . plugin . hasCustomActionForBrowser ( browserId ) ;
246+ var isLocalBrowser = await this . plugin . isLocalBrowser ( browserId ) ;
247+ var customActionsInfo = await this . plugin . hasCustomActionForBrowser ( browserId ) ;
248+ var hasCustomMaximizeWindow = customActionsInfo . hasMaximizeWindow ;
234249
235- if ( isLocalBrowser && ! supportedFeatures . hasCanResizeWindowToDimensions )
250+ if ( isLocalBrowser && ! hasCustomMaximizeWindow )
236251 return await this . _maximizeLocalBrowserWindow ( browserId ) ;
237252
238253 return await this . plugin . maximizeWindow ( browserId ) ;
239254 }
240255
241256 async takeScreenshot ( browserId , screenshotPath , pageWidth , pageHeight ) {
242- var isLocalBrowser = await this . plugin . isLocalBrowser ( browserId ) ;
243- var supportedFeatures = await this . plugin . hasCustomActionForBrowser ( browserId ) ;
257+ var isLocalBrowser = await this . plugin . isLocalBrowser ( browserId ) ;
258+ var customActionsInfo = await this . plugin . hasCustomActionForBrowser ( browserId ) ;
259+ var hasCustomTakeScreenshot = customActionsInfo . hasTakeScreenshot ;
244260
245- if ( isLocalBrowser && ! supportedFeatures . hasTakeScreenshot ) {
261+ if ( isLocalBrowser && ! hasCustomTakeScreenshot ) {
246262 await this . _takeLocalBrowserScreenshot ( browserId , screenshotPath , pageWidth , pageHeight ) ;
247263 return ;
248264 }
0 commit comments