Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass a borrowed fetch context to fetch(). #14138

Merged
merged 1 commit into from Nov 9, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Pass a borrowed fetch context to fetch().

This will allow inspecting its state after fetching in unit tests.
  • Loading branch information
Ms2ger committed Nov 8, 2016
commit 234b47e33e31bda41c39725265061a6cf2cd7048
@@ -63,15 +63,15 @@ 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)
}

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 {
@@ -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);
})
}

@@ -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());
@@ -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) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.