Skip to content

script: Implement the WindowProxy ProxyTraps according to specification - #47632

Merged
mrobinson merged 1 commit into
servo:mainfrom
mrobinson:proxytraps
Sep 3, 2026
Merged

mrobinson merged 1 commit into
servo:mainfrom
mrobinson:proxytraps

Conversation

@mrobinson

@mrobinson mrobinson commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

This change re-implements the ProxyTraps for WindowProxy according
to the specification which says that they should always take into
account same origin concerns. In addition to fixing security and
correctness issues, this means that now there is only a single type of
WindowProxy ProxyTrap instead of two, simplifying the code.

This change exposes quite a few places that we should be inheriting
the Origin, but are not properly doing so. #47630 is an example
of a fix necessary to get more of these tests passing.

Testing: This gets many tests passing and reveal quite a few new
fails that are progressions.
Fixes: #28556.
Fixes: #44669.
Fixes: #47548.

@mrobinson
mrobinson requested a review from gterzian as a code owner August 29, 2026 17:26
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 29, 2026
@mrobinson
mrobinson force-pushed the proxytraps branch 2 times, most recently from 5f7d81a to e94aaf7 Compare August 30, 2026 10:20
descriptor.handle_mut(),
&mut is_none,
)
JS_GetOwnPropertyDescriptorById(cx, proxy, id, descriptor.handle_mut(), &mut is_none)

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.

InvokeGetOwnPropertyDescriptor assumes that the proxy is a ProxyObject, but this function is now being used for WindowProxy as well. JS_GetOwnPropertyDescriptorById doesn't make this assumption.


