this.parsedJSON.content_scripts.forEach is not a function
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:
https://github.com/mozilla/addons-linter/blob/e1f890216c9e8edcf51ff68bab3e57d658111fc7/src/parsers/manifestjson.js#L533-L537
https://github.com/mozilla/addons-linter/blob/e1f890216c9e8edcf51ff68bab3e57d658111fc7/src/parsers/manifestjson.js#L884-L888
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