The current version of the patch throws if any of the script injection requests fail (e.g. permission failure).
Any script execution failure itself (e.g. invalid syntax or just a runtime error) results in a
null result with a message printed to the console.
The first behavior is somewhat problematic because the extension may receive errors despite partially successful injection.
This could potentially be resolved by checking the permissions before injecting scripts (which is what Chrome is doing), but that check can fail if the frame/document navigates elsewhere during the injection (after the check, before the actual execution).
Tentatively, I think that we should include errors in each result in the results array returned by
scripting.executeScript. An example of resolving this bug is to pass some indication of an error to the caller via the results array, whether via a (boolean) flag, or via an explicit error property (potentially just normalized to an object with a
message property, because Error instances are not really serializable).
Let's try to agree on consistent behavior with other browser vendors that implement the
scripting.executeScript API is finally introducing support for async functions (not in
tabs.executeScript though), and they're currently ignoring script errors: https://bugs.chromium.org/p/chromium/issues/detail?id=1195807#c3