-
Notifications
You must be signed in to change notification settings - Fork 1.6k
The openPopup
method is undefined
in Chrome 100.0.4896.75
yet the doc says otherwise.
#2602
Comments
CC: @dotproto to confirm whether this is a documentation issue or something else. |
Experiencing the same issue in both chrome and edge. I have verified that my browsers are up to date. Please update with a timeline for when chrome.action.openPopup will be available and update the docs to reflect the current status. |
To avoid any bad surprises, I believe the |
Have you tried this in chrome? Because I still get chrome.action.onClicked.addListener((tab) => {
console.log(chrome.action.openPopup); // undefined
}); |
@nibble0101 I was wrong on my last statement. After doing some research it appears that Chrome's action.openPopup() is supposed to be more relaxed about user actions than Mozilla's browserAction.open(). Currently action.openPopup() seems to be missing from stable channel. See comment |
Okay thanks. |
this is really weird, the function is listed in the docs but it's not available yet. how is that possible? |
I made some tries with canary and it seems that second parameter (windowId) is useless. |
Just tried this again in both stable versions of Edge and Chrome. The openPopup function is still undefined. Is there any official update on this? Is this even the proper place to report such a bug? If not, please advise on where to report this so that it can be addressed. |
Same issue, anything new now? |
also having this issue... is there any other way to programmatically trigger a popup opening? |
This doesn't work in other contexts either, even if they are user-triggered, such as a listener of Chrome version: |
Just checked again a couple months later and this is still happening. Some transparency on the status of this bug would be much appreciated. |
Still present. Is there no other way? For now I open new tab with popup URL to do some actions I need. But that is not very pleasant UX |
Are there any updates here? Because this prevents me from publishing my Chrome extensions, chrome.action.openPopup() is not available in the Chrome stable (version 106.0.5249.119):
I did the test on my Manifest V3 Print Chrome extension that is already on the Chrome Web Store: I want to publish my Chrome extensions before the end of this year. |
on 7 Jun I wrote: "... it'd seem that only focused tab can open the popup ..." |
|
Still not working on stable version (107.0.5304.88) |
This is also broken for Edge 107.0.1418.42 |
Seconded. Works in Chromium Version 108.0.5359.71 but not Chrome Version 107.0.5304.110. Calling from an onMessage listener within the Service Worker:
|
@oliverdunk can you please advise ? this is a really key feature for many addons. |
I may not be able to support this feature if chrome doesn't actually support openPopup. See: GoogleChrome/developer.chrome.com#2602
Hey all 👋 Sorry for the confusion here - this API is currently only available in the dev channel. It's showing on https://developer.chrome.com/ because we automatically generate certain parts of the documentation from the features available in Chromium, and it seems like that tool doesn't yet have handling for a situation like this. I'll try to get that fixed. If you want to track work on the API in general, you can star https://crbug.com/1245093. I don't have any updates to share but we're aware this is something that's in demand and I would personally really love to see it! |
I've merged a fix so the docs are now showing the correct channel information: https://developer.chrome.com/docs/extensions/reference/action/#method-openPopup. Closing this in favour of https://crbug.com/1245093 :) |
A workaround for anyone still looking: // here we check if we are on the Google home page or not
function setPopupForTab(tab) {
if (tab.url.startsWith('https://www.google.com/')) {
chrome.action.setPopup({ tabId: tab.id, popup: 'popup.html' });
} else {
chrome.action.setPopup({ tabId: tab.id, popup: 'errorPopup.html' });
}
}
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status === 'complete') {
setPopupForTab(tab);
}
});
chrome.tabs.onActivated.addListener((activeInfo) => {
chrome.tabs.get(activeInfo.tabId, (tab) => {
setPopupForTab(tab);
});
}); |
I can help if you want. chrome.runtime.onInstalled.addListener(() => { Make sure you remove the default_popup from the action object in manifest.json else it will not work. |
Hi guys,
window.chrome.runtime.sendMessage({ type: 'OPEN_OPTIONS_PAGE' }) And self.chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if(message.type === 'OPEN_OPTIONS_PAGE'){
self.chrome.runtime.openOptionsPage().then(() => {
sendResponse('OPENED')
}).catch((e) => {
sendResponse('FAILED_TO_OPEN', e)
})
}
}) It works on other browsers too. But may change the |
The above doesn't seem to be opening the popup programmatically, it only sets it silently without opening it. Users still must actively click on the extension icon. Is there any workaround to open the extension popup programmatically at all? (without using |
Hi Luis, we recently shipped the API for policy-installed extensions, so if your extension is always installed by enterprise policy you can use |
@oliverdunk This API does not work in developer mode using unpacked loaded extensions. I assume I need Chrome from the DEV channel? |
You can use Chrome from any channel but your extension must be force installed by policy. You can use the update testing tool to do this locally: https://github.com/GoogleChromeLabs/extension-update-testing-tool |
@oliverdunk I see no information regarding the channel, only |
That is very confusing. The |
There should be a tooltip if you hover for a few seconds - unfortunately we can't add a link or reduce the delay, but hopefully that helps somewhat. I definitely appreciate that the state of this is slightly confusing - I really hope we can release this to everyone soon because that would be the best fix 🙂 |
Thanks, waiting a bit longer definitely shows some short tooltip. The commit at https://bugs.chromium.org/p/chromium/issues/detail?id=1245093#c30 mentions "enterprise-installed extensions". I was not aware of the fact, that there is some differentiation for normal endusers and enterprise users in a company. Seems this is some feature that is not available to normal users. https://chromium.googlesource.com/chromium/src/+/HEAD/docs/enterprise/policies.md What exactly does that mean? |
@DanielRuf, this is referring to the ability admins have to force-install extensions within an enterprise. An example would be the steps here: https://support.google.com/chrome/a/answer/6306504?hl=en Releasing something for policy-installed extensions is independent of any release timeline, and unfortunately there aren't any updates there at the moment. I'd love for us to release this for everyone, and I think the whole team would, but we have some open issues to address beforehand. |
Hoping to use this with context menus so I can add a context menu option to send data to the extension and open the extension. |
@justingolden21 have you had any luck implementing this with context menus? |
I use this to send data to my notes app from right click to get the current selection and page title: background script: const CONTEXT_MENU_ID = 'addToNewNote';
// Register context menu option
chrome.contextMenus.create({
title: 'Add "%s" to new note',
contexts: ['selection'],
id: CONTEXT_MENU_ID,
});
// Listen for context menu option clicked
chrome.contextMenus.onClicked.addListener(function (info, tab) {
if (info.menuItemId === CONTEXT_MENU_ID) {
// Create new tab of Chrome Notes
chrome.tabs.create(
{
url: chrome.runtime.getURL('index.html'),
active: true,
},
// Callback after creating tab to make sure it loaded before sending message
function (newTab) {
chrome.tabs.onUpdated.addListener(function (tabId) {
if (tabId !== newTab.id) return;
// If tab is loaded, send message
chrome.runtime.sendMessage({
action: 'new_note',
title: tab.title,
selection: info.selectionText,
});
});
chrome.tabs.update(newTab.id, { active: true });
}
);
}
}); script: chrome.runtime.onMessage.addListener(function (message) {
if (message.action === 'new_note') {
// my code
}
}); @alyshae hope this helps you and/or others! |
Any plans on releasing this feature to the general public? It has been more than 5 years since it was hidden under the |
waiting for this api can be public availabe |
I'm just about done with this an it should be ready for launch
I'm working on it right now
…On Thu, Dec 21, 2023, 10:18 PM sofent11 ***@***.***> wrote:
waiting for this api can be public availabe
—
Reply to this email directly, view it on GitHub
<#2602 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A4EHTGXGIJSLE7R7YJ72NV3YKUJ3PAVCNFSM5TNNMHEKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBWG4ZDKMJXHE2A>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
There aren't any updates I'm afraid. We're still tracking this internally though. |
Describe the bug
According to the documentation, the
openPopup
method should be available in Chrome 99+ but I get theUncaught TypeError: chrome.action.openPopup is not a function
error when I run the code below.Below is my
manifest.json
file.I am using
100.0.4896.75 (Official Build) (64-bit)
. Either the way I am using theopenPopup
method is incorrect or the documentation is incorrect.To Reproduce
Steps to reproduce the behavior:
MV3
background.js
Expected behavior
The extension will throw the
Uncaught TypeError: chrome.action.openPopup is not a function
error after 10s. I would have expectedopenPopup
to not beundefined
.Screenshots
N/A
Desktop (please complete the following information):
Smartphone (please complete the following information):
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: