Skip to content

windows/tabs API getCurrent uses focus instead of execution context #141

@planetarian

Description

@planetarian

Currently, the getCurrent methods in chrome.windows/chrome.tabs return the last focused:

// 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions