mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +01:00
servoshell: Support runtime preference manipulation (#38159)
These changes add a custom servo:preferences URL that allows modifying selected preferences at runtime. The goal of this work is to make it easy to test pages while toggling experimental web platform features, and support quickly changing the User-Agent header. Testing: Manually verified that spacex.com loads correctly after changing the user agent, and that https://polygon.io/ displays grid elements correctly and no console errors with the experimental prefs enabled. Fixes: #35862 <img width="1136" height="880" alt="Screenshot 2025-07-18 at 1 06 23 AM" src="https://github.com/user-attachments/assets/2d27c321-6ca0-43c3-a347-7bc4b55272df" /> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
c97ec1b2fb
commit
6565d982bd
13 changed files with 308 additions and 25 deletions
|
@ -514,6 +514,10 @@ impl HttpCache {
|
|||
request: &Request,
|
||||
done_chan: &mut DoneChannel,
|
||||
) -> Option<CachedResponse> {
|
||||
if pref!(network_http_cache_disabled) {
|
||||
return None;
|
||||
}
|
||||
|
||||
// TODO: generate warning headers as appropriate <https://tools.ietf.org/html/rfc7234#section-5.5>
|
||||
debug!("trying to construct cache response for {:?}", request.url());
|
||||
if request.method != Method::GET {
|
||||
|
|
|
@ -30,6 +30,13 @@ use file::FileProtocolHander;
|
|||
static FORBIDDEN_SCHEMES: [&str; 4] = ["http", "https", "chrome", "about"];
|
||||
|
||||
pub trait ProtocolHandler: Send + Sync {
|
||||
/// A list of schema-less URLs that can be resolved against this handler's
|
||||
/// scheme. These URLs will be granted access to the `navigator.servo`
|
||||
/// interface to perform privileged operations that manipulate Servo internals.
|
||||
fn privileged_paths(&self) -> &'static [&'static str] {
|
||||
&[]
|
||||
}
|
||||
|
||||
/// Triggers the load of a resource for this protocol and returns a future
|
||||
/// that will produce a Response. Even if the protocol is not backed by a
|
||||
/// http endpoint, it is recommended to a least provide:
|
||||
|
@ -132,6 +139,18 @@ impl ProtocolRegistry {
|
|||
.get(scheme)
|
||||
.is_some_and(|handler| handler.is_secure())
|
||||
}
|
||||
|
||||
pub fn privileged_urls(&self) -> Vec<ServoUrl> {
|
||||
self.handlers
|
||||
.iter()
|
||||
.flat_map(|(scheme, handler)| {
|
||||
let paths = handler.privileged_paths();
|
||||
paths
|
||||
.iter()
|
||||
.filter_map(move |path| ServoUrl::parse(&format!("{scheme}:{path}")).ok())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// Test if the URL is potentially trustworthy or the custom protocol is registered as secure
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue