mozilla / addons

☂ Umbrella repository for Mozilla Addons ✨
Other
127 stars 41 forks source link

[Bug]: Broken Headers implementation with Manivest v3 #15133

Closed klappradla closed 2 weeks ago

klappradla commented 3 weeks ago

What happened?

When updating our browser extension from Manifest v2 to Manifest v3, I ran into an issue with the implementation of the Headers interface suddenly being broken in Firefox when running the web extension with Manifest v3.

The entries() method was suddenly returning undefined. I'm using the ky package and the following error occurred within the package's code:

TypeError: source.entries() is not iterable

The code I run is roughly like this:

const source = new globalThis.Headers({
  accept: "application/json",
  "content-type": "application/json; charset=utf-8"
});
// -> Headers { accept → "application/json", "content-type" → "application/json; charset=utf-8" }

source.entries() // -> is not iterable
Array.from(source.entries())
// -> [] empty

The code works perfectly fine when I polyfill the Headers class with this package or when I run the web extension with Manifest v2.

So it seems like a regression bug here.

What did you expect to happen?

The Headers class works perfectly fine with Manifest v2 or when I polyfill it.

For instance turning the headers into an array works fine:


const source = new globalThis.Headers({
  accept: "application/json",
  "content-type": "application/json; charset=utf-8"
});
Array.from(source.entries())
// -> [[ "accept", "application/json" ], [ "content-type", "application/json; charset=utf-8" ]]
​```

### Is there an existing issue for this?

- [X] I have searched the existing issues

┆Issue is synchronized with this [Jira Task](https://mozilla-hub.atlassian.net/browse/AMOENG-1188)
willdurand commented 2 weeks ago

I'd suggest you file a bug on Bugzilla instead: https://bugzilla.mozilla.org/enter_bug.cgi?product=WebExtensions&component=Untriaged