Closed Bug 1155700 Opened 10 years ago Closed 8 years ago

Make built-in Map/Set visible with XRay vision

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: azasypkin, Assigned: evilpie)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(2 files, 2 obsolete files)

Currently we should use Components.utils.waiveXrays() to make Map/Set visible in privileged code, but it would be great to make it visible through XRay vision as other well known built-in types.
Yes, this would be nice. Just needs somebody to do it. CCing the two people aside from me who know how to implement XrayToJS. :-)
Blocks: XrayToJS
(In reply to Oleg Zasypkin [:azasypkin] from comment #0) > Currently we should use Components.utils.waiveXrays() to make Map/Set > visible in privileged code, but it would be great to make it visible through > XRay vision as other well known built-in types. "Should"? That sounds scary to me, how is that safe? (In reply to Bobby Holley (:bholley) from comment #1) > Yes, this would be nice. Just needs somebody to do it. CCing the two people > aside from me who know how to implement XrayToJS. :-) Unfortunately, my Q2 is already accounted for :(
(In reply to Nick Fitzgerald [:fitzgen] from comment #2) > (In reply to Oleg Zasypkin [:azasypkin] from comment #0) > > Currently we should use Components.utils.waiveXrays() to make Map/Set > > visible in privileged code, but it would be great to make it visible through > > XRay vision as other well known built-in types. > > "Should"? That sounds scary to me, how is that safe? > Well, "should" was probably too strong :) We pass Map (test generated data) from the test(web content context) to API mock (privileged context) in Marionette JS integration tests(gaia/FxOS). So in tests we can sacrifice safety for the simpler code.
Taking, aiming for Q3, possibly along with bug 1023984 but we'll see how this one goes first.
Assignee: nobody → evilpies
Attached patch Use ClassSpec for Map/Set (obsolete) — Splinter Review
My plan is to extend plain-object-prototypes.js in the future and fix some other prototypes. I am not sure exactly how useful the error message test is, and if it might actually make sense if it said something like "incompatible MapPrototype".
Attachment #8807987 - Attachment is obsolete: true
Attachment #8809750 - Flags: review?(arai.unmht)
Comment on attachment 8809750 [details] [diff] [review] Use ClassSpec for Map/Set Review of attachment 8809750 [details] [diff] [review]: ----------------------------------------------------------------- r+ with some fix in tests. ::: js/src/builtin/MapObject.cpp @@ +302,5 @@ > + nullptr, > + MapObject::staticProperties, > + MapObject::methods, > + MapObject::properties, > + nullptr, trailing `nullptr` can be omitted. @@ +1032,5 @@ > + nullptr, > + SetObject::staticProperties, > + SetObject::methods, > + SetObject::properties, > + nullptr, here too, `nullptr` can be omitted. ::: js/src/jit-test/tests/basic/plain-object-prototypes.js @@ +6,5 @@ > + Date.prototype, > +]; > + > +// if ('Promise' in this) > +// prototypes.push(Promise.prototype) This needs some comment or bug number. also this can be simply moved into `prototypes` array, since Promise always exists. @@ +13,5 @@ > + delete prototype[Symbol.toStringTag]; > + assertEq(Object.prototype.toString.call(prototype), "[object Object]"); > +} > + > +// Make sure the real class name is not exposed by Errors. Please move this test *before* removing @@toStringTag, or simply new file. @@ +28,5 @@ > +assertThrowsObjectError(() => Map.prototype.has(0)); > +assertThrowsObjectError(() => Set.prototype.has(0)); > +assertThrowsObjectError(() => WeakMap.prototype.has({})); > +assertThrowsObjectError(() => WeakSet.prototype.has({})); > +assertThrowsObjectError(() => WeakSet.prototype.has({})); \ No newline at end of file Please remove duplication and add Date.prototype.getSeconds() or something instead.
Attachment #8809750 - Flags: review?(arai.unmht) → review+
Attached patch Enable Map/Set Xrays (obsolete) — Splinter Review
Sadly because we still can't xray iterators I had to bring back that hack in test_XrayToJS. I will try to look into writing xray support iterators soon.
Bz, sorry for always making you review those, but Bobby is busy as well.
Flags: needinfo?(bzbarsky)
Comment on attachment 8810125 [details] [diff] [review] Enable Map/Set Xrays Please test all the things exposed over Xrays. I assume testXray() tests "constructor" and perhaps toString(), right? And you're testing size/get on Map and size/has on Set. But still need to test has on Map, set/delete on Map, add/delete on Set, clear/forEach on both. And if the iterator stuff actually works, test that too, please (entries, values, keys, for-of loop).
Flags: needinfo?(bzbarsky)
Sorry, that was sloppy. Values, keys and @@iterator don't work, because we don't have Xrays to Iterators.
Attachment #8810125 - Attachment is obsolete: true
Bz, review please. Thank you!
Flags: needinfo?(bzbarsky)
Comment on attachment 8811891 [details] [diff] [review] v2 Enable Map/Set Xrays r=me
Flags: needinfo?(bzbarsky)
Attachment #8811891 - Flags: review+
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: