action openPopup weirds

97 views
Skip to first unread message

Robbi

unread,
May 6, 2022, 5:02:05 AM5/6/22
to Chromium Extensions
Hello folk,
I have not yet been able to open an extension popup using this method with the optional "windowId" parameter.
Rather, chome.action.openPopup ({'windowId': <number>}, myCallbackFunc) works fine only when invoked by the window that has the same windowId (which would make the parameter useless).
If I try to open the popup (of the same extension) on another window whose id is known, I get the error: "Unchecked runtime.lastError: Failed to open popup."
Did I miss something?

Google Assistant Cambodia

unread,
May 6, 2022, 5:26:00 AM5/6/22
to Chromium Extensions, Robbi
Why is it not open?

នៅ សុក្រ 6 ឧសភា 2022 ​ម៉ោង 4:02:05 PM UTC+7 Robbi បាន​សរសេរ៖

hrg...@gmail.com

unread,
May 6, 2022, 6:01:02 AM5/6/22
to Chromium Extensions, cambo...@gmail.com, Robbi
Did you try focusing the target window first?

Robbi

unread,
May 6, 2022, 6:21:58 AM5/6/22
to Chromium Extensions, hrg...@gmail.com, cambo...@gmail.com, Robbi
Experimenting and invoking openPopup from devtools windows docked to the respective main windows I get the same results.
I don't know how to get focus on a window (other than the current one) from inside the extension (service worker or extension page) through the APIs.
They are windows open with chrome.window.create. I have window ids, but with these ids I can't reference those windows to focus with window.focus ().

Robbi

unread,
May 6, 2022, 6:37:33 AM5/6/22
to Chromium Extensions, Robbi, hrg...@gmail.com, cambo...@gmail.com
I add a short video to make it clearer.
Thanks
2022-05-06 12-30-43.mkv

hrg...@gmail.com

unread,
May 6, 2022, 8:43:55 AM5/6/22
to Chromium Extensions, Robbi, hrg...@gmail.com, cambo...@gmail.com
Extensions can focus any other window as long as the browser is the focused application.

chrome.windows.update(windowID, {focused: true})

Robbi

unread,
May 6, 2022, 9:08:06 AM5/6/22
to Chromium Extensions, hrg...@gmail.com, Robbi, cambo...@gmail.com
Thanks, I didn't remember it could be done with windows.update.
Now either with:
chrome.windows.update (<winId>, {focused: true}, _ => {chrome.action.openPopup ({'windowId': <winId>}, _ => {console.log ('Hallo')})})
or more simply:
chrome.windows.update (<winId>, {focused: true}, _ => {chrome.action.openPopup (_ => {console.log ('Hello')})})
I've overcame the problem.

At this point the openPopup parameter has no purpose (does it?)
Thanks again

hrg...@gmail.com

unread,
May 6, 2022, 10:23:53 AM5/6/22
to Chromium Extensions, Robbi, hrg...@gmail.com, cambo...@gmail.com
Given that the parameter doesn't behave as documented, it's pretty much useless.
Reply all
Reply to author
Forward
0 new messages