How can I check which tab opened a (popup) window?

I came across the same problem and found the webNavigation.onCreatedNavigationTarget event that yields the source tab/frame id when a new window is opened.

Solution found from this post: Is it possible to determine a tab's opener within a Google Chrome extension?


Since you are already doing code injection this is what I would do.

Inject code to override window.open and have it window.postMessage to child window telling them who opened them. Also will need to inject code to listen to the effect of window.addEventListener('message', messageHandler) which will decided if they should window.close().

On second though I think I would just override window.open and not even open the child windows if you don't want to allow a give site to open windows.