mirror of
https://github.com/servo/servo.git
synced 2025-09-09 22:48:21 +01:00
Auto merge of #11889 - mrmiywj:report-redirected-request, r=jdm
send requests that are redirected to devtools <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11773 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because no automating tests <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11889) <!-- Reviewable:end -->
This commit is contained in:
commit
3afa150cd8
2 changed files with 65 additions and 17 deletions
|
@ -586,6 +586,52 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() {
|
|||
assert!(devtools_port.try_recv().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_redirected_request_to_devtools() {
|
||||
struct Factory;
|
||||
|
||||
impl HttpRequestFactory for Factory {
|
||||
type R = MockRequest;
|
||||
|
||||
fn create(&self, url: Url, method: Method, _: Headers) -> Result<MockRequest, LoadError> {
|
||||
if url.domain().unwrap() == "mozilla.com" {
|
||||
assert_eq!(Method::Post, method);
|
||||
Ok(MockRequest::new(ResponseType::Redirect("http://mozilla.org".to_owned())))
|
||||
} else {
|
||||
assert_eq!(Method::Get, method);
|
||||
Ok(MockRequest::new(ResponseType::Text(<[_]>::to_vec("Yay!".as_bytes()))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let url = Url::parse("http://mozilla.com").unwrap();
|
||||
let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), &HttpTest);
|
||||
|
||||
load_data.method = Method::Post;
|
||||
|
||||
let http_state = HttpState::new();
|
||||
let ui_provider = TestProvider::new();
|
||||
let (devtools_chan, devtools_port) = mpsc::channel::<DevtoolsControlMsg>();
|
||||
|
||||
let _ = load(&load_data, &ui_provider, &http_state, Some(devtools_chan), &Factory,
|
||||
DEFAULT_USER_AGENT.to_owned(), &CancellationListener::new(None), None);
|
||||
|
||||
let devhttprequest = expect_devtools_http_request(&devtools_port);
|
||||
let devhttpresponse = expect_devtools_http_response(&devtools_port);
|
||||
|
||||
assert!(devhttprequest.method == Method::Post);
|
||||
assert!(devhttprequest.url == url);
|
||||
assert!(devhttpresponse.status == Some(RawStatus(301, Cow::Borrowed("Moved Permanently"))));
|
||||
|
||||
let devhttprequest = expect_devtools_http_request(&devtools_port);
|
||||
let devhttpresponse = expect_devtools_http_response(&devtools_port);
|
||||
let url = Url::parse("http://mozilla.org").unwrap();
|
||||
|
||||
assert!(devhttprequest.method == Method::Get);
|
||||
assert!(devhttprequest.url == url);
|
||||
assert!(devhttpresponse.status == Some(RawStatus(200, Cow::Borrowed("Ok"))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue