Execute content script on window after popup docked

I have a background script that creates a popup window when the extension icon is clicked.

var create = browser.windows.create({
    url:popupURL,
    type:'popup',
    height:500,
    width:300,
});

On the popup window, there is a button that, when clicked, minimizes the popup window (called in the popup javascript file):

browser.windows.update(windowInfo.id,{
    state:"docked",
    focused:false
});

I then execute the content script (called in the popup javascript file):

    browser.tabs.executeScript({file: "/content_scripts/recorder.js"})
    .then(beginMessage);

But this executes the content script in the popup window. How can I execute the content script in the window that has just been focused when the popup was minimized?

By passing the selected tab ID of that other window to executeScript.

This is definitely something I overlooked. My only problem now would be getting the correct tab ID. I would like to get the ID of the tab that comes into focus when the popup is docked. When I try to do this, it grabs the ID for the popup window. Do you have any ideas about how I would be able to do this? Thanks!

I’d save the focused window ID before opening the popup and then query for the active tab in that window when doing this action.

I wonder whether it would work more smoothly to drop a panel from the extension’s toolbar button for user interaction, so focus never leaves the target tab. I guess there is a reason you want a separate window.