Open Bug 1556604 Opened 1 year ago Updated 2 months ago

Allow structured cloning of native error types

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

People

(Reporter: yhirano, Assigned: mjessome)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36

Steps to reproduce:

HTML Standard change: https://github.com/whatwg/html/pull/4665.
WebIDL Standard change: https://github.com/heycam/webidl/pull/732

Tests: https://github.com/web-platform-tests/wpt/pull/17095.

Type: defect → enhancement
Priority: -- → P2

Hello! I've taken the time to investigate & implement this, please see my attached diff as a first pass. I have a couple notes / questions, all feedback is appreciated!

  1. I'm not currently serializing the .stack property. I had attempted to do this as a serialized savedFrame, bu ran into issues during deserialization. Recommendations on an approach for this would be appreciated!

  2. As indicated in the spec, the Error type being serialized is selected based on prototype, so ErrorObject.value() cannot be used directly. I created GetSerializedExceptionType() to iterate through Error prototypes and convert to the corresponding JSExnType per the spec. If there's a better way to test the Error prototype than what I've done here, I'd appreciate any input -- There was no immediately obvious better way to do this.

  3. It seems to me that we can't currently create ErrorObjects without fileName, sourceId, lineNumber or columnNumber. Given this, I have interpreted the following from the spec to include those fields:

User agents should attach a serialized representation of any interesting accompanying data which are not yet specified

  1. Testing: What should be covered in jsapi tests vs "non262" vs wpt ? I had written some ad-hoc tests locally during development and left in a simple one. I'm curious what the correct approach is, considering overlap with the wpt tests?

Thank you!

Assignee: nobody → marc.jessome
Flags: needinfo?(bzbarsky)

I'll aim to look on Monday. Thank you for working on this!

I'm not currently serializing the .stack property

That's OK for now, but please file a followup on that? We should figure out how we want to do this... I do wonder whether some of the other deserialization issues I think I ran into while reviewing might have been an issue there.

If there's a better way to test the Error prototype than what I've done here, I'd appreciate any input

That's really a question for a SpiderMonkey peer. I asked Jeff to review the patch too.

Given this, I have interpreted the following from the spec to include those fields:

Yes, we should include them.

What should be covered in jsapi tests vs "non262" vs wpt ?

That's a good question. My gut feeling is that if it needs the web platform to test in general (i.e. it can't be a pure tes262 test), it should likely go in wpt. But again, this is largely a question for a SpiderMonkey peer.

Flags: needinfo?(bzbarsky)
Status: UNCONFIRMED → NEW
Ever confirmed: true

Note that we are tweaking the semantics slightly at https://github.com/whatwg/html/pull/5150. I will work on updating the web platform tests (and will edit that HTML pull request to point to them when they're available.)

You need to log in before you can comment on or make changes to this bug.