Invoking a Context Menu Click Synchronously


(Matthew G. Saroff) #1

I am working on an extension, and I want to invoke a color wheel from a context menu.

I was attempting to invoke this by creating an color type input box and clicking on it, but it triggers the popup blocker, because it is invoked asynchronously, as is noted here:


Pertinent quote:

Also, if a user input handler waits on a promise, then its status as a user input handler is lost. For example:

So, is there a way to invoke a function from a menu click synchronously, which, at least according to the docs, would preserve the user input status?

As an alternative, if there is a way to load a popup page from a context menu as is done from a toolbar button:

But I think that both would require a synchronous approach.


(Niklas Gollenstede) #2

You could:

  • insert your own color picker inside a closed shadow DOM (from a library)
  • use { command: '_execute_page_action', } when creating a context menu item

(Matthew G. Saroff) #3

I’m using browserAction.openPopup() to open the window, but I am looking at windows.create to make it persistent.