servo: Merge #18981 - Merge request type and destination (from KiChjang:fold-type-destination); r=avadacatavra
authorKeith Yeung <kungfukeith11@gmail.com>
Tue, 24 Oct 2017 17:02:18 -0500
changeset 388049 718c237332ba9f7372f91ea233915ffcb3e7e486
parent 388048 841b4cc3ecce14ffe384a7bc0fa987fd5c5df3d5
child 388050 d22b8c27e4ccfcad474213c6d9789a29aa52ca4b
push id32739
push useracraciun@mozilla.com
push dateWed, 25 Oct 2017 09:29:21 +0000
treeherdermozilla-central@252a8528c5ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersavadacatavra
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #18981 - Merge request type and destination (from KiChjang:fold-type-destination); r=avadacatavra Fixes #18278. Source-Repo: https://github.com/servo/servo Source-Revision: dcd7d2fa32aa53628a9be63a2d0ea64796cd968e
servo/components/constellation/network_listener.rs
servo/components/gfx/font_cache_thread.rs
servo/components/net/fetch/methods.rs
servo/components/net/http_loader.rs
servo/components/net/websocket_loader.rs
servo/components/net_traits/request.rs
servo/components/script/dom/dedicatedworkerglobalscope.rs
servo/components/script/dom/htmlimageelement.rs
servo/components/script/dom/htmlmediaelement.rs
servo/components/script/dom/htmlscriptelement.rs
servo/components/script/dom/request.rs
servo/components/script/dom/serviceworkerglobalscope.rs
servo/components/script/dom/webidls/Request.webidl
servo/components/script/dom/workerglobalscope.rs
servo/components/script/dom/worklet.rs
servo/components/script/fetch.rs
servo/components/script/layout_image.rs
servo/components/script/stylesheet_loader.rs
servo/tests/unit/net/fetch.rs
--- a/servo/components/constellation/network_listener.rs
+++ b/servo/components/constellation/network_listener.rs
@@ -8,17 +8,17 @@
 
 use hyper::header::Location;
 use ipc_channel::ipc;
 use ipc_channel::router::ROUTER;
 use msg::constellation_msg::PipelineId;
 use net::http_loader::{set_default_accept, set_default_accept_language};
 use net_traits::{CoreResourceMsg, FetchMetadata, FetchResponseMsg};
 use net_traits::{IpcSend, NetworkError, ResourceThreads};
