Conversation
| MOZ_ASSERT(JS_IsGlobalObject(global)); | ||
| MOZ_ASSERT(!JS_IsExceptionPending(cx)); | ||
|
|
||
| JSAutoRealm ar(cx, global); |
There was a problem hiding this comment.
This looks like you're modelling it off of the jsshell version, but I intend to use this to replicate https://searchfox.org/mozilla-central/rev/fcc0cfc7f5b1df957ae29f6b2ccfeb6df47b6be8/xpcom/base/CycleCollectedJSRuntime.cpp#2177 . Since AutoEntryScript is a Servo Rust type, can we make this class implement a hook for Rust code to invoke the closure instead?
There was a problem hiding this comment.
I intend to use this to replicate https://searchfox.org/mozilla-central/rev/fcc0cfc7f5b1df957ae29f6b2ccfeb6df47b6be8/xpcom/base/CycleCollectedJSRuntime.cpp#2177
can you elaborate on this? i’m not sure i follow, did you have existing plans to set up a ScriptEnvironmentPreparer for Servo?
Since AutoEntryScript is a Servo Rust type, can we make this class implement a hook for Rust code to invoke the closure instead?
yeah, that could work. would the idea be that RustEnvironmentPreparer::invoke() just passes the closure to Servo, which would enter the AutoEntryScript and call the closure?
also, what do we do with uncaught exceptions? the jsshell uses a thing called AutoReportException, but i’m not sure what the Servo counterpart is for that.
There was a problem hiding this comment.
can you elaborate on this? i’m not sure i follow, did you have existing plans to set up a ScriptEnvironmentPreparer for Servo?
I didn't know it existed until this PR, but now I want to replicate the way Gecko uses it.
yeah, that could work. would the idea be that RustEnvironmentPreparer::invoke() just passes the closure to Servo, which would enter the AutoEntryScript and call the closure
Yes.
also, what do we do with uncaught exceptions? the jsshell uses a thing called AutoReportException, but i’m not sure what the Servo counterpart is for that.
We have code that calls report_pending_exception in various places right now. Gecko uses AutoJsApi, which is another thing I want to replicate.
Signed-off-by: Delan Azabani <dazabani@igalia.com>
|
heads up: this is a lower priority for us now, since it only seems to be needed for handling uncaught exceptions in the debugger script (servo/servo#38331). |
|
That's fine. I suggest just calling report_pending_exception by hand. |
NOTE: do not merge until #597 lands