marklieberman / foxygestures

Mouse gestures for Firefox
GNU General Public License v3.0
188 stars 19 forks source link

executeInBackground crashes with cryptic error if the function isn't an arrow function #380

Open Aran-Fey opened 1 year ago

Aran-Fey commented 1 year ago

So I've discovered the hard way that executeInBackground only works with arrow functions.

Consider this user script:

executeInBackground(() => console.log('hello'));

This correctly outputs "hello" to the extension console.

In contrast, these other snippets fail with very unhelpful errors:

function func(){
    console.log('hello');
}
executeInBackground(func);
// Uncaught (in promise) Error: eval(...) is undefined

executeInBackground((function(){
    console.log('hello');
}));
// Uncaught (in promise) Error: function statement requires a name