diff --git a/components/script/dom/html/htmllinkelement.rs b/components/script/dom/html/htmllinkelement.rs index 7caf80ec499..f49b0b6c65c 100644 --- a/components/script/dom/html/htmllinkelement.rs +++ b/components/script/dom/html/htmllinkelement.rs @@ -5,25 +5,17 @@ use std::borrow::{Borrow, ToOwned}; use std::cell::Cell; use std::default::Default; -use std::str::FromStr; -use base::id::WebViewId; use dom_struct::dom_struct; use embedder_traits::EmbedderMsg; use html5ever::{LocalName, Prefix, local_name, ns}; use ipc_channel::ipc::IpcSender; use js::rust::HandleObject; -use mime::Mime; use net_traits::image_cache::{ Image, ImageCache, ImageCacheResponseMessage, ImageCacheResult, ImageLoadListener, ImageOrMetadataAvailable, ImageResponse, PendingImageId, UsePlaceholder, }; -use net_traits::mime_classifier::{MediaType, MimeClassifier}; -use net_traits::policy_container::PolicyContainer; -use net_traits::request::{ - CorsSettings, Destination, Initiator, InsecureRequestsPolicy, Referrer, RequestBuilder, - RequestId, -}; +use net_traits::request::{Destination, Initiator, RequestBuilder, RequestId}; use net_traits::{ FetchMetadata, FetchResponseListener, FetchResponseMsg, NetworkError, ReferrerPolicy, ResourceFetchTiming, ResourceTimingType, @@ -31,7 +23,8 @@ use net_traits::{ use pixels::PixelFormat; use script_bindings::root::Dom; use servo_arc::Arc; -use servo_url::{ImmutableOrigin, ServoUrl}; +use servo_url::ServoUrl; +use strum_macros::IntoStaticStr; use style::attr::AttrValue; use style::stylesheets::Stylesheet; use stylo_atoms::Atom; @@ -57,13 +50,13 @@ use crate::dom::element::{ set_cross_origin_attribute, }; use crate::dom::html::htmlelement::HTMLElement; +use crate::dom::linkprocessingoptions::LinkProcessingOptions; use crate::dom::medialist::MediaList; use crate::dom::node::{BindContext, Node, NodeTraits, UnbindContext}; use crate::dom::performanceresourcetiming::InitiatorType; use crate::dom::stylesheet::StyleSheet as DOMStyleSheet; use crate::dom::types::{EventTarget, GlobalScope}; use crate::dom::virtualmethods::VirtualMethods; -use crate::fetch::create_a_potential_cors_request; use crate::links::LinkRelations; use crate::network_listener::{PreInvoke, ResourceTimingListener, submit_timing}; use crate::script_runtime::CanGc; @@ -78,24 +71,6 @@ impl RequestGenerationId { } } -/// -struct LinkProcessingOptions { - href: String, - destination: Option, - integrity: String, - link_type: String, - cryptographic_nonce_metadata: String, - cross_origin: Option, - referrer_policy: ReferrerPolicy, - policy_container: PolicyContainer, - source_set: Option<()>, - base_url: ServoUrl, - origin: ImmutableOrigin, - insecure_requests_policy: InsecureRequestsPolicy, - has_trustworthy_ancestor_origin: bool, - // Some fields that we don't need yet are missing -} - #[dom_struct] pub(crate) struct HTMLLinkElement { htmlelement: HTMLElement, @@ -542,23 +517,24 @@ impl HTMLLinkElement { options.destination = Some(Destination::None); // Step 4. Let request be the result of creating a link request given options. - let url = options.base_url.clone(); let Some(request) = options.create_link_request(self.owner_window().webview_id()) else { // Step 5. If request is null, then return. return; }; + let url = request.url.clone(); // Step 6. Set request's initiator to "prefetch". let request = request.initiator(Initiator::Prefetch); - // (Step 7, firing load/error events is handled in the FetchResponseListener impl for PrefetchContext) + // (Step 7, firing load/error events is handled in the FetchResponseListener impl for LinkFetchContext) // Step 8. The user agent should fetch request, with processResponseConsumeBody set to processPrefetchResponse. let document = self.upcast::().owner_doc(); - let fetch_context = PrefetchContext { + let fetch_context = LinkFetchContext { url, link: Trusted::new(self), resource_timing: ResourceFetchTiming::new(ResourceTimingType::Resource), + type_: LinkFetchContextType::Prefetch, }; document.fetch_background(request, fetch_context); @@ -794,129 +770,47 @@ impl HTMLLinkElement { } /// + /// and type matching destination steps of fn handle_preload_url(&self) { // Step 1. Update the source set for el. // TODO // Step 2. Let options be the result of creating link options from el. let options = self.processing_options(); - // Step 3. Preload options, with the following steps given a response response: - // Step 3.1 If response is a network error, fire an event named error at el. - // Otherwise, fire an event named load at el. - self.preload(options); - } - - /// - fn preload(&self, options: LinkProcessingOptions) { - // Step 1. If options's type doesn't match options's destination, then return. - let type_matches_destination: bool = - HTMLLinkElement::type_matches_destination(&options.link_type, options.destination); - self.previous_type_matched.set(type_matches_destination); - if !type_matches_destination { - return; + // Steps for https://html.spec.whatwg.org/multipage/#preload + { + // Step 1. If options's type doesn't match options's destination, then return. + let type_matches_destination = options.type_matches_destination(); + self.previous_type_matched.set(type_matches_destination); + if !type_matches_destination { + return; + } } - // Step 2. If options's destination is "image" and options's source set is not null, - // then set options's href to the result of selecting an image source from options's source set. - // TODO - // Step 3. Let request be the result of creating a link request given options. - let url = options.base_url.clone(); - let Some(request) = options.create_link_request(self.owner_window().webview_id()) else { - // Step 4. If request is null, then return. + // Step 3. Preload options, with the following steps given a response response: + let Some(request) = options.preload(self.owner_window().webview_id()) else { return; }; - let document = self.upcast::().owner_doc(); - // Step 5. Let unsafeEndTime be 0. - // TODO - // Step 6. Let entry be a new preload entry whose integrity metadata is options's integrity. - // TODO - // Step 7. Let key be the result of creating a preload key given request. - // TODO - // Step 8. If options's document is "pending", then set request's initiator type to "early hint". - // TODO - // Step 9. Let controller be null. - // Step 10. Let reportTiming given a Document document be to report timing for controller - // given document's relevant global object. - // Step 11. Set controller to the result of fetching request, with processResponseConsumeBody - // set to the following steps given a response response and null, failure, or a byte sequence bodyBytes: - let fetch_context = PreloadContext { + let url = request.url.clone(); + let fetch_context = LinkFetchContext { url, link: Trusted::new(self), resource_timing: ResourceFetchTiming::new(ResourceTimingType::Resource), + type_: LinkFetchContextType::Preload, }; - document.fetch_background(request.clone(), fetch_context); - } - - /// - fn type_matches_destination(mime_type: &str, destination: Option) -> bool { - // Step 1. If type is an empty string, then return true. - if mime_type.is_empty() { - return true; - } - // Step 2. If destination is "fetch", then return true. - // - // Fetch is handled as an empty string destination in the spec: - // https://fetch.spec.whatwg.org/#concept-potential-destination-translate - let Some(destination) = destination else { - return false; - }; - if destination == Destination::None { - return true; - } - // Step 3. Let mimeTypeRecord be the result of parsing type. - let Ok(mime_type_record) = Mime::from_str(mime_type) else { - // Step 4. If mimeTypeRecord is failure, then return false. - return false; - }; - // Step 5. If mimeTypeRecord is not supported by the user agent, then return false. - // - // We currently don't check if we actually support the mime type. Only if we can classify - // it according to the spec. - let Some(mime_type) = MimeClassifier::get_media_type(&mime_type_record) else { - return false; - }; - // Step 6. If any of the following are true: - if - // destination is "audio" or "video", and mimeTypeRecord is an audio or video MIME type; - ((destination == Destination::Audio || destination == Destination::Video) && - mime_type == MediaType::AudioVideo) - // destination is a script-like destination and mimeTypeRecord is a JavaScript MIME type; - || (destination.is_script_like() && mime_type == MediaType::JavaScript) - // destination is "image" and mimeTypeRecord is an image MIME type; - || (destination == Destination::Image && mime_type == MediaType::Image) - // destination is "font" and mimeTypeRecord is a font MIME type; - || (destination == Destination::Font && mime_type == MediaType::Font) - // destination is "json" and mimeTypeRecord is a JSON MIME type; - || (destination == Destination::Json && mime_type == MediaType::Json) - // destination is "style" and mimeTypeRecord's essence is text/css; or - || (destination == Destination::Style && mime_type_record == mime::TEXT_CSS) - // destination is "track" and mimeTypeRecord's essence is text/vtt, - || (destination == Destination::Track && mime_type_record.essence_str() == "text/vtt") - { - // then return true. - return true; - } - // Step 7. Return false. - false + self.upcast::() + .owner_doc() + .fetch_background(request, fetch_context); } + /// fn fire_event_after_response(&self, response: Result) { + // Step 3.1 If response is a network error, fire an event named error at el. + // Otherwise, fire an event named load at el. if response.is_err() { self.upcast::() .fire_event(atom!("error"), CanGc::note()); } else { - // TODO(35035): Figure out why we need to queue a task for the load event. Otherwise - // the performance timing data hasn't been saved yet, which fails several preload - // WPT tests that assume that performance timing information is available when - // the load event is fired. - let this = Trusted::new(self); - self.owner_global() - .task_manager() - .performance_timeline_task_source() - .queue(task!(preload_load_event: move || { - let this = this.root(); - this - .upcast::() - .fire_event(atom!("load"), CanGc::note()); - })); + self.upcast::() + .fire_event(atom!("load"), CanGc::note()); } } } @@ -1092,54 +986,6 @@ impl HTMLLinkElementMethods for HTMLLinkElement { } } -impl LinkProcessingOptions { - /// - fn create_link_request(self, webview_id: WebViewId) -> Option { - // Step 1. Assert: options's href is not the empty string. - assert!(!self.href.is_empty()); - - // Step 2. If options's destination is null, then return null. - let destination = self.destination?; - - // Step 3. Let url be the result of encoding-parsing a URL given options's href, relative to options's base URL. - // TODO: The spec passes a base url which is incompatible with the - // "encoding-parse a URL" algorithm. - let Ok(url) = self.base_url.join(&self.href) else { - // Step 4. If url is failure, then return null. - return None; - }; - - // Step 5. Let request be the result of creating a potential-CORS request given - // url, options's destination, and options's crossorigin. - // Step 6. Set request's policy container to options's policy container. - // Step 7. Set request's integrity metadata to options's integrity. - // Step 8. Set request's cryptographic nonce metadata to options's cryptographic nonce metadata. - // Step 9. Set request's referrer policy to options's referrer policy. - // FIXME: Step 10. Set request's client to options's environment. - // FIXME: Step 11. Set request's priority to options's fetch priority. - // FIXME: Use correct referrer - let builder = create_a_potential_cors_request( - Some(webview_id), - url, - destination, - self.cross_origin, - None, - Referrer::NoReferrer, - self.insecure_requests_policy, - self.has_trustworthy_ancestor_origin, - self.policy_container, - ) - .initiator(Initiator::Link) - .origin(self.origin) - .integrity_metadata(self.integrity) - .cryptographic_nonce_metadata(self.cryptographic_nonce_metadata) - .referrer_policy(self.referrer_policy); - - // Step 12. Return request. - Some(builder) - } -} - /// fn translate_a_preload_destination(potential_destination: &str) -> Destination { match potential_destination { @@ -1239,7 +1085,21 @@ impl PreInvoke for FaviconFetchContext { } } -struct PrefetchContext { +#[derive(Clone, IntoStaticStr)] +#[strum(serialize_all = "lowercase")] +enum LinkFetchContextType { + Prefetch, + Preload, +} + +impl From for InitiatorType { + fn from(other: LinkFetchContextType) -> Self { + let name: &'static str = other.into(); + InitiatorType::LocalName(name.to_owned()) + } +} + +struct LinkFetchContext { /// The `` element that caused this prefetch operation link: Trusted, @@ -1247,9 +1107,12 @@ struct PrefetchContext { /// The url being prefetched url: ServoUrl, + + /// The type of fetching we perform, used when report timings. + type_: LinkFetchContextType, } -impl FetchResponseListener for PrefetchContext { +impl FetchResponseListener for LinkFetchContext { fn process_request_body(&mut self, _: RequestId) {} fn process_request_eof(&mut self, _: RequestId) {} @@ -1266,97 +1129,8 @@ impl FetchResponseListener for PrefetchContext { _ = chunk; } - // Step 7 of `fetch and process the linked resource` in https://html.spec.whatwg.org/multipage/#link-type-prefetch - fn process_response_eof( - &mut self, - _: RequestId, - response: Result, - ) { - if response.is_err() { - // Step 1. If response is a network error, fire an event named error at el. - self.link - .root() - .upcast::() - .fire_event(atom!("error"), CanGc::note()); - } else { - // Step 2. Otherwise, fire an event named load at el. - self.link - .root() - .upcast::() - .fire_event(atom!("load"), CanGc::note()); - } - } - - fn resource_timing_mut(&mut self) -> &mut ResourceFetchTiming { - &mut self.resource_timing - } - - fn resource_timing(&self) -> &ResourceFetchTiming { - &self.resource_timing - } - - fn submit_resource_timing(&mut self) { - submit_timing(self, CanGc::note()) - } - - fn process_csp_violations(&mut self, _request_id: RequestId, violations: Vec) { - let global = &self.resource_timing_global(); - let link = self.link.root(); - let source_position = link - .upcast::() - .compute_source_position(link.line_number as u32); - global.report_csp_violations(violations, None, Some(source_position)); - } -} - -impl ResourceTimingListener for PrefetchContext { - fn resource_timing_information(&self) -> (InitiatorType, ServoUrl) { - ( - InitiatorType::LocalName("prefetch".to_string()), - self.url.clone(), - ) - } - - fn resource_timing_global(&self) -> DomRoot { - self.link.root().upcast::().owner_doc().global() - } -} - -impl PreInvoke for PrefetchContext { - fn should_invoke(&self) -> bool { - // Prefetch requests are never aborted. - true - } -} - -struct PreloadContext { - /// The `` element that caused this preload operation - link: Trusted, - - resource_timing: ResourceFetchTiming, - - /// The url being preloaded - url: ServoUrl, -} - -impl FetchResponseListener for PreloadContext { - fn process_request_body(&mut self, _: RequestId) {} - - fn process_request_eof(&mut self, _: RequestId) {} - - fn process_response( - &mut self, - _: RequestId, - fetch_metadata: Result, - ) { - _ = fetch_metadata; - } - - fn process_response_chunk(&mut self, _: RequestId, chunk: Vec) { - _ = chunk; - } - - /// Step 3.1 of + /// Step 7 of + /// and step 3.1 of fn process_response_eof( &mut self, _: RequestId, @@ -1387,12 +1161,9 @@ impl FetchResponseListener for PreloadContext { } } -impl ResourceTimingListener for PreloadContext { +impl ResourceTimingListener for LinkFetchContext { fn resource_timing_information(&self) -> (InitiatorType, ServoUrl) { - ( - InitiatorType::LocalName(self.url.clone().into_string()), - self.url.clone(), - ) + (self.type_.clone().into(), self.url.clone()) } fn resource_timing_global(&self) -> DomRoot { @@ -1400,9 +1171,9 @@ impl ResourceTimingListener for PreloadContext { } } -impl PreInvoke for PreloadContext { +impl PreInvoke for LinkFetchContext { fn should_invoke(&self) -> bool { - // Preload requests are never aborted. + // Prefetch and preload requests are never aborted. true } } diff --git a/components/script/dom/linkprocessingoptions.rs b/components/script/dom/linkprocessingoptions.rs new file mode 100644 index 00000000000..59a409a1757 --- /dev/null +++ b/components/script/dom/linkprocessingoptions.rs @@ -0,0 +1,164 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +use std::str::FromStr; + +use base::id::WebViewId; +use mime::Mime; +use net_traits::ReferrerPolicy; +use net_traits::mime_classifier::{MediaType, MimeClassifier}; +use net_traits::policy_container::PolicyContainer; +use net_traits::request::{ + CorsSettings, Destination, Initiator, InsecureRequestsPolicy, Referrer, RequestBuilder, +}; +use servo_url::{ImmutableOrigin, ServoUrl}; + +use crate::fetch::create_a_potential_cors_request; + +/// +pub(crate) struct LinkProcessingOptions { + pub(crate) href: String, + pub(crate) destination: Option, + pub(crate) integrity: String, + pub(crate) link_type: String, + pub(crate) cryptographic_nonce_metadata: String, + pub(crate) cross_origin: Option, + pub(crate) referrer_policy: ReferrerPolicy, + pub(crate) policy_container: PolicyContainer, + pub(crate) source_set: Option<()>, + pub(crate) base_url: ServoUrl, + pub(crate) origin: ImmutableOrigin, + pub(crate) insecure_requests_policy: InsecureRequestsPolicy, + pub(crate) has_trustworthy_ancestor_origin: bool, + // Some fields that we don't need yet are missing +} + +impl LinkProcessingOptions { + /// + pub(crate) fn create_link_request(self, webview_id: WebViewId) -> Option { + // Step 1. Assert: options's href is not the empty string. + assert!(!self.href.is_empty()); + + // Step 2. If options's destination is null, then return null. + let destination = self.destination?; + + // Step 3. Let url be the result of encoding-parsing a URL given options's href, relative to options's base URL. + let Ok(url) = ServoUrl::parse_with_base(Some(&self.base_url), &self.href) else { + // Step 4. If url is failure, then return null. + return None; + }; + + // Step 5. Let request be the result of creating a potential-CORS request given + // url, options's destination, and options's crossorigin. + // Step 6. Set request's policy container to options's policy container. + // Step 7. Set request's integrity metadata to options's integrity. + // Step 8. Set request's cryptographic nonce metadata to options's cryptographic nonce metadata. + // Step 9. Set request's referrer policy to options's referrer policy. + // FIXME: Step 10. Set request's client to options's environment. + // FIXME: Step 11. Set request's priority to options's fetch priority. + // FIXME: Use correct referrer + let builder = create_a_potential_cors_request( + Some(webview_id), + url, + destination, + self.cross_origin, + None, + Referrer::NoReferrer, + self.insecure_requests_policy, + self.has_trustworthy_ancestor_origin, + self.policy_container, + ) + .initiator(Initiator::Link) + .origin(self.origin) + .integrity_metadata(self.integrity) + .cryptographic_nonce_metadata(self.cryptographic_nonce_metadata) + .referrer_policy(self.referrer_policy); + + // Step 12. Return request. + Some(builder) + } + + /// + pub(crate) fn type_matches_destination(&self) -> bool { + // Step 1. If type is an empty string, then return true. + if self.link_type.is_empty() { + return true; + } + // Step 2. If destination is "fetch", then return true. + // + // Fetch is handled as an empty string destination in the spec: + // https://fetch.spec.whatwg.org/#concept-potential-destination-translate + let Some(destination) = self.destination else { + return false; + }; + if destination == Destination::None { + return true; + } + // Step 3. Let mimeTypeRecord be the result of parsing type. + let Ok(mime_type_record) = Mime::from_str(&self.link_type) else { + // Step 4. If mimeTypeRecord is failure, then return false. + return false; + }; + // Step 5. If mimeTypeRecord is not supported by the user agent, then return false. + // + // We currently don't check if we actually support the mime type. Only if we can classify + // it according to the spec. + let Some(mime_type) = MimeClassifier::get_media_type(&mime_type_record) else { + return false; + }; + // Step 6. If any of the following are true: + if + // destination is "audio" or "video", and mimeTypeRecord is an audio or video MIME type; + ((destination == Destination::Audio || destination == Destination::Video) && + mime_type == MediaType::AudioVideo) + // destination is a script-like destination and mimeTypeRecord is a JavaScript MIME type; + || (destination.is_script_like() && mime_type == MediaType::JavaScript) + // destination is "image" and mimeTypeRecord is an image MIME type; + || (destination == Destination::Image && mime_type == MediaType::Image) + // destination is "font" and mimeTypeRecord is a font MIME type; + || (destination == Destination::Font && mime_type == MediaType::Font) + // destination is "json" and mimeTypeRecord is a JSON MIME type; + || (destination == Destination::Json && mime_type == MediaType::Json) + // destination is "style" and mimeTypeRecord's essence is text/css; or + || (destination == Destination::Style && mime_type_record == mime::TEXT_CSS) + // destination is "track" and mimeTypeRecord's essence is text/vtt, + || (destination == Destination::Track && mime_type_record.essence_str() == "text/vtt") + { + // then return true. + return true; + } + // Step 7. Return false. + false + } + + /// + pub(crate) fn preload(self, webview_id: WebViewId) -> Option { + // Step 1. If options's type doesn't match options's destination, then return. + // + // Handled by callers, since we need to check the previous destination type + assert!(self.type_matches_destination()); + // Step 2. If options's destination is "image" and options's source set is not null, + // then set options's href to the result of selecting an image source from options's source set. + // TODO + // Step 3. Let request be the result of creating a link request given options. + let Some(request) = self.create_link_request(webview_id) else { + // Step 4. If request is null, then return. + return None; + }; + // Step 5. Let unsafeEndTime be 0. + // TODO + // Step 6. Let entry be a new preload entry whose integrity metadata is options's integrity. + // TODO + // Step 7. Let key be the result of creating a preload key given request. + // TODO + // Step 8. If options's document is "pending", then set request's initiator type to "early hint". + // TODO + // Step 9. Let controller be null. + // Step 10. Let reportTiming given a Document document be to report timing for controller + // given document's relevant global object. + // Step 11. Set controller to the result of fetching request, with processResponseConsumeBody + // set to the following steps given a response response and null, failure, or a byte sequence bodyBytes: + Some(request.clone()) + } +} diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 3ea8440d836..ad93520f7b4 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -345,6 +345,7 @@ pub(crate) mod inputevent; pub(crate) mod intersectionobserver; pub(crate) mod intersectionobserverentry; pub(crate) mod keyboardevent; +pub(crate) mod linkprocessingoptions; pub(crate) mod location; pub(crate) mod mediadeviceinfo; pub(crate) mod mediadevices; diff --git a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-by-any-directive.sub.html.ini b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-by-any-directive.sub.html.ini index 816cd785fe7..951d82fc049 100644 --- a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-by-any-directive.sub.html.ini +++ b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-by-any-directive.sub.html.ini @@ -1,10 +1,6 @@ [prefetch-allowed-by-any-directive.sub.html] - expected: TIMEOUT [Prefetch should succeed when restricted by default-src but allowed by other directive] - expected: TIMEOUT - - [Prefetch should fail when restricted by default-src and different origin allowed by other directive] - expected: NOTRUN + expected: FAIL [Prefetch should succeed when restricted by default-src but origin allowed by other directive] - expected: NOTRUN + expected: FAIL diff --git a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-by-default.html.ini b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-by-default.html.ini index 8d5f47089a3..95a29b24269 100644 --- a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-by-default.html.ini +++ b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-by-default.html.ini @@ -1,4 +1,3 @@ [prefetch-allowed-by-default.html] - expected: TIMEOUT [Prefetch should succeed when allowed by default-src] - expected: TIMEOUT + expected: FAIL diff --git a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-no-default.html.ini b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-no-default.html.ini index 328cb2551c4..fbebcfb6d24 100644 --- a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-no-default.html.ini +++ b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-no-default.html.ini @@ -1,4 +1,3 @@ [prefetch-allowed-no-default.html] - expected: TIMEOUT [Prefetch should succeed when there is no default-src] - expected: TIMEOUT + expected: FAIL diff --git a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-with-conflicting-permissive-policies.html.ini b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-with-conflicting-permissive-policies.html.ini index 0919ef94aa5..d97b0a724e3 100644 --- a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-with-conflicting-permissive-policies.html.ini +++ b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-allowed-with-conflicting-permissive-policies.html.ini @@ -1,4 +1,3 @@ [prefetch-allowed-with-conflicting-permissive-policies.html] - expected: TIMEOUT [Prefetch should succeed when a directive in a policy is permissive, even if a subsequent policy overrides that.] - expected: TIMEOUT + expected: FAIL diff --git a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-blocked-by-default-multiple-policies.html.ini b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-blocked-by-default-multiple-policies.html.ini deleted file mode 100644 index f795f8c5d4b..00000000000 --- a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-blocked-by-default-multiple-policies.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[prefetch-blocked-by-default-multiple-policies.html] - expected: TIMEOUT - [Prefetch should fail when restricted by default-src] - expected: TIMEOUT diff --git a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-blocked-by-default.html.ini b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-blocked-by-default.html.ini deleted file mode 100644 index 3ee2b910a58..00000000000 --- a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-blocked-by-default.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[prefetch-blocked-by-default.html] - expected: TIMEOUT - [Prefetch should fail when restricted by default-src] - expected: TIMEOUT diff --git a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-generate-directives.html.ini b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-generate-directives.html.ini index df10ea63fd6..38162f1d822 100644 --- a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-generate-directives.html.ini +++ b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-generate-directives.html.ini @@ -1,79 +1,72 @@ [prefetch-generate-directives.html] - expected: TIMEOUT [Test that script-src enabled with everything else disabled allows prefetching] - expected: TIMEOUT + expected: FAIL [Test that script-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that img-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that img-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that connect-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that connect-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that object-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that object-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that font-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that font-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that manifest-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that manifest-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that media-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that media-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that style-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that style-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that child-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that child-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that frame-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that frame-src enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that worker-src enabled with everything else disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that worker-src enabled with default-src disabled allows prefetching] - expected: NOTRUN - - [Test that base-uri enabled with everything else disabled allows prefetching] - expected: NOTRUN - - [Test that base-uri enabled with default-src disabled allows prefetching] - expected: NOTRUN + expected: FAIL [Test that permissive script-src-elem supersedes script-src] - expected: NOTRUN + expected: FAIL [Test that permissive script-src supersedes script-src-elem] - expected: NOTRUN + expected: FAIL diff --git a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-ignores-prefetch-src.sub.html.ini b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-ignores-prefetch-src.sub.html.ini deleted file mode 100644 index 30e8ff98e77..00000000000 --- a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-ignores-prefetch-src.sub.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[prefetch-ignores-prefetch-src.sub.html] - expected: TIMEOUT - [Prefetch should fail when restricted by default-src and allowed by unsupported prefetch-src directive (prefetch-src should be ignored)] - expected: TIMEOUT diff --git a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-no-csp.html.ini b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-no-csp.html.ini index 414e4ff720e..65ef73d04bb 100644 --- a/tests/wpt/meta/content-security-policy/resource-hints/prefetch-no-csp.html.ini +++ b/tests/wpt/meta/content-security-policy/resource-hints/prefetch-no-csp.html.ini @@ -1,4 +1,3 @@ [prefetch-no-csp.html] - expected: TIMEOUT [Prefetch succeeds when no CSP] - expected: TIMEOUT + expected: FAIL diff --git a/tests/wpt/meta/preload/dynamic-adding-preload.html.ini b/tests/wpt/meta/preload/dynamic-adding-preload.html.ini deleted file mode 100644 index 0b703747277..00000000000 --- a/tests/wpt/meta/preload/dynamic-adding-preload.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[dynamic-adding-preload.html] - [Makes sure that a dynamically added preloaded resource is downloaded] - expected: FAIL diff --git a/tests/wpt/meta/preload/preload-error.sub.html.ini b/tests/wpt/meta/preload/preload-error.sub.html.ini index e99ef98bc41..d1f530471c8 100644 --- a/tests/wpt/meta/preload/preload-error.sub.html.ini +++ b/tests/wpt/meta/preload/preload-error.sub.html.ini @@ -1,4 +1,5 @@ [preload-error.sub.html] + expected: TIMEOUT [404 (image): main] expected: FAIL @@ -26,12 +27,6 @@ [CSP-error (xhr): main] expected: FAIL - [success (fetch): main] - expected: FAIL - - [404 (fetch): main] - expected: FAIL - [CORS (fetch): main] expected: FAIL @@ -55,21 +50,3 @@ [MIME-blocked-nosniff (script): main] expected: FAIL - - [success (xhr): main] - expected: FAIL - - [CORS (style): main] - expected: FAIL - - [success (style): main] - expected: FAIL - - [404 (script): main] - expected: FAIL - - [Decode-error (style): main] - expected: FAIL - - [CORS (xhr): main] - expected: FAIL diff --git a/tests/wpt/meta/preload/preload-font-crossorigin.html.ini b/tests/wpt/meta/preload/preload-font-crossorigin.html.ini index 62be525e1e6..563e3334b23 100644 --- a/tests/wpt/meta/preload/preload-font-crossorigin.html.ini +++ b/tests/wpt/meta/preload/preload-font-crossorigin.html.ini @@ -1,12 +1,6 @@ [preload-font-crossorigin.html] - [Same origin font preload with crossorigin attribute] - expected: FAIL - [Same origin font preload without crossorigin attribute] expected: FAIL - [Cross origin font preload with crossorigin attribute] - expected: FAIL - [Cross origin font preload without crossorigin attribute] expected: FAIL diff --git a/tests/wpt/meta/preload/preload-invalid-resources.html.ini b/tests/wpt/meta/preload/preload-invalid-resources.html.ini new file mode 100644 index 00000000000..43f7a6ffb1d --- /dev/null +++ b/tests/wpt/meta/preload/preload-invalid-resources.html.ini @@ -0,0 +1,3 @@ +[preload-invalid-resources.html] + [Preloading an invalid image (invalid data) should preload and not re-fetch] + expected: FAIL diff --git a/tests/wpt/meta/preload/preload-referrer-policy.html.ini b/tests/wpt/meta/preload/preload-referrer-policy.html.ini index 5060e820c0e..6d6da88ec21 100644 --- a/tests/wpt/meta/preload/preload-referrer-policy.html.ini +++ b/tests/wpt/meta/preload/preload-referrer-policy.html.ini @@ -1,11 +1,5 @@ [preload-referrer-policy.html] expected: TIMEOUT - [referrer policy ( -> , element, cross-origin)] - expected: FAIL - - [referrer policy ( -> , element, same-origin)] - expected: FAIL - [referrer policy ( -> , header, cross-origin)] expected: TIMEOUT diff --git a/tests/wpt/meta/preload/preload-resource-match.https.html.ini b/tests/wpt/meta/preload/preload-resource-match.https.html.ini index 31f9bda5354..3aa7a6995a9 100644 --- a/tests/wpt/meta/preload/preload-resource-match.https.html.ini +++ b/tests/wpt/meta/preload/preload-resource-match.https.html.ini @@ -1,47 +1,11 @@ [preload-resource-match.https.html] expected: TIMEOUT - [Loading image (no-cors) with link (anonymous) should discard the preloaded response] - expected: FAIL - - [Loading image (no-cors) with link (use-credentials) should discard the preloaded response] - expected: FAIL - - [Loading image (anonymous) with link (no-cors) should discard the preloaded response] - expected: FAIL - - [Loading image (anonymous) with link (use-credentials) should discard the preloaded response] - expected: FAIL - - [Loading image (use-credentials) with link (no-cors) should discard the preloaded response] - expected: FAIL - - [Loading image (use-credentials) with link (anonymous) should discard the preloaded response] - expected: FAIL - [Loading font (anonymous) with link (no-cors) should discard the preloaded response] expected: FAIL - [Loading font (anonymous) with link (anonymous) should reuse the preloaded response] - expected: FAIL - [Loading font (anonymous) with link (use-credentials) should discard the preloaded response] expected: FAIL - [Loading font (same-origin) with link (same-origin) should reuse the preloaded response] - expected: FAIL - - [Loading backgroundImage (no-cors) with link (anonymous) should discard the preloaded response] - expected: FAIL - - [Loading backgroundImage (no-cors) with link (use-credentials) should discard the preloaded response] - expected: FAIL - - [Loading fetch (same-origin) with link (same-origin) should reuse the preloaded response] - expected: FAIL - - [Loading fetch (no-cors) with link (no-cors) should reuse the preloaded response] - expected: FAIL - [Loading fetch (no-cors) with link (anonymous) should discard the preloaded response] expected: FAIL @@ -51,9 +15,6 @@ [Loading fetch (anonymous) with link (no-cors) should discard the preloaded response] expected: FAIL - [Loading fetch (anonymous) with link (anonymous) should reuse the preloaded response] - expected: FAIL - [Loading fetch (anonymous) with link (use-credentials) should discard the preloaded response] expected: FAIL @@ -63,53 +24,8 @@ [Loading fetch (use-credentials) with link (anonymous) should discard the preloaded response] expected: FAIL - [Loading fetch (use-credentials) with link (use-credentials) should reuse the preloaded response] - expected: FAIL - - [Loading script (no-cors) with link (anonymous) should discard the preloaded response] - expected: FAIL - - [Loading script (no-cors) with link (use-credentials) should discard the preloaded response] - expected: FAIL - - [Loading script (anonymous) with link (no-cors) should discard the preloaded response] - expected: FAIL - - [Loading script (anonymous) with link (use-credentials) should discard the preloaded response] - expected: FAIL - - [Loading script (use-credentials) with link (no-cors) should discard the preloaded response] - expected: FAIL - - [Loading script (use-credentials) with link (anonymous) should discard the preloaded response] - expected: TIMEOUT - - [Loading script (use-credentials) with link (use-credentials) should reuse the preloaded response] - expected: NOTRUN - - [Loading module (same-origin) with link (same-origin) should reuse the preloaded response] - expected: NOTRUN - - [Loading module (no-cors) with link (no-cors) should reuse the preloaded response] - expected: NOTRUN - - [Loading module (no-cors) with link (anonymous) should discard the preloaded response] - expected: NOTRUN - - [Loading module (no-cors) with link (use-credentials) should discard the preloaded response] - expected: NOTRUN - - [Loading module (anonymous) with link (no-cors) should discard the preloaded response] - expected: NOTRUN - - [Loading module (anonymous) with link (anonymous) should reuse the preloaded response] - expected: NOTRUN - - [Loading module (anonymous) with link (use-credentials) should discard the preloaded response] - expected: NOTRUN - [Loading module (use-credentials) with link (no-cors) should discard the preloaded response] - expected: NOTRUN + expected: TIMEOUT [Loading module (use-credentials) with link (anonymous) should discard the preloaded response] expected: NOTRUN @@ -146,3 +62,21 @@ [Loading style (use-credentials) with link (use-credentials) should reuse the preloaded response] expected: NOTRUN + + [Loading image (same-origin) with link (same-origin) should reuse the preloaded response] + expected: FAIL + + [Loading image (no-cors) with link (no-cors) should reuse the preloaded response] + expected: FAIL + + [Loading image (anonymous) with link (anonymous) should reuse the preloaded response] + expected: FAIL + + [Loading image (use-credentials) with link (use-credentials) should reuse the preloaded response] + expected: FAIL + + [Loading backgroundImage (no-cors) with link (no-cors) should reuse the preloaded response] + expected: FAIL + + [Loading backgroundImage (same-origin) with link (same-origin) should reuse the preloaded response] + expected: FAIL diff --git a/tests/wpt/meta/preload/preload-xhr.html.ini b/tests/wpt/meta/preload/preload-xhr.html.ini index f74aef3fb55..6c03bb5de3b 100644 --- a/tests/wpt/meta/preload/preload-xhr.html.ini +++ b/tests/wpt/meta/preload/preload-xhr.html.ini @@ -1,6 +1,3 @@ [preload-xhr.html] [Make an XHR request immediately after creating link rel=preload.] expected: FAIL - - [Make an XHR request after loading link rel=preload.] - expected: FAIL diff --git a/tests/wpt/meta/preload/single-download-preload.html.ini b/tests/wpt/meta/preload/single-download-preload.html.ini deleted file mode 100644 index d32846e882f..00000000000 --- a/tests/wpt/meta/preload/single-download-preload.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[single-download-preload.html] - [Makes sure that preloaded resources are not downloaded again when used] - expected: FAIL diff --git a/tests/wpt/meta/preload/subresource-integrity-font.html.ini b/tests/wpt/meta/preload/subresource-integrity-font.html.ini index 3affa0fd05e..45ef5f77847 100644 --- a/tests/wpt/meta/preload/subresource-integrity-font.html.ini +++ b/tests/wpt/meta/preload/subresource-integrity-font.html.ini @@ -8,21 +8,12 @@ [ Same-origin with correct sha512 hash.] expected: FAIL - [ Same-origin with empty integrity.] - expected: FAIL - - [ Same-origin with no integrity.] - expected: FAIL - [ Same-origin with incorrect hash.] expected: FAIL [ Same-origin with correct sha256 hash, options.] expected: FAIL - [ Same-origin with unknown algorithm only.] - expected: FAIL - [ Same-origin with multiple sha256 hashes, including correct.] expected: FAIL @@ -56,9 +47,6 @@ [Cross-origin, not CORS request, with incorrect sha256.] expected: FAIL - [ Cross-origin with empty integrity.] - expected: FAIL - [Cross-origin, not CORS request, with empty integrity.] expected: FAIL diff --git a/tests/wpt/meta/preload/subresource-integrity.html.ini b/tests/wpt/meta/preload/subresource-integrity.html.ini index be47ce6c6c5..d3acfa774da 100644 --- a/tests/wpt/meta/preload/subresource-integrity.html.ini +++ b/tests/wpt/meta/preload/subresource-integrity.html.ini @@ -1,40 +1,13 @@ [subresource-integrity.html] - [Same-origin script with correct sha256 hash.] - expected: FAIL - - [Same-origin script with correct sha384 hash.] - expected: FAIL - - [Same-origin script with correct sha512 hash.] - expected: FAIL - - [Same-origin script with empty integrity.] - expected: FAIL - [Same-origin script with incorrect hash.] expected: FAIL - [Same-origin script with multiple sha256 hashes, including correct.] - expected: FAIL - - [Same-origin script with multiple sha256 hashes, including unknown algorithm.] - expected: FAIL - - [Same-origin script with sha256 mismatch, sha512 match] - expected: FAIL - [Same-origin script with sha256 match, sha512 mismatch] expected: FAIL - [ script with correct hash, ACAO: *] - expected: FAIL - [ script with incorrect hash, ACAO: *] expected: FAIL - [ script with correct hash, CORS-eligible] - expected: FAIL - [ script with incorrect hash CORS-eligible] expected: FAIL @@ -47,21 +20,6 @@ [Cross-origin script, not CORS request, with hash mismatch] expected: FAIL - [Cross-origin script, empty integrity] - expected: FAIL - - [Same-origin script with correct hash, options.] - expected: FAIL - - [Same-origin script with unknown algorithm only.] - expected: FAIL - - [Same-origin script with matching digest re-uses preload with matching digest.] - expected: FAIL - - [Same-origin script with matching digest re-uses preload with matching digest and options.] - expected: FAIL - [Same-origin script with non-matching digest does not re-use preload with matching digest.] expected: FAIL @@ -86,42 +44,15 @@ [Same-origin script with non-matching digest reuses preload with no digest but fails.] expected: FAIL - [Same-origin style with correct sha256 hash.] - expected: FAIL - - [Same-origin style with correct sha384 hash.] - expected: FAIL - - [Same-origin style with correct sha512 hash.] - expected: FAIL - - [Same-origin style with empty integrity.] - expected: FAIL - [Same-origin style with incorrect hash.] expected: FAIL - [Same-origin style with multiple sha256 hashes, including correct.] - expected: FAIL - - [Same-origin style with multiple sha256 hashes, including unknown algorithm.] - expected: FAIL - - [Same-origin style with sha256 mismatch, sha512 match] - expected: FAIL - [Same-origin style with sha256 match, sha512 mismatch] expected: FAIL - [ style with correct hash, ACAO: *] - expected: FAIL - [ style with incorrect hash, ACAO: *] expected: FAIL - [ style with correct hash, CORS-eligible] - expected: FAIL - [ style with incorrect hash CORS-eligible] expected: FAIL @@ -134,21 +65,6 @@ [Cross-origin style, not CORS request, with hash mismatch] expected: FAIL - [Cross-origin style, empty integrity] - expected: FAIL - - [Same-origin style with correct hash, options.] - expected: FAIL - - [Same-origin style with unknown algorithm only.] - expected: FAIL - - [Same-origin style with matching digest re-uses preload with matching digest.] - expected: FAIL - - [Same-origin style with matching digest re-uses preload with matching digest and options.] - expected: FAIL - [Same-origin style with non-matching digest does not re-use preload with matching digest.] expected: FAIL @@ -193,3 +109,39 @@ [Cross-origin image, not CORS request, with hash mismatch] expected: FAIL + + [Same-origin image with correct sha256 hash.] + expected: FAIL + + [Same-origin image with correct sha384 hash.] + expected: FAIL + + [Same-origin image with correct sha512 hash.] + expected: FAIL + + [Same-origin image with empty integrity.] + expected: FAIL + + [Same-origin image with multiple sha256 hashes, including correct.] + expected: FAIL + + [Same-origin image with multiple sha256 hashes, including unknown algorithm.] + expected: FAIL + + [Same-origin image with sha256 mismatch, sha512 match] + expected: FAIL + + [ image with correct hash, ACAO: *] + expected: FAIL + + [ image with correct hash, CORS-eligible] + expected: FAIL + + [Cross-origin image, empty integrity] + expected: FAIL + + [Same-origin image with correct hash, options.] + expected: FAIL + + [Same-origin image with unknown algorithm only.] + expected: FAIL diff --git a/tests/wpt/meta/resource-timing/initiator-type/link.html.ini b/tests/wpt/meta/resource-timing/initiator-type/link.html.ini index ca98f47511e..babf64153ce 100644 --- a/tests/wpt/meta/resource-timing/initiator-type/link.html.ini +++ b/tests/wpt/meta/resource-timing/initiator-type/link.html.ini @@ -1,5 +1,4 @@ [link.html] - expected: TIMEOUT [The initiator type for css resources embedded in css must be 'css'] expected: FAIL @@ -15,11 +14,8 @@ [The initiator type for must be 'link'] expected: FAIL - [The initiator type for must be 'link'] - expected: TIMEOUT - [The initiator type for must be 'link'] - expected: TIMEOUT + expected: FAIL [The initiator type for module preload must be 'other'] - expected: NOTRUN + expected: FAIL