Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store cross-origin property holder objects in, e.g., proxy objects' reserved slots #28557

Open
yvt opened this issue Jul 27, 2021 · 0 comments · May be fixed by #28559
Open

Store cross-origin property holder objects in, e.g., proxy objects' reserved slots #28557

yvt opened this issue Jul 27, 2021 · 0 comments · May be fixed by #28559
Labels
A-content/script Related to the script thread

Comments

@yvt
Copy link
Sponsor Contributor

yvt commented Jul 27, 2021

Maybe-cross-origin objects have a [[CrossOriginPropertyDescriptorMap]] internal slot, which holds a weak map that stores property descriptors representing each realm's view of a particular maybe-cross-origin object's cross-origin properties. This weak map is filled on-demand by the CrossOriginGetOwnPropertyHelper operation.

In Firefox, this is realized as holder objects, which are created and filled on cross-origin property access and stored in proxy objects' reserved slots. We probably should follow this approach. Some part is already implemented by #28546 in the ensure_cross_origin_property_holder function.

@jdm jdm added the A-content/script Related to the script thread label Jul 28, 2021
yvt added a commit to yvt/rust-mozjs that referenced this issue Jul 28, 2021
We need this new slot to store cross-origin property holder objects.

<servo/servo#28557>:

> Maybe-cross-origin objects have a `[[CrossOriginPropertyDescriptor-
> Map]]` internal slot, which holds a weak map that stores property
> descriptors representing each realm's view of a particular maybe-
> cross-origin object's cross-origin properties. [...] In Firefox, this
> is realized as holder objects, which are created and filled on cross-
> origin property access and stored in proxy objects' reserved slots.
bors-servo added a commit that referenced this issue Aug 1, 2021
Implement `Location`'s custom internal methods

This PR partly resurrects #16501 and introduces the use of principals object to associate objects and Realms with origins. Using this infrastructure, this PR implements [the custom internal methods][1] of the `Location` interface, which is "maybe-cross-origin".

Unimplemented/incomplete things:

 - Other maybe-cross-origin interfaces, namely `WindowProxy` and `DissimilarWindowLocation`, aren't implemented correctly yet (causing most test cases of `tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html` to fail).
     - `WindowProxy`: #28556
 - [The "perform a security check" operation][2] and `Location`'s non-cross-origin properties' relevant `Document` origin checks aren't implemented either (not sure if they are covered by the existing tests).
 - There are a slight deviation from the standard and inefficiency in `CrossOriginGetOwnPropertyHelper`'s current implementation.
     - #28557

[1]: https://html.spec.whatwg.org/multipage/#the-location-interface
[2]: https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #16243 and make some progress in #2382

---
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___
@yvt yvt changed the title Store cross-origin property holder objects in proxy objects' reserved slots Store cross-origin property holder objects in, e.g., proxy objects' reserved slots Aug 1, 2021
@yvt yvt linked a pull request Aug 2, 2021 that will close this issue
5 tasks
bors-servo added a commit that referenced this issue May 17, 2023
Store cross-origin properties holders for maybe-cross-origin objects

This mostly follows [Firefox's][1] [approach][2] except that the holder maps are stored in DOM struct fields (e.g., `Location::holder_map`) instead of proxy internal slots. This approach provides superior type safety and maintainability (e.g., we don't have to be cautious about how each proxy internal slot index is used).

[1]: https://searchfox.org/mozilla-central/rev/072710086ddfe25aa2962c8399fefb2304e8193b/dom/bindings/Codegen.py#621-628
[2]: https://searchfox.org/mozilla-central/rev/072710086ddfe25aa2962c8399fefb2304e8193b/dom/base/MaybeCrossOriginObject.cpp#232-253

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #28557

---
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___
bors-servo added a commit that referenced this issue May 17, 2023
Store cross-origin properties holders for maybe-cross-origin objects

This mostly follows [Firefox's][1] [approach][2] except that the holder maps are stored in DOM struct fields (e.g., `Location::holder_map`) instead of proxy internal slots. This approach provides superior type safety and maintainability (e.g., we don't have to be cautious about how each proxy internal slot index is used).

[1]: https://searchfox.org/mozilla-central/rev/072710086ddfe25aa2962c8399fefb2304e8193b/dom/bindings/Codegen.py#621-628
[2]: https://searchfox.org/mozilla-central/rev/072710086ddfe25aa2962c8399fefb2304e8193b/dom/base/MaybeCrossOriginObject.cpp#232-253

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #28557

---
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/script Related to the script thread
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants