diff options
-rw-r--r-- | tests/unit/net/http_loader.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/tests/unit/net/http_loader.rs b/tests/unit/net/http_loader.rs index 47ac4acfc27..fccef5000fb 100644 --- a/tests/unit/net/http_loader.rs +++ b/tests/unit/net/http_loader.rs @@ -278,16 +278,11 @@ impl HttpRequestFactory for AssertMustIncludeHeadersRequestFactory { } } -fn assert_cookie_for_domain(cookie_jar: Arc<RwLock<CookieStorage>>, domain: &str, cookie: &str) { +fn assert_cookie_for_domain(cookie_jar: Arc<RwLock<CookieStorage>>, domain: &str, cookie: Option<&str>) { let mut cookie_jar = cookie_jar.write().unwrap(); let url = Url::parse(&*domain).unwrap(); let cookies = cookie_jar.cookies_for_url(&url, CookieSource::HTTP); - - if let Some(cookie_list) = cookies { - assert_eq!(cookie.to_owned(), cookie_list); - } else { - assert_eq!(cookie.len(), 0); - } + assert_eq!(cookies.as_ref().map(|c| &**c), cookie); } struct AssertMustNotIncludeHeadersRequestFactory { @@ -851,7 +846,7 @@ fn test_load_sets_cookies_in_the_resource_manager_when_it_get_set_cookie_header_ let http_state = HttpState::new(); let ui_provider = TestProvider::new(); - assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", ""); + assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", None); let load_data = LoadData::new(LoadContext::Browsing, url.clone(), &HttpTest); @@ -863,7 +858,7 @@ fn test_load_sets_cookies_in_the_resource_manager_when_it_get_set_cookie_header_ &CancellationListener::new(None), None); - assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", "mozillaIs=theBest"); + assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", Some("mozillaIs=theBest")); } #[test] @@ -1030,7 +1025,7 @@ fn test_when_cookie_received_marked_secure_is_ignored_for_http() { DEFAULT_USER_AGENT.into(), &CancellationListener::new(None), None); - assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", ""); + assert_cookie_for_domain(http_state.cookie_jar.clone(), "http://mozilla.com", None); } #[test] @@ -1055,7 +1050,7 @@ fn test_when_cookie_set_marked_httpsonly_secure_isnt_sent_on_http_request() { let mut load_data = LoadData::new(LoadContext::Browsing, url, &HttpTest); load_data.data = Some(<[_]>::to_vec("Yay!".as_bytes())); - assert_cookie_for_domain(http_state.cookie_jar.clone(), "https://mozilla.com", "mozillaIs=theBest"); + assert_cookie_for_domain(http_state.cookie_jar.clone(), "https://mozilla.com", Some("mozillaIs=theBest")); let _ = load( &load_data.clone(), &ui_provider, &http_state, None, |