You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WebFrame#executeJavascriptInIsolatedWorld is not rejecting on error #22490
try{constr=awaitrequire('electron').webFrame.executeJavaScriptInIsolatedWorld(999,[{code: 'thisShouldProduceAnError()'}]);console.log(`executeJavaScriptInIsolatedWorld resolved with ${r}, instead of rejecting`);}catch{}
// Note: An error event in an isolated world will never be dispatched to
// a foreign world.
Fix this requires patching Chromium, and we need to be very careful to not break other things. So I prefer documenting this behavior instead of fixing it.
ScriptExecutionCallback was enhanced to detect execution failure and reject, not with the original error but nevertheless an error, which is better than a resolve. This code is common to executeJavascript and executeJavascriptInIsolatedWorld. It works for executeJavascript but not for executeJavascriptInIsolatedWorld.
The purpose of this bug is not to get the original error but to achieve the clearly intended parity, if possible, with executeJavascript.
There is nothing wrong on our code, it is Chromium that intentionally hides the error from us. Chromium checks if the script is executed in isolated world, and if it is then Chromium would return undefined as result even when the execution fails, so there is no way on our side to know if the execution failed. (For main world an empty handle would be returned for failed executions.)
The only way to fix this is to patch Chromium, but this is security related code and patch would be relatively large, I think it would be too risky.
Activity
zcbenz commentedon May 19, 2020
This is unfortunately by design in Chromium, see:
https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/pausable_script_executor.cc;l=62-72
Fix this requires patching Chromium, and we need to be very careful to not break other things. So I prefer documenting this behavior instead of fixing it.
bughit commentedon May 19, 2020
@zcbenz please take a look at @MarshallOfSound's commit 0fc172f
ScriptExecutionCallback was enhanced to detect execution failure and reject, not with the original error but nevertheless an error, which is better than a resolve. This code is common to executeJavascript and executeJavascriptInIsolatedWorld. It works for executeJavascript but not for executeJavascriptInIsolatedWorld.
The purpose of this bug is not to get the original error but to achieve the clearly intended parity, if possible, with executeJavascript.
zcbenz commentedon May 19, 2020
There is nothing wrong on our code, it is Chromium that intentionally hides the error from us. Chromium checks if the script is executed in isolated world, and if it is then Chromium would return
undefinedas result even when the execution fails, so there is no way on our side to know if the execution failed. (For main world an empty handle would be returned for failed executions.)The only way to fix this is to patch Chromium, but this is security related code and patch would be relatively large, I think it would be too risky.