How determine if the popup page is open or not?

Alternative method: extension.getViews({ type: "popup" }) will not work on mobile, because the popup is not actually a popup. As a workaround, you can set a variable (say, document.title) in the popup's document, and test its value in the background page. For instance, in your popup's HTML code:

<title>My awesome extension</title>

And in background.js:

if (document.title == "My awesome extension") {

You can use the following chrome API call from your background page fetch if the popup view is open:

var views = chrome.extension.getViews({ type: "popup" });

//views => [] //popup is closed
//views => [DOMWindow] //popup is open

If it returns an empty array then your popup is not open, if it returns an array with your popups DOMWindow object, then your popup is open.

If you have multiple popups in one plugin then you could check for the existence of some global variable in the returned DOMWindow to disambiguate.