-
-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Currently, the getCurrent methods in chrome.windows/chrome.tabs return the last focused:
electron-browser-shell/packages/electron-chrome-extensions/src/browser/api/windows.ts
Lines 21 to 23 in 3ed5c69
| // TODO: how does getCurrent differ from getLastFocused? | |
| handle('windows.getCurrent', this.getLastFocused.bind(this)) | |
| handle('windows.getLastFocused', this.getLastFocused.bind(this)) |
However, this is what the chrome developer reference has to say about "current window":
The current window is the window that contains the code that is currently executing. It's important to realize that this can be different from the topmost or focused window.
https://developer.chrome.com/docs/extensions/reference/api/windows#the_current_window
Using the focused window/tab results in a number of things operating not as expected, as code that executes in windows/tabs other than the currently-focused one will get unexpected responses when calling getCurrent. It also causes the extension popups to sometimes get confused about which window they should appear over, etc.
In my derived project, I've reworked this by passing in the event argument down into code paths that may reference the current window, so that it can utilize event.sender, which addresses the issue in the cases I've observed. I'm not sure whether this is the 'appropriate' means of accomplishing this, though.