-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Chrome manifest v3 APIs #329
Comments
If not - are you planning to implement the support? |
Chrome will support promises at the The polyfill invokes methods in the We'll keep this bug open, and close it once we've added integration tests. |
Is there any update on this? It seems like the extensions break with servicewoker+background script combo in manifest v3. |
@AhsanAyaz you mean |
@avalanche1 . No I mean using the background.js or any file as a service worker with webextension-polyfill doesn't work because of the |
The polyfill does not use |
I'm attempting to convert my working v2 extension to v3... but experiencing some issues. I am using In particular, since v3 consolidates Is this a problem with chrome's v3 manifest having changed or deprecated that function name? Or is this a problem with this polyfill? I can't seem to get properly updated info on the interplay between the v3 changes and this polyfill. |
Yes I'm sure I'm in manifest v3, because my other changes (including changes in the manifest, like Specifically, the error I'm getting is that |
@getify https://developer.chrome.com/docs/extensions/reference/action/ |
They didn't list throwing away In any case, I've now passed that error, and encountered a variety of others. For example, my extension (obviously) has a popup, and I used to be able to call
In any case, sorry to be rambling here... it seems that the conversion from v2 to v3 is NOT particularly straightforward the way the migration guide makes it seem. There's quite a bit of breaking change behavior where they apparently decided people didn't need (or shouldn't need) to do things that were perfectly valid/useful in v2. I don't guess that my problems right now are particularly related to this polyfill, so I don't need to keep creating noise here. Sorry! If anyone has any suggested resources on how to navigate all these breaking changes, I'd certainly love to read it. I feel like I'm flailing in the dark here, because just about everything I google search about reveals stuff about v2 and nobody seems to have much concrete answers on v3. Side note: it's annoying that Chrome is already warning (with logged errors) about manifest v2 extensions going away, but the v3 stuff we're supposed to convert to is not even fully shipped, and the docs for it are painfully lacking. Maybe I'm just in the pain because I decided to be proactive when I saw the error, and perhaps I should just sleep on this for about 6 months while more of this bakes fully. |
I came across this: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Build_a_cross_browser_extension and it seems like things are still up in the air. The note specifically mentions that the webextension-polyfill is specifically for Manifest V2. |
This is not the case. Extension pages can still use
|
Well, I wish that was the case, but... did you read this from me earlier in the thread?
So it's not (or wasn't at time of writing) in Chrome. Moreover, it's not (or wasn't at time of writing) in the MV3 docs. And when I came here with my problem, here was the first response:
So... shrugs. It's clearly in a state of confusion and flux. How am I supposed to migrate when faced with such mixed signals? |
Well, what's my reasonable workaround then? My MV2 extension sends messages from browser page to the background page, which then finds the extension popup to relay the message to. The background page (MV2) had no trouble doing that. If SW (MV3) cannot do so, how can I get these messages routed? |
The API is only available if
Read official documentation instead of relying on a comment from a random third party.
The extension page or even a content script can directly communicate with the popup, e.g. with |
This tone is almost deliberately condescending and hostile. It's like stating "the sky is blue" as if someone doesn't know that obviously, the sky is blue. Of course I have "action" declared in the manifest. I was using the equivalent of it ( As I stated above, I have other Please refrain from insulting me like I have no idea what I'm doing. I have a perfectly good and workable MV2 extension that has worked for years. Migrating to MV3 has been a horrible nightmare, and it's the fault of the developers building the changes as well as those responsible for the poor state of the "official documentation".
First off, how on earth am I supposed to know who's who? Maybe you're the "random third party" for all I know. [ Edit: these comments are off-topic ] But as I stated multiple different ways above in the thread, I HAVE READ THE DOCUMENTATION. [ Edit: these comments are off-topic ] Moreover, your dismissive and condescending tone here furthers the off-putting nature of this whole situation. [ Edit: these comments are off-topic ] |
That was not intended. I misread the error message that you pasted, and thought that the error indicated the absence of the action API in your extension, hence the question of whether "action" was declared. Secondly, I made a typo in an earlier comment. The method is
It seems that you believe that this is the place for feedback to Google, judging by your expressed frustration directed towards Google and Chrome. This is not the place for that. You are currently posting questions and complaints about Google's MV3 implementation, in the issue tracker of a library that offers a Promise-based API layer over whatever the execution environment offers. The only overlap is "MV3" as subject, but other than that your comments are off-topic. Your questions about the API would fit better on a Q&A site or a forum for extension developers.
The API references match the browsers' implementations. If something is missing or inaccurate, file a bug report in the right places: https://github.com/mdn/content for MDN (Firefox, Safari and other browsers), and https://github.com/GoogleChrome/developer.chrome.com/ for Chrome-specific docs. |
I read the docs for It is still the case that the migration guide/breaking-changes of those "official docs" does not list this "change" from That's not the fault of this polyfill, of course. So that complaint indeed belongs elsewhere. But it is nonetheless fact that bears on how this thread has unfolded.
I'm only on this thread because when I initially encountered the errors in migration, it wasn't at all clear if any/all of them might be coming from this polyfill not being MV3 compliant (the OP's topic). The fact that the issue was still open led me to believe that the question was still undecided. After a few messages exchanged here, it seemed clear that my issues likely weren't caused by the polyfill. So 2 months ago my "last" message said that I didn't want to continue creating undue noise in this repo/thread, and intended to take my support questions (and complaints) to a different channel (at some future date). It was your belated comment (with mistake/typo) contradicting earlier facts/claims that restarted the conversation and brought me back into the mix here. I'll again assert that, my intent is for THIS to be my last message here on the subject, and that my support questions and complaints will go elsewhere. Side note: the OP had asked "is this polyfill MV3 compliant?" If it is, now -- and I think so, but I'm not in a position to know for sure -- then it seems like this thread is ready to be closed with an affirmative answer to that question. That would probably help clear up any future readers of this thread being confused by the unfortunate detours.
We all make mistakes. For the record, my tone escalated to significant frustration not from the first message you posted (with the mistake/typo), but from the second reply, where you doubled down with comments I interpreted as suggesting that the fault was entirely mine for not RTFM. Moreover, I interpreted your defense of the "official" documentation, and your dismissal of another thread commenter as "random third-party", as positioning yourself instead as "official". That made your mistake/typo claims all the more infuriating. I don't have any idea who you work for, but it seemed to me like you were defending Google there, perhaps even as a Google employee might, so that's what spurred my Google-specific complaints.
Agreed. I edited my earlier comment to strikeout the parts that were off-topic complaints about Google. My apologies for the noise. |
I think that the polyfill isn't useful after MV3:
Firefox doesn't support MV3 at all at the moment so using this "Firefox polyfill" on a Chrome-only MV3 extension makes no sense. Once Firefox supports MV3, you'll just be able to load your natively-promisified "Chrome-only" Surely there will be some API discrepancies going forward, but the polyfill isn't really built with that in mind and has its own downsides/bugs. |
So, if I want to keep using "browser" namespace in my MV3 Chromium extension, I could "simplify" this polyfill to just this: if (!('browser' in self)) {
self.browser = self.chrome;
} Right? |
It looks like that the polyfill is no longer required for Manifest v3. [^1] However, for a better developer experience, we keep the TypeScript definitions and use a little workaround for the global "browser" namespace. [^1]: mozilla/webextension-polyfill#329
It looks like that the polyfill is no longer required for Manifest v3. [^1] However, for a better developer experience, we keep the TypeScript definitions and use a little workaround for the global "browser" namespace. [^1]: mozilla/webextension-polyfill#329
It looks like that the polyfill is no longer required for Manifest v3. [^1] However, for a better developer experience, we keep the TypeScript definitions and use a little workaround for the global "browser" namespace. [^1]: mozilla/webextension-polyfill#329
It looks like that the polyfill is no longer required for Manifest v3. [^1] However, for a better developer experience, we keep the TypeScript definitions and use a little workaround for the global "browser" namespace. [^1]: mozilla/webextension-polyfill#329
@Juraj-Masiar: Thanks, this helped me. I did run into an issue, though, that Chrome still doesn't support returning a promise from a message listener. Instead you have to start a promise that will call a callback, and immediately return true. See; https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage |
Remove polyfill, using `chrome.` instead. According to mozilla/webextension-polyfill#329
Is this lib compatible with Chrome manifest v3?
I haven't found any mentions in the docs.
The text was updated successfully, but these errors were encountered: