developer.chrome.com icon indicating copy to clipboard operation
developer.chrome.com copied to clipboard

The `openPopup` method is `undefined` in Chrome `100.0.4896.75` yet the doc says otherwise.

Open nibble0101 opened this issue 3 years ago • 13 comments

Describe the bug According to the documentation, the openPopup method should be available in Chrome 99+ but I get the Uncaught TypeError: chrome.action.openPopup is not a function error when I run the code below.

chrome.runtime.onInstalled.addListener(() => {
  console.log("Immediately");
  setTimeout(() => {
    console.log("After 10s");
    console.log(chrome.action.openPopup); // undefined
    chrome.action.openPopup();
  }, 10000);
});

Below is my manifest.json file.

{
    "name": "dewall",
    "description": "Removes paywall on select websites",
    "version": "1.0",
    "manifest_version": 3,
    "background": {
        "service_worker": "background.js"
    },
    "permissions": [
        "storage",
        "notifications"
    ],
    "action": {
        "default_popup": "popup.html",
        "default_icon": {
            "16": "/images/get_started16.png",
            "32": "/images/get_started32.png",
            "48": "/images/get_started48.png",
            "128": "/images/get_started128.png"
        }
    }
}

I am using 100.0.4896.75 (Official Build) (64-bit) . Either the way I am using the openPopup method is incorrect or the documentation is incorrect.

To Reproduce Steps to reproduce the behavior:

  1. Create a basic extension using MV3
  2. Add the code above in background.js

Expected behavior The extension will throw the Uncaught TypeError: chrome.action.openPopup is not a function error after 10s. I would have expected openPopup to not be undefined.

Screenshots N/A

Desktop (please complete the following information):

  • OS: Pop!_os
  • Browser: Chrome
  • Version: 100.0.4896.75 (Official Build) (64-bit)

Smartphone (please complete the following information): N/A

Additional context N/A

nibble0101 avatar Apr 14 '22 11:04 nibble0101

CC: @dotproto to confirm whether this is a documentation issue or something else.

jeffposnick avatar Apr 14 '22 13:04 jeffposnick

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.

myersgm avatar Apr 25 '22 17:04 myersgm

To avoid any bad surprises, I believe the openPopp() is only available inside of a user triggered event handler as explained here. Also MDN documentation seems to have very good explanation about Chrome API usage.

xde013 avatar Apr 27 '22 10:04 xde013

To avoid any bad surprises, I believe the openPopp() is only available inside of a user triggered event handler as explained here. Also MDN documentation seems to have very good explanation about Chrome API usage.

Have you tried this in chrome? Because I still get undefined even in chrome.action.onClicked.

chrome.action.onClicked.addListener((tab) => {
  console.log(chrome.action.openPopup); // undefined
});

nibble0101 avatar Apr 27 '22 11:04 nibble0101

@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

xde013 avatar Apr 27 '22 12:04 xde013

@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.

nibble0101 avatar Apr 27 '22 15:04 nibble0101

this is really weird, the function is listed in the docs but it's not available yet. how is that possible?

WagnerMoreira avatar Jun 02 '22 22:06 WagnerMoreira

I made some tries with canary and it seems that second parameter (windowId) is useless. it'd seem that only focused tab can open the popup

robbi73 avatar Jun 07 '22 07:06 robbi73

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.

myersgm avatar Jul 21 '22 19:07 myersgm

Same issue, anything new now?

shaokeyibb avatar Jul 27 '22 05:07 shaokeyibb

also having this issue... is there any other way to programmatically trigger a popup opening?

elijaholmos avatar Aug 15 '22 03:08 elijaholmos

This doesn't work in other contexts either, even if they are user-triggered, such as a listener of chrome.commands.onCommand

Chrome version: Version 104.0.5112.101 (Official Build) (arm64)

juancampa avatar Aug 25 '22 16:08 juancampa

Just checked again a couple months later and this is still happening.

Some transparency on the status of this bug would be much appreciated.

myersgm avatar Oct 03 '22 20:10 myersgm

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

DarkEye123 avatar Oct 22 '22 19:10 DarkEye123

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: https://chrome.google.com/webstore/detail/print-for-google-chrome/idfnpgjblkahngbondojabhffkkdekbd But my "double click" menu does not work on the Chrome stable channel, but it does work on the Chrome Dev channel.

I want to publish my Chrome extensions before the end of this year.

stefanvd avatar Oct 28 '22 09:10 stefanvd

