Skip to content
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

this.parsedJSON.content_scripts.forEach is not a function #4661

Open
Rob--W opened this issue Jan 6, 2023 · 0 comments
Open

this.parsedJSON.content_scripts.forEach is not a function #4661

Rob--W opened this issue Jan 6, 2023 · 0 comments

Comments

@Rob--W
Copy link
Member

Rob--W commented Jan 6, 2023

Describe the problem and steps to reproduce it:

While looking into #4645, I noticed that the underlying issue is that one cannot make any assumptions on this.parsedJSON, other than it being JSON. There are multiple instances where this assumption is violated:

if (
this.parsedJSON.content_scripts &&
this.parsedJSON.content_scripts.length
) {
this.parsedJSON.content_scripts.forEach((scriptRule) => {

if (
this.parsedJSON.browser_action &&
this.parsedJSON.browser_action.theme_icons
) {
this.parsedJSON.browser_action.theme_icons.forEach((icon) => {

Test case, create manifest.json with the following content and run the linter on it:

{
  "content_scripts": {
    "length": true
  }
}

Similarly,

{
  "browser_action": {
    "theme_icons": true
  }
}

What happened?

TypeError: this.parsedJSON.content_scripts.forEach is not a function
TypeError: this.parsedJSON.browser_action.theme_icons.forEach is not a function

What did you expect to happen?

Validation errors for the manifest being invalid, including MANIFEST_FIELD_INVALID with message "/content_scripts" must be an array.
And for the second test case, "/browser_action/theme_icons" must be an array

┆Issue is synchronized with this Jira Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants