diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-09-11 00:09:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-11 07:09:56 +0000 |
commit | bc8d8b62c3017dbdb413a636b80bc3a2df0172d6 (patch) | |
tree | 2f4de6402a0bfc56af023b4611bfe14fc59f8fa8 /components/net/tests | |
parent | 095590e2247517cf22e4aea7956f341a9a38b206 (diff) | |
download | servo-bc8d8b62c3017dbdb413a636b80bc3a2df0172d6.tar.gz servo-bc8d8b62c3017dbdb413a636b80bc3a2df0172d6.zip |
Stop using `time@0.1` in Servo (#33394)
This removes the last few uses of `time@0.1` in Servo. There are still
dependencies from `style` and `webrender`, but they will be removed soon
as well. The uses of this version of `time` are replaced with
`std::time` types and `time@0.3` when negative `Duration` is necessary.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/net/tests')
-rw-r--r-- | components/net/tests/hsts.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/components/net/tests/hsts.rs b/components/net/tests/hsts.rs index a3bebb67fcf..e7fae4cf8a4 100644 --- a/components/net/tests/hsts.rs +++ b/components/net/tests/hsts.rs @@ -3,16 +3,19 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::collections::HashMap; +use std::time::Duration as StdDuration; +use base::cross_process_instant::CrossProcessInstant; use net::hsts::{HstsEntry, HstsList}; use net_traits::IncludeSubdomains; +use time_03::Duration; #[test] fn test_hsts_entry_is_not_expired_when_it_has_no_timestamp() { let entry = HstsEntry { host: "mozilla.org".to_owned(), include_subdomains: false, - max_age: Some(20), + max_age: Some(StdDuration::from_secs(20)), timestamp: None, }; @@ -25,7 +28,7 @@ fn test_hsts_entry_is_not_expired_when_it_has_no_max_age() { host: "mozilla.org".to_owned(), include_subdomains: false, max_age: None, - timestamp: Some(time::get_time().sec as u64), + timestamp: Some(CrossProcessInstant::now()), }; assert!(!entry.is_expired()); @@ -36,8 +39,8 @@ fn test_hsts_entry_is_expired_when_it_has_reached_its_max_age() { let entry = HstsEntry { host: "mozilla.org".to_owned(), include_subdomains: false, - max_age: Some(10), - timestamp: Some(time::get_time().sec as u64 - 20u64), + max_age: Some(StdDuration::from_secs(10)), + timestamp: Some(CrossProcessInstant::now() - Duration::seconds(20)), }; assert!(entry.is_expired()); @@ -106,7 +109,7 @@ fn test_push_entry_with_0_max_age_evicts_entry_from_list() { vec![HstsEntry::new( "mozilla.org".to_owned(), IncludeSubdomains::NotIncluded, - Some(500000u64), + Some(StdDuration::from_secs(500000)), ) .unwrap()], ); @@ -118,7 +121,7 @@ fn test_push_entry_with_0_max_age_evicts_entry_from_list() { HstsEntry::new( "mozilla.org".to_owned(), IncludeSubdomains::NotIncluded, - Some(0), + Some(StdDuration::ZERO), ) .unwrap(), ); @@ -367,8 +370,8 @@ fn test_hsts_list_with_expired_entry_is_not_is_host_secure() { vec![HstsEntry { host: "mozilla.org".to_owned(), include_subdomains: false, - max_age: Some(20), - timestamp: Some(time::get_time().sec as u64 - 100u64), + max_age: Some(StdDuration::from_secs(20)), + timestamp: Some(CrossProcessInstant::now() - Duration::seconds(100)), }], ); let hsts_list = HstsList { |