on 7 Jun I wrote: "... it'd seem that only focused tab can open the popup ..." You have to put first the focus on the right window (no devtools windows). A good workaround could be this: chrome.tabs.getCurrent(tab => { chrome.windows.update(tab.windowId, {focused:true}, _ => chrome.action.openPopup()) })

robbi73 avatar Oct 28 '22 10:10 robbi73

chrome.action.openPopup() work in chromium browser Version 106.0.5249.91 and chrome dev Version 108.0.5343.2. but don't work on brave browser( chromium version Version 106.0.5249.103).

anilf01 avatar Nov 02 '22 17:11 anilf01

chrome.action.openPopup() work in chromium browser Version 106.0.5249.91 and chrome dev Version 108.0.5343.2. but don't work on brave browser( chromium version Version 106.0.5249.103).

Still not working on stable version (107.0.5304.88)

itskaiway avatar Nov 03 '22 06:11 itskaiway

This is also broken for Edge 107.0.1418.42

chuanqisun avatar Nov 15 '22 09:11 chuanqisun

chrome.action.openPopup() work in chromium browser Version 106.0.5249.91 and chrome dev Version 108.0.5343.2. but don't work on brave browser( chromium version Version 106.0.5249.103).

Still not working on stable version (107.0.5304.88)

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:

chrome.runtime.onMessage.addListener(
  // Open extension popup
  if (typeof chrome.action.openPopup === 'function') {
    console.log("Open the popup");
    chrome.action.openPopup({}, function() {
      console.log("Popup opened");
    });
  }
  else {
    console.log("chrome.action.openPopup() not supported");
  }
);

TomVoxsen avatar Dec 02 '22 11:12 TomVoxsen

Seeing the same issue on Chrome Version 108.0.5359.94 (Official Build) (arm64)

adeopura4 avatar Dec 06 '22 15:12 adeopura4

Same here with chrome version 107.0.5304.121. Hope google people fix this issue soon.

oxcarxierra avatar Dec 08 '22 05:12 oxcarxierra

I'm having the same issue in Chrome Version 108.0.5359.124 (Official Build) (arm64) this doesn't make sense. How could you publish documentation about something that doesn't exist?

oscarcalderonc avatar Jan 06 '23 13:01 oscarcalderonc

Is there another way to open the chrome extension other than use the extension icon? I have a project of an extension where the webpages get buttons injected that send messages that reaches background script, and then I need to open the chrome extension programmatically. This is the final piece that is missing to build this user experience flow.

oscarcalderonc avatar Jan 06 '23 14:01 oscarcalderonc

I tested all my browsers and these are my results:

Chromium: 108.0.1462.54 (Build ufficiale) (64 bit) DOESN'T WORK Chromium: 108.0.1462.76 (Build ufficiale) (64 bit) DOESN'T WORK Chromium: 108.0.5359.94 (Build ufficiale) (a 64 bit) DOESN'T WORK Chromium: 108.0.5359.95 (Build ufficiale) (a 64 bit) WORKS!!! Chromium: 108.0.5359.128 (Build ufficiale) (a 64 bit) DOESN'T WORK Chromium: 108.0.5500.0 (Build ufficiale) (a 64 bit) WORKS!!!

It'd seem the classic "too short blanket" riddle

robbi73 avatar Jan 06 '23 15:01 robbi73

@dotproto It seems it was discussed on April's public meeting. Was there an outcome for this, like updating the documentation or adding the actual functionality in a stable release?

oscarcalderonc avatar Jan 06 '23 22:01 oscarcalderonc

Seeing the same issue on Chrome Version 109.0.5414.87 (Official Build) (arm64)
on. mac m1

creasy2010 avatar Jan 18 '23 08:01 creasy2010

Is there another way to open the chrome extension other than use the extension icon? I have a project of an extension where the webpages get buttons injected that send messages that reaches background script, and then I need to open the chrome extension programmatically. This is the final piece that is missing to build this user experience flow.

Did you find any way to open up the popup?

vu0tran avatar Feb 14 '23 20:02 vu0tran

Same issue with Chrome Version 110.0.5481.77 (Official Build)

chan-kh avatar Feb 15 '23 22:02 chan-kh

@vu0tran nah, we had to descope the feature that would make use of this function. I know we can do a workaround like "painting" stuff by injecting HTML code in the webpage to show some small window but that sucks.

I mean if the documentation says something it has several consequences. We got involved in this project of building a chrome extension promising something that could be done based on what we researched and found in the documentation, to later back off with that feature.

If there's no intention of enabling such functionality then just update the documentation by removing the reference to it. Is that so difficult?

oscarcalderonc avatar Feb 16 '23 11:02 oscarcalderonc