-use net_traits::request::{Destination, RequestInit, Type};
+use net_traits::request::{Destination, RequestInit};
 use net_traits::response::ResponseInit;
 use std::sync::mpsc::Sender;
 
 pub struct NetworkListener {
     res_init: Option<ResponseInit>,
     req_init: RequestInit,
     pipeline_id: PipelineId,
     resource_threads: ResourceThreads,
@@ -54,17 +54,17 @@ impl NetworkListener {
         };
 
         let msg = match self.res_init {
             Some(ref res_init_) => CoreResourceMsg::FetchRedirect(
                                    self.req_init.clone(),
                                    res_init_.clone(),
                                    ipc_sender),
             None => {
-                set_default_accept(Type::None, Destination::Document, &mut listener.req_init.headers);
+                set_default_accept(Destination::Document, &mut listener.req_init.headers);
                 set_default_accept_language(&mut listener.req_init.headers);
 
                 CoreResourceMsg::Fetch(
                 listener.req_init.clone(),
                 ipc_sender)
             }
         };
 
--- a/servo/components/gfx/font_cache_thread.rs
+++ b/servo/components/gfx/font_cache_thread.rs
@@ -2,17 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use app_units::Au;
 use font_template::{FontTemplate, FontTemplateDescriptor};
 use fontsan;
 use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
 use net_traits::{CoreResourceThread, FetchResponseMsg, fetch_async};
-use net_traits::request::{Destination, RequestInit, Type as RequestType};
+use net_traits::request::{Destination, RequestInit};
 use platform::font_context::FontContextHandle;
 use platform::font_list::SANS_SERIF_FONT_FAMILY;
 use platform::font_list::for_each_available_family;
 use platform::font_list::for_each_variation;
 use platform::font_list::last_resort_font_families;
 use platform::font_list::system_default_family;
 use platform::font_template::FontTemplateData;
 use servo_atoms::Atom;
@@ -232,17 +232,16 @@ impl FontCache {
                 // https://drafts.csswg.org/css-fonts/#font-fetching-requirements
                 let url = match url_source.url.url() {
                     Some(url) => url.clone(),
                     None => return,
                 };
 
                 let request = RequestInit {
                     url: url.clone(),
-                    type_: RequestType::Font,
                     destination: Destination::Font,
                     // TODO: Add a proper origin - Can't import GlobalScope from gfx
                     // We can leave origin to be set by default
                     .. RequestInit::default()
                 };
 
                 let channel_to_self = self.channel_to_self.clone();
                 let bytes = Mutex::new(Vec::new());
--- a/servo/components/net/fetch/methods.rs
+++ b/servo/components/net/fetch/methods.rs
@@ -12,18 +12,18 @@ use http_loader::{set_default_accept, se
 use hyper::{Error, Result as HyperResult};
 use hyper::header::{Accept, AcceptLanguage, AccessControlExposeHeaders, ContentLanguage, ContentType};
 use hyper::header::{Header, HeaderFormat, HeaderView, Headers, Referer as RefererHeader};
 use hyper::method::Method;
 use hyper::mime::{Mime, SubLevel, TopLevel};
 use hyper::status::StatusCode;
 use mime_guess::guess_mime_type;
 use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy};
-use net_traits::request::{CredentialsMode, Referrer, Request, RequestMode, ResponseTainting};
-use net_traits::request::{Type, Origin, Window};
+use net_traits::request::{CredentialsMode, Destination, Referrer, Request, RequestMode};
+use net_traits::request::{ResponseTainting, Origin, Window};
 use net_traits::response::{Response, ResponseBody, ResponseType};
 use servo_url::ServoUrl;
 use std::ascii::AsciiExt;
 use std::borrow::Cow;
 use std::fmt;
 use std::fs::File;
 use std::io::Read;
 use std::mem;
@@ -68,17 +68,17 @@ pub fn fetch_with_cors_cache(request: &m
 
     // Step 2.
     if request.origin == Origin::Client {
         // TODO: set request's origin to request's client's origin
         unimplemented!()
     }
 
     // Step 3.
-    set_default_accept(request.type_, request.destination, &mut request.headers);
+    set_default_accept(request.destination, &mut request.headers);
 
     // Step 4.
     set_default_accept_language(&mut request.headers);
 
     // Step 5.
     // TODO: figure out what a Priority object is.
 
     // Step 6.
@@ -261,19 +261,19 @@ pub fn main_fetch(request: &mut Request,
     } else {
         response
     };
 
     let internal_error = {
         // Tests for steps 17 and 18, before step 15 for borrowing concerns.
         let response_is_network_error = response.is_network_error();
         let should_replace_with_nosniff_error =
-            !response_is_network_error && should_be_blocked_due_to_nosniff(request.type_, &response.headers);
+            !response_is_network_error && should_be_blocked_due_to_nosniff(request.destination, &response.headers);
         let should_replace_with_mime_type_error =
-            !response_is_network_error && should_be_blocked_due_to_mime_type(request.type_, &response.headers);
+            !response_is_network_error && should_be_blocked_due_to_mime_type(request.destination, &response.headers);
 
         // Step 15.
         let mut network_error_response = response.get_network_error().cloned().map(Response::network_error);
         let internal_response = if let Some(error_response) = network_error_response.as_mut() {
             error_response
         } else {
             response.actual_response_mut()
         };
@@ -524,17 +524,17 @@ fn is_null_body_status(status: &Option<S
                 StatusCode::ResetContent | StatusCode::NotModified => true,
             _ => false
         },
         _ => false
     }
 }
 
 /// <https://fetch.spec.whatwg.org/#should-response-to-request-be-blocked-due-to-nosniff?>
-pub fn should_be_blocked_due_to_nosniff(request_type: Type, response_headers: &Headers) -> bool {
+pub fn should_be_blocked_due_to_nosniff(destination: Destination, response_headers: &Headers) -> bool {
     /// <https://fetch.spec.whatwg.org/#x-content-type-options-header>
     /// This is needed to parse `X-Content-Type-Options` according to spec,
     /// which requires that we inspect only the first value.
     ///
     /// A [unit-like struct](https://doc.rust-lang.org/book/structs.html#unit-like-structs)
     /// is sufficient since a valid header implies that we use `nosniff`.
     #[derive(Clone, Copy, Debug)]
     struct XContentTypeOptions;
@@ -594,47 +594,47 @@ pub fn should_be_blocked_due_to_nosniff(
             mime!(Text / ("x-javascript")),
         ];
 
         javascript_mime_types.iter()
             .any(|mime| mime.0 == mime_type.0 && mime.1 == mime_type.1)
     }
 
     // Assumes str::starts_with is equivalent to mime::TopLevel
-    return match request_type {
+    match content_type_header {
         // Step 6
-        Type::Script => {
-            match content_type_header {
-                Some(&ContentType(ref mime_type)) => !is_javascript_mime_type(&mime_type),
-                None => true
-            }
-        }
+        Some(&ContentType(ref mime_type)) if destination.is_script_like()
+            => !is_javascript_mime_type(mime_type),
+
         // Step 7
-        Type::Style => {
-            match content_type_header {
-                Some(&ContentType(Mime(TopLevel::Text, SubLevel::Css, _))) => false,
-                _ => true
-            }
-        }
+        Some(&ContentType(Mime(ref tl, ref sl, _))) if destination == Destination::Style
+            => *tl != TopLevel::Text && *sl != SubLevel::Css,
+
+        None if destination == Destination::Style || destination.is_script_like() => true,
         // Step 8
         _ => false
-    };
+    }
 }
 
 /// <https://fetch.spec.whatwg.org/#should-response-to-request-be-blocked-due-to-mime-type?>
-fn should_be_blocked_due_to_mime_type(request_type: Type, response_headers: &Headers) -> bool {
+fn should_be_blocked_due_to_mime_type(destination: Destination, response_headers: &Headers) -> bool {
+    // Step 1
     let mime_type = match response_headers.get::<ContentType>() {
         Some(header) => header,
         None => return false,
     };
-    request_type == Type::Script && match *mime_type {
+
+    // Step 2-3
+    destination.is_script_like() && match *mime_type {
         ContentType(Mime(TopLevel::Audio, _, _)) |
         ContentType(Mime(TopLevel::Video, _, _)) |
         ContentType(Mime(TopLevel::Image, _, _)) => true,
         ContentType(Mime(TopLevel::Text, SubLevel::Ext(ref ext), _)) => ext == "csv",
+
+        // Step 4
         _ => false,
     }
 }
 
 /// <https://fetch.spec.whatwg.org/#block-bad-port>
 pub fn should_be_blocked_due_to_bad_port(url: &ServoUrl) -> bool {
     // Step 1 is not applicable, this function just takes the URL directly.
 
--- a/servo/components/net/http_loader.rs
+++ b/servo/components/net/http_loader.rs
@@ -30,17 +30,17 @@ use hyper::method::Method;
 use hyper::status::StatusCode;
 use hyper_openssl::OpensslClient;
 use hyper_serde::Serde;
 use log;
 use msg::constellation_msg::PipelineId;
 use net_traits::{CookieSource, FetchMetadata, NetworkError, ReferrerPolicy};
 use net_traits::request::{CacheMode, CredentialsMode, Destination, Origin};
 use net_traits::request::{RedirectMode, Referrer, Request, RequestMode};
-use net_traits::request::{ResponseTainting, ServiceWorkersMode, Type};
+use net_traits::request::{ResponseTainting, ServiceWorkersMode};
 use net_traits::response::{HttpsState, Response, ResponseBody, ResponseType};
 use resource_thread::AuthCache;
 use servo_url::{ImmutableOrigin, ServoUrl};
 use std::ascii::AsciiExt;
 use std::collections::HashSet;
 use std::error::Error;
 use std::io::{self, Read, Write};
 use std::iter::FromIterator;
@@ -117,41 +117,41 @@ impl WrappedHttpResponse {
             Some(Encoding::EncodingExt("br".to_owned()))
         } else {
             None
         }
     }
 }
 
 // Step 3 of https://fetch.spec.whatwg.org/#concept-fetch.
-pub fn set_default_accept(type_: Type, destination: Destination, headers: &mut Headers) {
+pub fn set_default_accept(destination: Destination, headers: &mut Headers) {
     if headers.has::<Accept>() {
         return;
     }
-    let value = match (type_, destination) {
+    let value = match destination {
         // Step 3.2.
-        (_, Destination::Document) => {
+        Destination::Document => {
             vec![
                 qitem(mime!(Text / Html)),
                 qitem(mime!(Application / ("xhtml+xml"))),
                 QualityItem::new(mime!(Application / Xml), q(0.9)),
                 QualityItem::new(mime!(_ / _), q(0.8)),
             ]
         },
         // Step 3.3.
-        (Type::Image, _) => {
+        Destination::Image => {
             vec![
                 qitem(mime!(Image / Png)),
                 qitem(mime!(Image / ("svg+xml") )),
                 QualityItem::new(mime!(Image / _), q(0.8)),
                 QualityItem::new(mime!(_ / _), q(0.5)),
             ]
         },
         // Step 3.3.
-        (Type::Style, _) => {
+        Destination::Style => {
             vec![
                 qitem(mime!(Text / Css)),
                 QualityItem::new(mime!(_ / _), q(0.1))
             ]
         },
         // Step 3.1.
         _ => {
             vec![qitem(mime!(_ / _))]
@@ -1196,17 +1196,16 @@ fn http_network_fetch(request: &Request,
 fn cors_preflight_fetch(request: &Request,
                         cache: &mut CorsCache,
                         context: &FetchContext)
                         -> Response {
     // Step 1
     let mut preflight = Request::new(request.current_url(), Some(request.origin.clone()), request.pipeline_id);
     preflight.method = Method::Options;
     preflight.initiator = request.initiator.clone();
-    preflight.type_ = request.type_.clone();
     preflight.destination = request.destination.clone();
     preflight.origin = request.origin.clone();
     preflight.referrer = request.referrer.clone();
     preflight.referrer_policy = request.referrer_policy;
 
     // Step 2
     preflight.headers.set::<AccessControlRequestMethod>(
         AccessControlRequestMethod(request.method.clone()));
--- a/servo/components/net/websocket_loader.rs
+++ b/servo/components/net/websocket_loader.rs
@@ -12,17 +12,17 @@ use hyper::header::{CacheControl, CacheD
 use hyper::header::{Headers, Host, SetCookie, Pragma, Protocol, ProtocolName, Upgrade};
 use hyper::http::h1::{LINE_ENDING, parse_response};
 use hyper::method::Method;
 use hyper::net::HttpStream;
 use hyper::status::StatusCode;
 use hyper::version::HttpVersion;
 use net_traits::{CookieSource, MessageData, NetworkError, WebSocketCommunicate, WebSocketConnectData};
 use net_traits::{WebSocketDomAction, WebSocketNetworkEvent};
-use net_traits::request::{Destination, Type};
+use net_traits::request::Destination;
 use servo_url::ServoUrl;
 use std::ascii::AsciiExt;
 use std::io::{self, Write};
 use std::net::TcpStream;
 use std::sync::{Arc, Mutex};
 use std::sync::atomic::{AtomicBool, Ordering};
 use std::thread;
 use url::Position;
@@ -275,17 +275,17 @@ fn fetch(url: ServoUrl,
          -> Result<Response, NetworkError> {
     // Step 1.
     // TODO: handle request's window.
 
     // Step 2.
     // TODO: handle request's origin.
 
     // Step 3.
-    set_default_accept(Type::None, Destination::None, &mut headers);
+    set_default_accept(Destination::None, &mut headers);
 
     // Step 4.
     set_default_accept_language(&mut headers);
 
     // Step 5.
     // TODO: handle request's priority.
 
     // Step 6.
@@ -365,17 +365,17 @@ fn main_fetch(url: ServoUrl,
     // Steps 15-16.
     // Not applicable: no need to maintain an internal response.
 
     // Step 17.
     if response.is_ok() {
         // TODO: handle blocking as mixed content.
         // TODO: handle blocking by content security policy.
         // Not applicable: blocking due to MIME type matters only for scripts.
-        if should_be_blocked_due_to_nosniff(Type::None, &headers) {
+        if should_be_blocked_due_to_nosniff(Destination::None, &headers) {
             response = Err(NetworkError::Internal("Request should be blocked due to nosniff.".into()));
         }
     }
 
     // Step 18.
     // Not applicable: we don't care about the body at all.
 
     // Step 19.
--- a/servo/components/net_traits/request.rs
+++ b/servo/components/net_traits/request.rs
@@ -14,47 +14,47 @@ use std::default::Default;
 pub enum Initiator {
     None,
     Download,
     ImageSet,
     Manifest,
     XSLT,
 }
 
-/// A request [type](https://fetch.spec.whatwg.org/#concept-request-type)
-#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
-pub enum Type {
-    None,
-    Audio,
-    Font,
-    Image,
-    Script,
-    Style,
-    Track,
-    Video,
-}
-
 /// A request [destination](https://fetch.spec.whatwg.org/#concept-request-destination)
 #[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
 pub enum Destination {
     None,
+    Audio,
     Document,
     Embed,
     Font,
     Image,
     Manifest,
-    Media,
     Object,
     Report,
     Script,
     ServiceWorker,
     SharedWorker,
     Style,
+    Track,
+    Video,
     Worker,
-    XSLT,
+    Xslt,
+}
+
+impl Destination {
+    /// https://fetch.spec.whatwg.org/#request-destination-script-like
+    #[inline]
+    pub fn is_script_like(&self) -> bool {
+        *self == Destination::Script ||
+        *self == Destination::ServiceWorker ||
+        *self == Destination::SharedWorker ||
+        *self == Destination::Worker
+    }
 }
 
 /// A request [origin](https://fetch.spec.whatwg.org/#concept-request-origin)
 #[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
 pub enum Origin {
     Client,
     Origin(ImmutableOrigin),
 }
@@ -145,17 +145,16 @@ pub struct RequestInit {
     #[serde(deserialize_with = "::hyper_serde::deserialize",
             serialize_with = "::hyper_serde::serialize")]
     #[ignore_malloc_size_of = "Defined in hyper"]
     pub headers: Headers,
     pub unsafe_request: bool,
     pub body: Option<Vec<u8>>,
     pub service_workers_mode: ServiceWorkersMode,
     // TODO: client object
-    pub type_: Type,
     pub destination: Destination,
     pub synchronous: bool,
     pub mode: RequestMode,
     pub cache_mode: CacheMode,
     pub use_cors_preflight: bool,
     pub credentials_mode: CredentialsMode,
     pub use_url_credentials: bool,
     pub origin: ImmutableOrigin,
@@ -173,17 +172,16 @@ impl Default for RequestInit {
     fn default() -> RequestInit {
         RequestInit {
             method: Method::Get,
             url: ServoUrl::parse("about:blank").unwrap(),
             headers: Headers::new(),
             unsafe_request: false,
             body: None,
             service_workers_mode: ServiceWorkersMode::All,
-            type_: Type::None,
             destination: Destination::None,
             synchronous: false,
             mode: RequestMode::NoCors,
             cache_mode: CacheMode::Default,
             use_cors_preflight: false,
             credentials_mode: CredentialsMode::Omit,
             use_url_credentials: false,
             origin: ImmutableOrigin::new_opaque(),
@@ -219,18 +217,16 @@ pub struct Request {
     pub window: Window,
     // TODO: target browsing context
     /// <https://fetch.spec.whatwg.org/#request-keepalive-flag>
     pub keep_alive: bool,
     /// <https://fetch.spec.whatwg.org/#request-service-workers-mode>
     pub service_workers_mode: ServiceWorkersMode,
     /// <https://fetch.spec.whatwg.org/#concept-request-initiator>
     pub initiator: Initiator,
-    /// <https://fetch.spec.whatwg.org/#concept-request-type>
-    pub type_: Type,
     /// <https://fetch.spec.whatwg.org/#concept-request-destination>
     pub destination: Destination,
     // TODO: priority object
     /// <https://fetch.spec.whatwg.org/#concept-request-origin>
     pub origin: Origin,
     /// <https://fetch.spec.whatwg.org/#concept-request-referrer>
     pub referrer: Referrer,
     /// <https://fetch.spec.whatwg.org/#concept-request-referrer-policy>
@@ -273,17 +269,16 @@ impl Request {
             sandboxed_storage_area_urls: false,
             headers: Headers::new(),
             unsafe_request: false,
             body: None,
             window: Window::Client,
             keep_alive: false,
             service_workers_mode: ServiceWorkersMode::All,
             initiator: Initiator::None,
-            type_: Type::None,
             destination: Destination::None,
             origin: origin.unwrap_or(Origin::Client),
             referrer: Referrer::Client,
             referrer_policy: None,
             pipeline_id: pipeline_id,
             synchronous: false,
             mode: RequestMode::NoCors,
             use_cors_preflight: false,
@@ -302,17 +297,16 @@ impl Request {
         let mut req = Request::new(init.url.clone(),
                                    Some(Origin::Origin(init.origin)),
                                    init.pipeline_id);
         req.method = init.method;
         req.headers = init.headers;
         req.unsafe_request = init.unsafe_request;
         req.body = init.body;
         req.service_workers_mode = init.service_workers_mode;
-        req.type_ = init.type_;
         req.destination = init.destination;
         req.synchronous = init.synchronous;
         req.mode = init.mode;
         req.use_cors_preflight = init.use_cors_preflight;
         req.credentials_mode = init.credentials_mode;
         req.use_url_credentials = init.use_url_credentials;
         req.cache_mode = init.cache_mode;
         req.referrer = if let Some(url) = init.referrer_url {
@@ -351,18 +345,19 @@ impl Request {
     /// <https://fetch.spec.whatwg.org/#navigation-request>
     pub fn is_navigation_request(&self) -> bool {
         self.destination == Destination::Document
     }
 
     /// <https://fetch.spec.whatwg.org/#subresource-request>
     pub fn is_subresource_request(&self) -> bool {
         match self.destination {
-            Destination::Font | Destination::Image | Destination::Manifest | Destination::Media |
-            Destination::Script | Destination::Style | Destination::XSLT | Destination::None => true,
+            Destination::Audio | Destination::Font | Destination::Image | Destination::Manifest |
+            Destination::Script | Destination::Style | Destination::Track | Destination::Video |
+            Destination::Xslt | Destination::None => true,
             _ => false,
         }
     }
 }
 
 impl Referrer {
     pub fn to_url(&self) -> Option<&ServoUrl> {
         match *self {
--- a/servo/components/script/dom/dedicatedworkerglobalscope.rs
+++ b/servo/components/script/dom/dedicatedworkerglobalscope.rs
@@ -25,17 +25,17 @@ use dom::workerglobalscope::WorkerGlobal
 use dom_struct::dom_struct;
 use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
 use ipc_channel::router::ROUTER;
 use js::jsapi::{HandleValue, JS_SetInterruptCallback};
 use js::jsapi::{JSAutoCompartment, JSContext, NullHandleValue};
 use js::jsval::UndefinedValue;
 use msg::constellation_msg::TopLevelBrowsingContextId;
 use net_traits::{IpcSend, load_whole_resource};
-use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
+use net_traits::request::{CredentialsMode, Destination, RequestInit};
 use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, new_rt_and_cx, Runtime};
 use script_runtime::ScriptThreadEventCategory::WorkerEvent;
 use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
 use servo_rand::random;
 use servo_url::ServoUrl;
 use std::mem::replace;
 use std::sync::{Arc, Mutex};
 use std::sync::atomic::AtomicBool;
@@ -174,17 +174,16 @@ impl DedicatedWorkerGlobalScope {
 
             let roots = RootCollection::new();
             let _stack_roots = ThreadLocalStackRoots::new(&roots);
 
             let WorkerScriptLoadOrigin { referrer_url, referrer_policy, pipeline_id } = worker_load_origin;
 
             let request = RequestInit {
                 url: worker_url.clone(),
-                type_: RequestType::Script,
                 destination: Destination::Worker,
                 credentials_mode: CredentialsMode::Include,
                 use_url_credentials: true,
                 pipeline_id: pipeline_id,
                 referrer_url: referrer_url,
                 referrer_policy: referrer_policy,
                 origin,
                 .. RequestInit::default()
--- a/servo/components/script/dom/htmlimageelement.rs
+++ b/servo/components/script/dom/htmlimageelement.rs
@@ -41,17 +41,17 @@ use html5ever::{LocalName, Prefix};
 use ipc_channel::ipc;
 use ipc_channel::router::ROUTER;
 use microtask::{Microtask, MicrotaskRunnable};
 use net_traits::{FetchResponseListener, FetchMetadata, NetworkError, FetchResponseMsg};
 use net_traits::image::base::{Image, ImageMetadata};
 use net_traits::image_cache::{CanRequestImages, ImageCache, ImageOrMetadataAvailable};
 use net_traits::image_cache::{ImageResponder, ImageResponse, ImageState, PendingImageId};
 use net_traits::image_cache::UsePlaceholder;
-use net_traits::request::{RequestInit, Type as RequestType};
+use net_traits::request::RequestInit;
 use network_listener::{NetworkListener, PreInvoke};
 use num_traits::ToPrimitive;
 use script_thread::ScriptThread;
 use servo_url::ServoUrl;
 use servo_url::origin::ImmutableOrigin;
 use std::cell::{Cell, RefMut};
 use std::char;
 use std::default::Default;
@@ -270,17 +270,16 @@ impl HTMLImageElement {
         };
         ROUTER.add_route(action_receiver.to_opaque(), Box::new(move |message| {
             listener.notify_fetch(message.to().unwrap());
         }));
 
         let request = RequestInit {
             url: img_url.clone(),
             origin: document.origin().immutable().clone(),
-            type_: RequestType::Image,
             pipeline_id: Some(document.global().pipeline_id()),
             .. RequestInit::default()
         };
 
         // This is a background load because the load blocker already fulfills the
         // purpose of delaying the document's load event.
         document.loader().fetch_async_background(request, action_sender);
     }
--- a/servo/components/script/dom/htmlmediaelement.rs
+++ b/servo/components/script/dom/htmlmediaelement.rs
@@ -32,17 +32,17 @@ use dom::promise::Promise;
 use dom::virtualmethods::VirtualMethods;
 use dom_struct::dom_struct;
 use html5ever::{LocalName, Prefix};
 use ipc_channel::ipc;
 use ipc_channel::router::ROUTER;
 use microtask::{Microtask, MicrotaskRunnable};
 use mime::{Mime, SubLevel, TopLevel};
 use net_traits::{FetchResponseListener, FetchMetadata, Metadata, NetworkError};
-use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
+use net_traits::request::{CredentialsMode, Destination, RequestInit};
 use network_listener::{NetworkListener, PreInvoke};
 use script_thread::ScriptThread;
 use servo_url::ServoUrl;
 use std::cell::Cell;
 use std::collections::VecDeque;
 use std::mem;
 use std::rc::Rc;
 use std::sync::{Arc, Mutex};
@@ -581,24 +581,23 @@ impl HTMLMediaElement {
                     // then continue with the normal set of steps instead of just
                     // returning.
                     return;
                 }
 
                 // Step 4.remote.2.
                 // FIXME(nox): Handle CORS setting from crossorigin attribute.
                 let document = document_from_node(self);
-                let type_ = match self.media_type_id() {
-                    HTMLMediaElementTypeId::HTMLAudioElement => RequestType::Audio,
-                    HTMLMediaElementTypeId::HTMLVideoElement => RequestType::Video,
+                let destination = match self.media_type_id() {
+                    HTMLMediaElementTypeId::HTMLAudioElement => Destination::Audio,
+                    HTMLMediaElementTypeId::HTMLVideoElement => Destination::Video,
                 };
                 let request = RequestInit {
                     url,
-                    type_,
-                    destination: Destination::Media,
+                    destination,
                     credentials_mode: CredentialsMode::Include,
                     use_url_credentials: true,
                     origin: document.origin().immutable().clone(),
                     pipeline_id: Some(self.global().pipeline_id()),
                     referrer_url: Some(document.url()),
                     referrer_policy: document.get_referrer_policy(),
                     .. RequestInit::default()
                 };
--- a/servo/components/script/dom/htmlscriptelement.rs
+++ b/servo/components/script/dom/htmlscriptelement.rs
@@ -25,17 +25,17 @@ use dom::virtualmethods::VirtualMethods;
 use dom_struct::dom_struct;
 use encoding::label::encoding_from_whatwg_label;
 use encoding::types::{DecoderTrap, EncodingRef};
 use html5ever::{LocalName, Prefix};
 use ipc_channel::ipc;
 use ipc_channel::router::ROUTER;
 use js::jsval::UndefinedValue;
 use net_traits::{FetchMetadata, FetchResponseListener, Metadata, NetworkError};
-use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestInit, RequestMode, Type as RequestType};
+use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestInit, RequestMode};
 use network_listener::{NetworkListener, PreInvoke};
 use servo_atoms::Atom;
 use servo_config::opts;
 use servo_url::ServoUrl;
 use std::ascii::AsciiExt;
 use std::cell::Cell;
 use std::fs::File;
 use std::io::{Read, Write};
@@ -233,17 +233,16 @@ fn fetch_a_classic_script(script: &HTMLS
                           cors_setting: Option<CorsSettings>,
                           integrity_metadata: String,
                           character_encoding: EncodingRef) {
     let doc = document_from_node(script);
 
     // Step 1, 2.
     let request = RequestInit {
         url: url.clone(),
-        type_: RequestType::Script,
         destination: Destination::Script,
         // 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
--- a/servo/components/script/dom/request.rs
+++ b/servo/components/script/dom/request.rs
@@ -10,17 +10,16 @@ use dom::bindings::codegen::Bindings::Re
 use dom::bindings::codegen::Bindings::RequestBinding::RequestCache;
 use dom::bindings::codegen::Bindings::RequestBinding::RequestCredentials;
 use dom::bindings::codegen::Bindings::RequestBinding::RequestDestination;
 use dom::bindings::codegen::Bindings::RequestBinding::RequestInfo;
 use dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
 use dom::bindings::codegen::Bindings::RequestBinding::RequestMethods;
 use dom::bindings::codegen::Bindings::RequestBinding::RequestMode;
 use dom::bindings::codegen::Bindings::RequestBinding::RequestRedirect;
-use dom::bindings::codegen::Bindings::RequestBinding::RequestType;
 use dom::bindings::error::{Error, Fallible};
 use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
 use dom::bindings::root::{DomRoot, MutNullableDom};
 use dom::bindings::str::{ByteString, DOMString, USVString};
 use dom::bindings::trace::RootedTraceableBox;
 use dom::globalscope::GlobalScope;
 use dom::headers::{Guard, Headers};
 use dom::promise::Promise;
@@ -31,17 +30,16 @@ use net_traits::ReferrerPolicy as MsgRef
 use net_traits::request::{Origin, Window};
 use net_traits::request::CacheMode as NetTraitsRequestCache;
 use net_traits::request::CredentialsMode as NetTraitsRequestCredentials;
 use net_traits::request::Destination as NetTraitsRequestDestination;
 use net_traits::request::RedirectMode as NetTraitsRequestRedirect;
 use net_traits::request::Referrer as NetTraitsRequestReferrer;
 use net_traits::request::Request as NetTraitsRequest;
 use net_traits::request::RequestMode as NetTraitsRequestMode;
-use net_traits::request::Type as NetTraitsRequestType;
 use servo_url::ServoUrl;
 use std::cell::{Cell, Ref};
 use std::rc::Rc;
 
 #[dom_struct]
 pub struct Request {
     reflector_: Reflector,
     request: DomRefCell<NetTraitsRequest>,
@@ -521,21 +519,16 @@ impl RequestMethods for Request {
         USVString(r.url_list.get(0).map_or("", |u| u.as_str()).into())
     }
 
     // https://fetch.spec.whatwg.org/#dom-request-headers
     fn Headers(&self) -> DomRoot<Headers> {
         self.headers.or_init(|| Headers::new(&self.global()))
     }
 
-    // https://fetch.spec.whatwg.org/#dom-request-type
-    fn Type(&self) -> RequestType {
-        self.request.borrow().type_.into()
-    }
-
     // https://fetch.spec.whatwg.org/#dom-request-destination
     fn Destination(&self) -> RequestDestination {
         self.request.borrow().destination.into()
     }
 
     // https://fetch.spec.whatwg.org/#dom-request-referrer
     fn Referrer(&self) -> USVString {
         let r = self.request.borrow();
@@ -698,82 +691,56 @@ impl Into<RequestCredentials> for NetTra
         }
     }
 }
 
 impl Into<NetTraitsRequestDestination> for RequestDestination {
     fn into(self) -> NetTraitsRequestDestination {
         match self {
             RequestDestination::_empty => NetTraitsRequestDestination::None,
+            RequestDestination::Audio => NetTraitsRequestDestination::Audio,
             RequestDestination::Document => NetTraitsRequestDestination::Document,
             RequestDestination::Embed => NetTraitsRequestDestination::Embed,
             RequestDestination::Font => NetTraitsRequestDestination::Font,
             RequestDestination::Image => NetTraitsRequestDestination::Image,
             RequestDestination::Manifest => NetTraitsRequestDestination::Manifest,
-            RequestDestination::Media => NetTraitsRequestDestination::Media,
             RequestDestination::Object => NetTraitsRequestDestination::Object,
             RequestDestination::Report => NetTraitsRequestDestination::Report,
             RequestDestination::Script => NetTraitsRequestDestination::Script,
-            RequestDestination::Serviceworker => NetTraitsRequestDestination::ServiceWorker,
             RequestDestination::Sharedworker => NetTraitsRequestDestination::SharedWorker,
             RequestDestination::Style => NetTraitsRequestDestination::Style,
+            RequestDestination::Track => NetTraitsRequestDestination::Track,
+            RequestDestination::Video => NetTraitsRequestDestination::Video,
             RequestDestination::Worker => NetTraitsRequestDestination::Worker,
-            RequestDestination::Xslt => NetTraitsRequestDestination::XSLT,
+            RequestDestination::Xslt => NetTraitsRequestDestination::Xslt,
         }
     }
 }
 
 impl Into<RequestDestination> for NetTraitsRequestDestination {
     fn into(self) -> RequestDestination {
         match self {
             NetTraitsRequestDestination::None => RequestDestination::_empty,
+            NetTraitsRequestDestination::Audio => RequestDestination::Audio,
             NetTraitsRequestDestination::Document => RequestDestination::Document,
             NetTraitsRequestDestination::Embed => RequestDestination::Embed,
             NetTraitsRequestDestination::Font => RequestDestination::Font,
             NetTraitsRequestDestination::Image => RequestDestination::Image,
             NetTraitsRequestDestination::Manifest => RequestDestination::Manifest,
-            NetTraitsRequestDestination::Media => RequestDestination::Media,
             NetTraitsRequestDestination::Object => RequestDestination::Object,
             NetTraitsRequestDestination::Report => RequestDestination::Report,
             NetTraitsRequestDestination::Script => RequestDestination::Script,
-            NetTraitsRequestDestination::ServiceWorker => RequestDestination::Serviceworker,
+            NetTraitsRequestDestination::ServiceWorker
+                => panic!("ServiceWorker request destination should not be exposed to DOM"),
             NetTraitsRequestDestination::SharedWorker => RequestDestination::Sharedworker,
             NetTraitsRequestDestination::Style => RequestDestination::Style,
-            NetTraitsRequestDestination::XSLT => RequestDestination::Xslt,
+            NetTraitsRequestDestination::Track => RequestDestination::Track,
+            NetTraitsRequestDestination::Video => RequestDestination::Video,
             NetTraitsRequestDestination::Worker => RequestDestination::Worker,
-        }
-    }
-}
-
-impl Into<NetTraitsRequestType> for RequestType {
-    fn into(self) -> NetTraitsRequestType {
-        match self {
-            RequestType::_empty => NetTraitsRequestType::None,
-            RequestType::Audio => NetTraitsRequestType::Audio,
-            RequestType::Font => NetTraitsRequestType::Font,
-            RequestType::Image => NetTraitsRequestType::Image,
-            RequestType::Script => NetTraitsRequestType::Script,
-            RequestType::Style => NetTraitsRequestType::Style,
-            RequestType::Track => NetTraitsRequestType::Track,
-            RequestType::Video => NetTraitsRequestType::Video,
-        }
-    }
-}
-
-impl Into<RequestType> for NetTraitsRequestType {
-    fn into(self) -> RequestType {
-        match self {
-            NetTraitsRequestType::None => RequestType::_empty,
-            NetTraitsRequestType::Audio => RequestType::Audio,
-            NetTraitsRequestType::Font => RequestType::Font,
-            NetTraitsRequestType::Image => RequestType::Image,
-            NetTraitsRequestType::Script => RequestType::Script,
-            NetTraitsRequestType::Style => RequestType::Style,
-            NetTraitsRequestType::Track => RequestType::Track,
-            NetTraitsRequestType::Video => RequestType::Video,
+            NetTraitsRequestDestination::Xslt => RequestDestination::Xslt,
         }
     }
 }
 
 impl Into<NetTraitsRequestMode> for RequestMode {
     fn into(self) -> NetTraitsRequestMode {
         match self {
             RequestMode::Navigate => NetTraitsRequestMode::Navigate,
--- a/servo/components/script/dom/serviceworkerglobalscope.rs
+++ b/servo/components/script/dom/serviceworkerglobalscope.rs
@@ -18,17 +18,17 @@ use dom::extendablemessageevent::Extenda
 use dom::globalscope::GlobalScope;
 use dom::workerglobalscope::WorkerGlobalScope;
 use dom_struct::dom_struct;
 use ipc_channel::ipc::{self, IpcSender, IpcReceiver};
 use ipc_channel::router::ROUTER;
 use js::jsapi::{JS_SetInterruptCallback, JSAutoCompartment, JSContext};
 use js::jsval::UndefinedValue;
 use net_traits::{load_whole_resource, IpcSend, CustomResponseMediator};
-use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
+use net_traits::request::{CredentialsMode, Destination, RequestInit};
 use script_runtime::{CommonScriptMsg, ScriptChan, new_rt_and_cx, Runtime};
 use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
 use servo_config::prefs::PREFS;
 use servo_rand::random;
 use servo_url::ServoUrl;
 use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
 use std::thread;
 use std::time::Duration;
@@ -156,17 +156,16 @@ impl ServiceWorkerGlobalScope {
             thread_state::initialize(SCRIPT | IN_WORKER);
             let roots = RootCollection::new();
             let _stack_roots = ThreadLocalStackRoots::new(&roots);
 
             let WorkerScriptLoadOrigin { referrer_url, referrer_policy, pipeline_id } = worker_load_origin;
 
             let request = RequestInit {
                 url: script_url.clone(),
-                type_: RequestType::Script,
                 destination: Destination::ServiceWorker,
                 credentials_mode: CredentialsMode::Include,
                 use_url_credentials: true,
                 pipeline_id: pipeline_id,
                 referrer_url: referrer_url,
                 referrer_policy: referrer_policy,
                 origin,
                 .. RequestInit::default()
--- a/servo/components/script/dom/webidls/Request.webidl
+++ b/servo/components/script/dom/webidls/Request.webidl
@@ -8,25 +8,26 @@ typedef (Request or USVString) RequestIn
 
 [Constructor(RequestInfo input, optional RequestInit init),
  Exposed=(Window,Worker)]
 
 interface Request {
   readonly attribute ByteString method;
   readonly attribute USVString url;
   [SameObject] readonly attribute Headers headers;
-  readonly attribute RequestType type;
+
   readonly attribute RequestDestination destination;
   readonly attribute USVString referrer;
   readonly attribute ReferrerPolicy referrerPolicy;
   readonly attribute RequestMode mode;
   readonly attribute RequestCredentials credentials;
   readonly attribute RequestCache cache;
   readonly attribute RequestRedirect redirect;
   readonly attribute DOMString integrity;
+
   [NewObject, Throws] Request clone();
 };
 
 Request implements Body;
 
 dictionary RequestInit {
   ByteString method;
   HeadersInit headers;
@@ -36,41 +37,31 @@ dictionary RequestInit {
   RequestMode mode;
   RequestCredentials credentials;
   RequestCache cache;
   RequestRedirect redirect;
   DOMString integrity;
   any window; // can only be set to null
 };
 
-enum RequestType {
+enum RequestDestination {
   "",
   "audio",
-  "font",
-  "image",
-  "script",
-  "style",
-  "track",
-  "video"
-};
-
-enum RequestDestination {
-  "",
   "document",
   "embed",
   "font",
   "image",
   "manifest",
-  "media",
   "object",
   "report",
   "script",
-  "serviceworker",
   "sharedworker",
   "style",
+  "track",
+  "video",
   "worker",
   "xslt"
 };
 
 enum RequestMode {
   "navigate",
   "same-origin",
   "no-cors",
--- a/servo/components/script/dom/workerglobalscope.rs
+++ b/servo/components/script/dom/workerglobalscope.rs
@@ -25,17 +25,17 @@ use dom::workerlocation::WorkerLocation;
 use dom::workernavigator::WorkerNavigator;
 use dom_struct::dom_struct;
 use fetch;
 use ipc_channel::ipc::IpcSender;
 use js::jsapi::{HandleValue, JSAutoCompartment, JSContext, JSRuntime};
 use js::jsval::UndefinedValue;
 use js::panic::maybe_resume_unwind;
 use net_traits::{IpcSend, load_whole_resource};
-use net_traits::request::{CredentialsMode, Destination, RequestInit as NetRequestInit, Type as RequestType};
+use net_traits::request::{CredentialsMode, Destination, RequestInit as NetRequestInit};
 use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, get_reports, Runtime};
 use script_traits::{TimerEvent, TimerEventId};
 use script_traits::WorkerGlobalScopeInit;
 use servo_url::{MutableOrigin, ServoUrl};
 use std::default::Default;
 use std::rc::Rc;
 use std::sync::Arc;
 use std::sync::atomic::{AtomicBool, Ordering};
@@ -194,17 +194,16 @@ impl WorkerGlobalScopeMethods for Worker
             };
         }
 
         rooted!(in(self.runtime.cx()) let mut rval = UndefinedValue());
         for url in urls {
             let global_scope = self.upcast::<GlobalScope>();
             let request = NetRequestInit {
                 url: url.clone(),
-                type_: RequestType::Script,
                 destination: Destination::Script,
                 credentials_mode: CredentialsMode::Include,
                 use_url_credentials: true,
                 origin: global_scope.origin().immutable().clone(),
                 pipeline_id: Some(self.upcast::<GlobalScope>().pipeline_id()),
                 referrer_url: None,
                 referrer_policy: None,
                 .. NetRequestInit::default()
--- a/servo/components/script/dom/worklet.rs
+++ b/servo/components/script/dom/worklet.rs
@@ -38,17 +38,16 @@ use js::jsapi::JSTracer;
 use js::jsapi::JS_GC;
 use js::jsapi::JS_GetGCParameter;
 use msg::constellation_msg::PipelineId;
 use net_traits::IpcSend;
 use net_traits::load_whole_resource;
 use net_traits::request::Destination;
 use net_traits::request::RequestInit;
 use net_traits::request::RequestMode;
-use net_traits::request::Type as RequestType;
 use script_runtime::CommonScriptMsg;
 use script_runtime::Runtime;
 use script_runtime::ScriptThreadEventCategory;
 use script_runtime::new_rt_and_cx;
 use script_thread::{MainThreadScriptMsg, ScriptThread};
 use servo_rand;
 use servo_url::ImmutableOrigin;
 use servo_url::ServoUrl;
@@ -568,17 +567,16 @@ impl WorkletThread {
 
         // Step 2.
         // TODO: Fetch a module graph, not just a single script.
         // TODO: Fetch the script asynchronously?
         // TODO: Caching.
         let resource_fetcher = self.global_init.resource_threads.sender();
         let request = RequestInit {
             url: script_url,
-            type_: RequestType::Script,
             destination: Destination::Script,
             mode: RequestMode::CorsMode,
             credentials_mode: credentials.into(),
             origin,
             .. RequestInit::default()
         };
         let script = load_whole_resource(request, &resource_fetcher).ok()
             .and_then(|(_, bytes)| String::from_utf8(bytes).ok());
--- a/servo/components/script/fetch.rs
+++ b/servo/components/script/fetch.rs
@@ -44,17 +44,16 @@ fn from_referrer_to_referrer_url(request
 
 fn request_init_from_request(request: NetTraitsRequest) -> NetTraitsRequestInit {
     NetTraitsRequestInit {
         method: request.method.clone(),
         url: request.url(),
         headers: request.headers.clone(),
         unsafe_request: request.unsafe_request,
         body: request.body.clone(),
-        type_: request.type_,
         destination: request.destination,
         synchronous: request.synchronous,
         mode: request.mode,
         use_cors_preflight: request.use_cors_preflight,
         credentials_mode: request.credentials_mode,
         use_url_credentials: request.use_url_credentials,
         origin: GlobalScope::current().expect("No current global object").origin().immutable().clone(),
         referrer_url: from_referrer_to_referrer_url(&request),
--- a/servo/components/script/layout_image.rs
+++ b/servo/components/script/layout_image.rs
@@ -8,17 +8,17 @@
 //! layout thread holds on to them during asynchronous operations.
 
 use dom::bindings::reflector::DomObject;
 use dom::node::{Node, document_from_node};
 use ipc_channel::ipc;
 use ipc_channel::router::ROUTER;
 use net_traits::{FetchResponseMsg, FetchResponseListener, FetchMetadata, NetworkError};
 use net_traits::image_cache::{ImageCache, PendingImageId};
-use net_traits::request::{Type as RequestType, RequestInit as FetchRequestInit};
+use net_traits::request::{Destination, RequestInit as FetchRequestInit};
 use network_listener::{NetworkListener, PreInvoke};
 use servo_url::ServoUrl;
 use std::sync::{Arc, Mutex};
 
 struct LayoutImageContext {
     id: PendingImageId,
     cache: Arc<ImageCache>,
 }
@@ -66,16 +66,16 @@ pub fn fetch_image_for_layout(url: Servo
     };
     ROUTER.add_route(action_receiver.to_opaque(), Box::new(move |message| {
         listener.notify_fetch(message.to().unwrap());
     }));
 
     let request = FetchRequestInit {
         url: url,
         origin: document.origin().immutable().clone(),
-        type_: RequestType::Image,
+        destination: Destination::Image,
         pipeline_id: Some(document.global().pipeline_id()),
         .. FetchRequestInit::default()
     };
 
     // Layout image loads do not delay the document load event.
     document.loader().fetch_async_background(request, action_sender);
 }
--- a/servo/components/script/stylesheet_loader.rs
+++ b/servo/components/script/stylesheet_loader.rs
@@ -16,17 +16,17 @@ use dom::node::{document_from_node, wind
 use encoding::EncodingRef;
 use encoding::all::UTF_8;
 use hyper::header::ContentType;
 use hyper::mime::{Mime, TopLevel, SubLevel};
 use hyper_serde::Serde;
 use ipc_channel::ipc;
 use ipc_channel::router::ROUTER;
 use net_traits::{FetchResponseListener, FetchMetadata, FilteredMetadata, Metadata, NetworkError, ReferrerPolicy};
-use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestInit, RequestMode, Type as RequestType};
+use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestInit, RequestMode};
 use network_listener::{NetworkListener, PreInvoke};
 use parking_lot::RwLock;
 use servo_arc::Arc;
 use servo_url::ServoUrl;
 use std::mem;
 use std::sync::Mutex;
 use std::sync::atomic::AtomicBool;
 use style::media_queries::MediaList;
@@ -242,17 +242,16 @@ impl<'a> StylesheetLoader<'a> {
             .or_else(|| document.get_referrer_policy());
         owner.increment_pending_loads_count();
         if owner.parser_inserted() {
             document.increment_script_blocking_stylesheet_count();
         }
 
         let request = RequestInit {
             url: url.clone(),
-            type_: RequestType::Style,
             destination: Destination::Style,
             // 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
--- a/servo/tests/unit/net/fetch.rs
+++ b/servo/tests/unit/net/fetch.rs
@@ -27,17 +27,17 @@ use net::connector::create_ssl_client;
 use net::fetch::cors_cache::CorsCache;
 use net::fetch::methods::FetchContext;
 use net::filemanager_thread::FileManager;
 use net::hsts::HstsEntry;
 use net::test::HttpState;
 use net_traits::IncludeSubdomains;
 use net_traits::NetworkError;
 use net_traits::ReferrerPolicy;
-use net_traits::request::{Origin, RedirectMode, Referrer, Request, RequestMode, Type};
+use net_traits::request::{Destination, Origin, RedirectMode, Referrer, Request, RequestMode};
 use net_traits::response::{CacheState, Response, ResponseBody, ResponseType};
 use servo_config::resource_files::resources_dir_path;
 use servo_url::{ImmutableOrigin, ServoUrl};
 use std::fs::File;
 use std::io::Read;
 use std::sync::{Arc, Mutex};
 use std::sync::atomic::{AtomicUsize, Ordering};
 use std::sync::mpsc::{Sender, channel};
@@ -605,17 +605,17 @@ fn test_fetch_with_sri_sucess() {
     let _ = server.close();
     assert_eq!(response_is_done(&response), true);
 }
 
 /// `fetch` should return a network error if there is a header `X-Content-Type-Options: nosniff`
 #[test]
 fn test_fetch_blocked_nosniff() {
     #[inline]
-    fn test_nosniff_request(request_type: Type,
+    fn test_nosniff_request(destination: Destination,
                             mime: Mime,
                             should_error: bool) {
         const MESSAGE: &'static [u8] = b"";
         const HEADER: &'static str = "X-Content-Type-Options";
         const VALUE: &'static [u8] = b"nosniff";
 
         let handler = move |_: HyperRequest, mut response: HyperResponse| {
             let mime_header = ContentType(mime.clone());
@@ -626,32 +626,32 @@ fn test_fetch_blocked_nosniff() {
 
             response.send(MESSAGE).unwrap();
         };
 
         let (mut server, url) = make_server(handler);
 
         let origin = Origin::Origin(url.origin());
         let mut request = Request::new(url, Some(origin), None);
-        request.type_ = request_type;
+        request.destination = destination;
         let fetch_response = fetch(&mut request, None);
         let _ = server.close();
 
         assert_eq!(fetch_response.is_network_error(), should_error);
     }
 
     let tests = vec![
-        (Type::Script, Mime(TopLevel::Text, SubLevel::Javascript, vec![]), false),
-        (Type::Script, Mime(TopLevel::Text, SubLevel::Css, vec![]), true),
-        (Type::Style,  Mime(TopLevel::Text, SubLevel::Css, vec![]), false),
+        (Destination::Script, Mime(TopLevel::Text, SubLevel::Javascript, vec![]), false),
+        (Destination::Script, Mime(TopLevel::Text, SubLevel::Css, vec![]), true),
+        (Destination::Style,  Mime(TopLevel::Text, SubLevel::Css, vec![]), false),
     ];
 
     for test in tests {
-        let (type_, mime, should_error) = test;
-        test_nosniff_request(type_, mime, should_error);
+        let (destination, mime, should_error) = test;
+        test_nosniff_request(destination, mime, should_error);
     }
 }
 
 fn setup_server_and_fetch(message: &'static [u8], redirect_cap: u32) -> Response {
     let handler = move |request: HyperRequest, mut response: HyperResponse| {
         let redirects = match request.uri {
             RequestUri::AbsolutePath(url) =>
                 url.split("/").collect::<String>().parse::<u32>().unwrap_or(0),