Skip to content

devtools: Implement frame scoped evaluation#42936

Merged
eerii merged 1 commit into
servo:mainfrom
atbrakhi:reference_error
Mar 3, 2026
Merged

devtools: Implement frame scoped evaluation#42936
eerii merged 1 commit into
servo:mainfrom
atbrakhi:reference_error

Conversation

@atbrakhi
Copy link
Copy Markdown
Member

@atbrakhi atbrakhi commented Mar 1, 2026

When paused at a breakpoint, hovering over local variables now shows their value. Previously eval used executeInGlobal() which could not access local scope, so hovering showed ReferenceError instead of the actual value.

frame-scope.mov

Testing: Added a new test
Fixes: Part #36027

@atbrakhi
Copy link
Copy Markdown
Member Author

atbrakhi commented Mar 1, 2026

This looks fine(screenshot from whattimeisit.io)

image

This is not ideal. Firefox does not show any value for typingElement. Servo should do the same.

image

When paused at a breakpoint, hovering over local variables now shows
their value. Previously `eval` used executeInGlobal() which could not access
local scope, so hovering showed ReferenceError instead of the actual value.

Signed-off-by: atbrakhi <[email protected]>
};

// TODO: Catch and return exception values from JS evaluation
// TODO: This should have a has_exception field
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to do what this comment said, to introduce a has_exception field in EvaluateJSReply. Introducing this resolved the reference error we see in screenshot of the previous comment.

@atbrakhi atbrakhi marked this pull request as ready for review March 3, 2026 13:18
@atbrakhi atbrakhi requested a review from gterzian as a code owner March 3, 2026 13:18
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 3, 2026
@atbrakhi atbrakhi requested a review from eerii March 3, 2026 13:21
@atbrakhi
Copy link
Copy Markdown
Member Author

atbrakhi commented Mar 3, 2026

@eerii i think this is ready for review now :)

Copy link
Copy Markdown
Member

@eerii eerii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I tested it locally :)

/// TODO: generalize this beyond the EvaluateJS message?
#[derive(Debug, Deserialize, Serialize)]
pub enum EvaluateJSReply {
pub enum EvaluateJSReplyValue {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very small nits, but maybe this can be simplified to EvaluateJSValue, or even JSValue if we are going to use it outside of eval (though that might be confused with the other JSValue).

Also, I'm not sure why clippy isn't complaining, but since all of the variants end with Value we should probably remove the suffix and have EvaluateJSValue::Void, and so on. The lint is enum_variant_names.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent lots of time on this renaming. My other option was also EvaluateJSValue but i didn't wanted to give the feel that this is all the Evaluate js value as we have a lot more then that. Hence I couldn't convince myself to rename it to EvaluateJSValue. But i will agree that i am also not a big fan of EvaluateJSReplyValue.

I think we will be touching this function more in coming weeks, how do you feel about landing it the way it is and renaming it later?...i am hoping to find something better

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is a tricky naming choice indeed. I agree that we should think about it and rename it later :)

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Mar 3, 2026
@eerii eerii added this pull request to the merge queue Mar 3, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 3, 2026
Merged via the queue into servo:main with commit 630e4b7 Mar 3, 2026
35 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 3, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Mar 3, 2026
Class name in `ObjectActor` was harcoded to `Window`, which is wrong.
This change removes the hardcoded value and replaces it with actual
class name.

**Before:**
<img width="320" height="163" alt="image"
src="https://github.com/user-attachments/assets/f94df58a-5309-4fd1-bb02-aa06dfeb32c3"
/>


**After:**
<img width="353" height="138" alt="image"
src="https://github.com/user-attachments/assets/ad129676-8c3d-48e2-a543-1447c75c40f0"
/>

Testing: Existing test passes
Fixes: part of #36027 
Depends on #42936

Signed-off-by: atbrakhi <[email protected]>
@eerii eerii mentioned this pull request Mar 4, 2026
@eerii eerii mentioned this pull request Apr 16, 2026
37 tasks
offline-ant pushed a commit to offline-ant/havi that referenced this pull request Jun 4, 2026
When paused at a breakpoint, hovering over local variables now shows
their value. Previously `eval` used `executeInGlobal()` which could not
access local scope, so hovering showed `ReferenceError` instead of the
actual value.

https://github.com/user-attachments/assets/05247b82-4e4d-422d-a428-63e46b55d55f

Testing: Added a new test
Fixes: Part servo#36027

Signed-off-by: atbrakhi <[email protected]>
offline-ant pushed a commit to offline-ant/havi that referenced this pull request Jun 4, 2026
Class name in `ObjectActor` was harcoded to `Window`, which is wrong.
This change removes the hardcoded value and replaces it with actual
class name.

**Before:**
<img width="320" height="163" alt="image"
src="https://github.com/user-attachments/assets/f94df58a-5309-4fd1-bb02-aa06dfeb32c3"
/>


**After:**
<img width="353" height="138" alt="image"
src="https://github.com/user-attachments/assets/ad129676-8c3d-48e2-a543-1447c75c40f0"
/>

Testing: Existing test passes
Fixes: part of servo#36027 
Depends on servo#42936

Signed-off-by: atbrakhi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants