Implement document preloaded resources#39794
Conversation
dc571ee to
219f724
Compare
|
🔨 Triggering try run (#18463506639) for Linux (WPT) |
|
Test results for linux-wpt from try job (#18463506639): Flaky unexpected result (34)
Stable unexpected results that are known to be intermittent (26)
|
|
✨ Try run (#18463506639) succeeded. |
219f724 to
0a59149
Compare
| // Step 1. Wait until fetchParams’s preloaded response candidate is not "pending". | ||
| // TODO | ||
| // Step 2. Assert: fetchParams’s preloaded response candidate is a response. | ||
| // TODO |
There was a problem hiding this comment.
The reason WPT isn't passing more tests is because of this here. I don't know how we can change the structs to be able to handle this case. I think it needs a separate PreloadEntry with enum on how to store this, but I am not sure how we can pass in the fetch_params into that.
Any guidance on how I can implement this in Rust would be great. I did see .await in other parts of the codebase, so I assume that Futures are the appropriate language construct to implement this, are they not?
There was a problem hiding this comment.
Yeah, futures are probably the way to go here. One possibility would be to use a channel for preload responses, so this code could just call await on the receiver, and the code that produces the preload response would be responsible for sending the complete response object over the corresponding sender.
There was a problem hiding this comment.
Cool. I think I know already how to tackle that, so will implement that in the next PR
jdm
left a comment
There was a problem hiding this comment.
This is a really useful step forward!
| // Step 1. Wait until fetchParams’s preloaded response candidate is not "pending". | ||
| // TODO | ||
| // Step 2. Assert: fetchParams’s preloaded response candidate is a response. | ||
| // TODO |
There was a problem hiding this comment.
Yeah, futures are probably the way to go here. One possibility would be to use a channel for preload responses, so this code could just call await on the receiver, and the code that produces the preload response would be responsible for sending the complete response object over the corresponding sender.
| global: self.global.clone(), | ||
| })); | ||
| let global = self.global.root(); | ||
| let _realm = enter_realm(&*global); |
There was a problem hiding this comment.
Ah this should have been part of 9042b68#diff-7732144f217b054c2148f8efd84259dfba8526ca07db0019691d994445c5195e Previously, we would call GlobalScope::current() which would require us to enter the realm here. Now, we pass in the global as an argument, hence this isn't required anymore.
| pub struct RequestClient { | ||
| /// <https://html.spec.whatwg.org/multipage/#map-of-preloaded-resources> | ||
| #[conditional_malloc_size_of] | ||
| #[serde(skip)] // TODO: Figure out what we need to do here to serialize this map |
There was a problem hiding this comment.
Yeah. It does support serialization, but it doesn't guarantee ordering. Ordering is important per the spec, so if we were to serialize as-is, then the ordering would be broken and we would violate the spec.
That said, I don't think in the current setup we need serialization for these requests, as we don't transfer them between threads. But I don't know when we will and how to support that, given that the default serialization isn't feasible.
|
|
||
| /// <https://html.spec.whatwg.org/multipage/#traversable-navigable> | ||
| #[derive(Clone, Copy, Default, MallocSizeOf, PartialEq)] | ||
| pub struct TraversableNavigable { |
There was a problem hiding this comment.
I suspect we will want this to live somewhere else and only include a few relevant fields in the net-related data structures (particularly after the TODOs), but I'm fine with dealing with that later.
jdm
left a comment
There was a problem hiding this comment.
I'm willing to merge this with only minor changes to avoid this turning into a sprawling PR of doom.
This aligns the request object more with the specification, since the spec now has a `traversable_for_user_prompts` and a separate field for the client. Before, they were present in the same enum. In doing so, new structs are added that are all required in the new spec. Doing so, we can add support for preloaded resources in this client, which are only populated when we have an applicable Global. Since the spec moved things around a bit, it now has a dedicated method to populate the client from the request. Part of servo#35035 Signed-off-by: Tim van der Lippe <[email protected]>
0a59149 to
412d562
Compare
This aligns the request object more with the specification,
since the spec now has a
traversable_for_user_promptsanda separate field for the client. Before, they were present
in the same enum.
In doing so, new structs are added that are all required in
the new spec. With this we can add support for preloaded
resources in this client, which are only populated when
we have an applicable Global.
Since the spec moved things around a bit, it now has a
dedicated method to populate the client from the request.
Unfortunately none of the WPT preload tests pass, since
the requests are received out-of-order. The specification
requires us to wait for that to settle, but I haven't figured
out yet how to do that. Given that this PR is already quite
large, opted to do that in a follow-up.
Part of #35035