So after some more research it turns out that we cannot process REGEX in Firefox Manifest V3 with the JS-interpreter library that we are using. The reason is explained here:
Firefox MV3 doesn’t allow ‘unsafe-eval’ or blob: for script-src. But the JS-interpreter is using Worker that uses blob which is not permitted for Firefox MV3. In fact, for evaluating regex they use some kind of vm (browser/node-server) environment. We have also not been able to find another JS library that manages to work around this restriction (yet). If anyone has a suggestion, please let us know.
Technical details aside, this means that executeScript_Sandbox works fine in Firefox except that it can not process any regular expression. If you have regular expression in your Javascript, you will get the error E501.
This macro explains it:
{
"Name": "executeScript_Sandbox_in_Firefox",
"CreationDate": "2024-5-5",
"Commands": [
{
"Command": "executeScript_Sandbox",
"Target": "var stripped = 'hello'.replace('e', 'o') \nreturn stripped",
"Value": "test",
"Description": "This works in Firefox"
},
{
"Command": "executeScript_Sandbox",
"Target": "var stripped = 'hello'.replace(/e/g, 'o') \nreturn stripped",
"Value": "test",
"Description": "This fails in Firefox with error code E501"
},
{
"Command": "echo",
"Target": "${test}",
"Value": "green",
"Description": ""
}
]
}