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>
This commit is contained in:
Martin Robinson 2024-09-11 00:09:56 -07:00 committed by GitHub
parent 095590e224
commit bc8d8b62c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 88 additions and 103 deletions

View file

@ -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 {