// Step 3. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver).
if is_platform_object_same_origin(cx, proxy) {
let window = unsafe { GetSubframeWindowProxy(cx, proxy.into(), id.into()) };

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 will clean up and optimize GetSubframeWindowProxy in a followup.

Comment on lines +62 to +65
// TODO: We do not know the origin of this new window at this point in the execution
// and we *really* don't want to use the origin of `global_to_clone_from`. The whole
// point is that this is a window with a *different* origin. Just use an opaque origin
// here which is guaranteed to never be equal to `global_to_clone_from`'s origin.

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.

This is fixing an issue revealed by the new proxy traps. A DissimilarOriginWindow shouldn't be initialized with the origin that it is dissimilar from.

Comment on lines +519 to +520
def emitsCrossOriginPropertyTable(self) -> bool:
return self.concrete and self.interface.hasCrossOriginMembers

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.

WindowProxy is not technically a cross-origin object in the same way that other ones are, but we do need access to the list of cross-origin properties.

[Replaceable, CrossOriginReadable] readonly attribute WindowProxy frames;
[Replaceable, CrossOriginReadable] readonly attribute unsigned long length;
[PutForwards=href, LegacyUnforgeable, CrossOriginReadable, CrossOriginWritable]
readonly attribute DissimilarOriginLocation location;

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.

This is simply replicating the attributes from Window.webidl.

@@ -1,3 +1,4 @@
[response-start-after-coop-bcg-switch.https.html]
expected: ERROR

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 still need to investigate this new failure, but I suspect it's revealing a false pass from before.

@TimvdLippe

Copy link
Copy Markdown
Contributor

I verified that most new test failures are fixed by #47630 That said, the implementation of windowproxy is still voodoo for me, so unfortunately I am not the appropriate reviewer here. Hopefully somebody else can review and I can read along. Basically, I can see you implemented the spec steps pretty much, but don't know the specifics of cross-origin objects to know if this has any security impact or so.

@jdm jdm left a comment

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.

This is great! Thank you for digging in here; it's good news that we could just reuse the proxyhandler infrastructure in many cases.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Sep 2, 2026
@jdm
jdm enabled auto-merge September 2, 2026 16:57
…cation

This change re-implements the `ProxyTraps` for `WindowProxy` according
to the specification which says that they should always take into
account same origin concerns. In addition to fixing security and
correctness issues, this means that now there is only a single type of
`WindowProxy` `ProxyTrap` instead of two, simplifying the code.

Signed-off-by: Martin Robinson <[email protected]>
Co-authored-by: Josh Bowman-Matthews <[email protected]>
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 2, 2026
@jdm
jdm added this pull request to the merge queue Sep 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 Sep 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 3, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Sep 3, 2026
@mrobinson
mrobinson added this pull request to the merge queue Sep 3, 2026
@servo-highfive servo-highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Sep 3, 2026
Merged via the queue into servo:main with commit dfac8fa Sep 3, 2026
114 of 123 checks passed
@mrobinson
mrobinson deleted the proxytraps branch September 3, 2026 11:17
@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 Sep 3, 2026
pull Bot pushed a commit to Patreos998/servo that referenced this pull request Sep 5, 2026
…t:srcdoc` (servo#47630)

The [specification] says that `about:blank` and `about:srcdoc` should
inherit their source origin. This means that instead of always creating
a new opaque origin in the parser for these kind of pages, we should try
harder to preserve the source origin.

[specification]:
https://html.spec.whatwg.org/multipage/#determining-the-origin

Testing: This will cause more tests to pass once servo#47632 lands.

---------

Signed-off-by: Martin Robinson <[email protected]>
Signed-off-by: Martin Robinson <[email protected]>
RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
…cation (servo#47632)

This change re-implements the `ProxyTraps` for `WindowProxy` according
to the specification which says that they should always take into
account same origin concerns. In addition to fixing security and
correctness issues, this means that now there is only a single type of
`WindowProxy` `ProxyTrap` instead of two, simplifying the code.

This change exposes quite a few places that we should be inheriting
the `Origin`, but are not properly doing so. servo#47630 is an example
of a fix necessary to get more of these tests passing.

Testing: This gets many tests passing and reveal quite a few new
fails that are progressions.
Fixes: servo#28556.
Fixes: servo#44669.
Fixes: servo#47548.

Signed-off-by: Martin Robinson <[email protected]>
Co-authored-by: Josh Bowman-Matthews <[email protected]>
RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
…t:srcdoc` (servo#47630)

The [specification] says that `about:blank` and `about:srcdoc` should
inherit their source origin. This means that instead of always creating
a new opaque origin in the parser for these kind of pages, we should try
harder to preserve the source origin.

[specification]:
https://html.spec.whatwg.org/multipage/#determining-the-origin

Testing: This will cause more tests to pass once servo#47632 lands.

---------

Signed-off-by: Martin Robinson <[email protected]>
Signed-off-by: Martin Robinson <[email protected]>
Psychpsyo pushed a commit to Psychpsyo/servo that referenced this pull request Oct 12, 2026
…cation (servo#47632)

This change re-implements the `ProxyTraps` for `WindowProxy` according
to the specification which says that they should always take into
account same origin concerns. In addition to fixing security and
correctness issues, this means that now there is only a single type of
`WindowProxy` `ProxyTrap` instead of two, simplifying the code.

This change exposes quite a few places that we should be inheriting
the `Origin`, but are not properly doing so. servo#47630 is an example
of a fix necessary to get more of these tests passing.

Testing: This gets many tests passing and reveal quite a few new
fails that are progressions.
Fixes: servo#28556.
Fixes: servo#44669.
Fixes: servo#47548.

Signed-off-by: Martin Robinson <[email protected]>
Co-authored-by: Josh Bowman-Matthews <[email protected]>
Psychpsyo pushed a commit to Psychpsyo/servo that referenced this pull request Oct 12, 2026
…t:srcdoc` (servo#47630)

The [specification] says that `about:blank` and `about:srcdoc` should
inherit their source origin. This means that instead of always creating
a new opaque origin in the parser for these kind of pages, we should try
harder to preserve the source origin.

[specification]:
https://html.spec.whatwg.org/multipage/#determining-the-origin

Testing: This will cause more tests to pass once servo#47632 lands.

---------

Signed-off-by: Martin Robinson <[email protected]>
Signed-off-by: Martin Robinson <[email protected]>
jschwe pushed a commit that referenced this pull request Nov 9, 2026
…to specification (#47632)

This change re-implements the `ProxyTraps` for `WindowProxy` according
to the specification which says that they should always take into
account same origin concerns. In addition to fixing security and
correctness issues, this means that now there is only a single type of
`WindowProxy` `ProxyTrap` instead of two, simplifying the code.

This change exposes quite a few places that we should be inheriting
the `Origin`, but are not properly doing so. #47630 is an example
of a fix necessary to get more of these tests passing.

Testing: This gets many tests passing and reveal quite a few new
fails that are progressions.
Fixes: #28556.
Fixes: #44669.
Fixes: #47548.

Signed-off-by: Martin Robinson <[email protected]>
Co-authored-by: Josh Bowman-Matthews <[email protected]>
(cherry picked from commit dfac8fa)
jschwe pushed a commit that referenced this pull request Nov 9, 2026
… and `about:srcdoc` (#47630)

The [specification] says that `about:blank` and `about:srcdoc` should
inherit their source origin. This means that instead of always creating
a new opaque origin in the parser for these kind of pages, we should try
harder to preserve the source origin.

[specification]:
https://html.spec.whatwg.org/multipage/#determining-the-origin

Testing: This will cause more tests to pass once #47632 lands.

---------

Signed-off-by: Martin Robinson <[email protected]>
Signed-off-by: Martin Robinson <[email protected]>
(cherry picked from commit fb160c4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

4 participants