diff options
author | Ms2ger <Ms2ger@gmail.com> | 2016-11-08 18:01:23 +0100 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2016-11-08 18:01:23 +0100 |
commit | 234b47e33e31bda41c39725265061a6cf2cd7048 (patch) | |
tree | f9b21b35f8c104d3a54c500c9db47c6cced1339b | |
parent | 1153ca9841f458daf373471f3c65295abd872271 (diff) | |
download | servo-234b47e33e31bda41c39725265061a6cf2cd7048.tar.gz servo-234b47e33e31bda41c39725265061a6cf2cd7048.zip |
Pass a borrowed fetch context to fetch().
This will allow inspecting its state after fetching in unit tests.
-rw-r--r-- | components/net/fetch/methods.rs | 4 | ||||
-rw-r--r-- | components/net/resource_thread.rs | 2 | ||||
-rw-r--r-- | tests/unit/net/fetch.rs | 6 | ||||
-rw-r--r-- | tests/unit/net/lib.rs | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 092a5e7f0ef..eba6481f236 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -63,7 +63,7 @@ type DoneChannel = Option<(Sender<Data>, Receiver<Data>)>; /// [Fetch](https://fetch.spec.whatwg.org#concept-fetch) pub fn fetch<UI: 'static + UIProvider>(request: Rc<Request>, target: &mut Target, - context: FetchContext<UI>) + context: &FetchContext<UI>) -> Response { fetch_with_cors_cache(request, &mut CORSCache::new(), target, context) } @@ -71,7 +71,7 @@ pub fn fetch<UI: 'static + UIProvider>(request: Rc<Request>, pub fn fetch_with_cors_cache<UI: 'static + UIProvider>(request: Rc<Request>, cache: &mut CORSCache, target: &mut Target, - context: FetchContext<UI>) + context: &FetchContext<UI>) -> Response { // Step 1 if request.window.get() == Window::Client { diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index 3724641c5bf..02af5a45bf5 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -586,7 +586,7 @@ impl CoreResourceManager { devtools_chan: dc, filemanager: filemanager, }; - fetch(Rc::new(request), &mut target, context); + fetch(Rc::new(request), &mut target, &context); }) } diff --git a/tests/unit/net/fetch.rs b/tests/unit/net/fetch.rs index 4d56668ad6e..6bef297cbbb 100644 --- a/tests/unit/net/fetch.rs +++ b/tests/unit/net/fetch.rs @@ -119,7 +119,7 @@ fn test_fetch_blob() { let request = Request::new(url, Some(Origin::Origin(origin.origin())), false, None); - let fetch_response = fetch(Rc::new(request), &mut None, context); + let fetch_response = fetch(Rc::new(request), &mut None, &context); assert!(!fetch_response.is_network_error()); @@ -231,9 +231,9 @@ fn test_cors_preflight_cache_fetch() { let wrapped_request1 = Rc::new(request); let fetch_response0 = fetch_with_cors_cache(wrapped_request0.clone(), &mut cache, - &mut None, new_fetch_context(None)); + &mut None, &new_fetch_context(None)); let fetch_response1 = fetch_with_cors_cache(wrapped_request1.clone(), &mut cache, - &mut None, new_fetch_context(None)); + &mut None, &new_fetch_context(None)); let _ = server.close(); assert!(!fetch_response0.is_network_error() && !fetch_response1.is_network_error()); diff --git a/tests/unit/net/lib.rs b/tests/unit/net/lib.rs index 60cd847ba99..d426e198a3f 100644 --- a/tests/unit/net/lib.rs +++ b/tests/unit/net/lib.rs @@ -74,12 +74,12 @@ impl FetchTaskTarget for FetchResponseCollector { fn fetch_async(request: Request, target: Box<FetchTaskTarget + Send>, dc: Option<Sender<DevtoolsControlMsg>>) { thread::spawn(move || { - fetch(Rc::new(request), &mut Some(target), new_fetch_context(dc)); + fetch(Rc::new(request), &mut Some(target), &new_fetch_context(dc)); }); } fn fetch_sync(request: Request, dc: Option<Sender<DevtoolsControlMsg>>) -> Response { - fetch(Rc::new(request), &mut None, new_fetch_context(dc)) + fetch(Rc::new(request), &mut None, &new_fetch_context(dc)) } fn make_server<H: Handler + 'static>(handler: H) -> (Listening, Url) { |