aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/stylesheet_loader.rs
diff options
context:
space:
mode:
authormrnayak <rmuddur@gmail.com>2017-01-13 23:35:00 +0530
committermrnayak <rmuddur@gmail.com>2017-01-13 23:35:00 +0530
commit3d9e44a8c497acd52b428dd02062a9c55a2efafc (patch)
treee62450e7f88ea8152da2d0f0276c25ad5402ed66 /components/script/stylesheet_loader.rs
parentdc93a72997aefaeb04cdc058b01fdd2eb14cef8f (diff)
downloadservo-3d9e44a8c497acd52b428dd02062a9c55a2efafc.tar.gz
servo-3d9e44a8c497acd52b428dd02062a9c55a2efafc.zip
Handle crossorigin in link and refactor crossorigin handling
Implemented Step three and handled step four of obtain the resource part of 4.2.4 The link element. Link to spec : https://html.spec.whatwg.org/multipage/semantics.html#concept-link-obtain Refactored crossOrigin handling in HTMLScriptElement, HTMLImageElement
Diffstat (limited to 'components/script/stylesheet_loader.rs')
-rw-r--r--components/script/stylesheet_loader.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs
index 637f0619fc5..25b06e31de9 100644
--- a/components/script/stylesheet_loader.rs
+++ b/components/script/stylesheet_loader.rs
@@ -20,7 +20,7 @@ use hyper_serde::Serde;
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use net_traits::{FetchResponseListener, FetchMetadata, Metadata, NetworkError, ReferrerPolicy};
-use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
+use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestInit, RequestMode, Type as RequestType};
use network_listener::{NetworkListener, PreInvoke};
use parking_lot::RwLock;
use script_layout_interface::message::Msg;
@@ -196,7 +196,8 @@ impl<'a> StylesheetLoader<'a> {
}
impl<'a> StylesheetLoader<'a> {
- pub fn load(&self, source: StylesheetContextSource, integrity_metadata: String) {
+ pub fn load(&self, source: StylesheetContextSource, cors_setting: Option<CorsSettings>,
+ integrity_metadata: String) {
let url = source.url();
let document = document_from_node(self.elem);
let context = Arc::new(Mutex::new(StylesheetContext {
@@ -231,8 +232,18 @@ impl<'a> StylesheetLoader<'a> {
url: url.clone(),
type_: RequestType::Style,
destination: Destination::Style,
- credentials_mode: CredentialsMode::Include,
- use_url_credentials: true,
+ // https://html.spec.whatwg.org/multipage/#create-a-potential-cors-request
+ // Step 1
+ mode: match cors_setting {
+ Some(_) => RequestMode::CorsMode,
+ None => RequestMode::NoCors,
+ },
+ // https://html.spec.whatwg.org/multipage/#create-a-potential-cors-request
+ // Step 3-4
+ credentials_mode: match cors_setting {
+ Some(CorsSettings::Anonymous) => CredentialsMode::CredentialsSameOrigin,
+ _ => CredentialsMode::Include,
+ },
origin: document.url(),
pipeline_id: Some(self.elem.global().pipeline_id()),
referrer_url: Some(document.url()),
@@ -247,6 +258,8 @@ impl<'a> StylesheetLoader<'a> {
impl<'a> StyleStylesheetLoader for StylesheetLoader<'a> {
fn request_stylesheet(&self, import: &Arc<RwLock<ImportRule>>) {
- self.load(StylesheetContextSource::Import(import.clone()), "".to_owned())
+ //TODO (mrnayak) : Whether we should use the original loader's CORS setting?
+ //Fix this when spec has more details.
+ self.load(StylesheetContextSource::Import(import.clone()), None, "".to_owned())
}
}