mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-03 09:48:47 +00:00
Userland: Remove remaining users of Duration::now_realtime()
This is a clear sign that they want to use a UnixDateTime instead. This also adds support for placing durations and date times into SQL databases via their millisecond offset to UTC.
This commit is contained in:
parent
82c681e44b
commit
effcd080ca
Notes:
sideshowbarker
2024-07-17 01:23:08 +09:00
Author: https://github.com/kleinesfilmroellchen
Commit: effcd080ca
Pull-request: https://github.com/SerenityOS/serenity/pull/17842
Reviewed-by: https://github.com/me-minus
Reviewed-by: https://github.com/timschumi
16 changed files with 62 additions and 45 deletions
|
@ -286,7 +286,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con
|
||||||
|
|
||||||
// 2. Create a new cookie with name cookie-name, value cookie-value. Set the creation-time and the last-access-time to the current date and time.
|
// 2. Create a new cookie with name cookie-name, value cookie-value. Set the creation-time and the last-access-time to the current date and time.
|
||||||
Web::Cookie::Cookie cookie { parsed_cookie.name, parsed_cookie.value, parsed_cookie.same_site_attribute };
|
Web::Cookie::Cookie cookie { parsed_cookie.name, parsed_cookie.value, parsed_cookie.same_site_attribute };
|
||||||
cookie.creation_time = Duration::now_realtime();
|
cookie.creation_time = UnixDateTime::now();
|
||||||
cookie.last_access_time = cookie.creation_time;
|
cookie.last_access_time = cookie.creation_time;
|
||||||
|
|
||||||
if (parsed_cookie.expiry_time_from_max_age_attribute.has_value()) {
|
if (parsed_cookie.expiry_time_from_max_age_attribute.has_value()) {
|
||||||
|
@ -302,7 +302,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con
|
||||||
} else {
|
} else {
|
||||||
// Set the cookie's persistent-flag to false. Set the cookie's expiry-time to the latest representable date.
|
// Set the cookie's persistent-flag to false. Set the cookie's expiry-time to the latest representable date.
|
||||||
cookie.persistent = false;
|
cookie.persistent = false;
|
||||||
cookie.expiry_time = Duration::max();
|
cookie.expiry_time = UnixDateTime::latest();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. If the cookie-attribute-list contains an attribute with an attribute-name of "Domain":
|
// 4. If the cookie-attribute-list contains an attribute with an attribute-name of "Domain":
|
||||||
|
@ -421,7 +421,7 @@ Vector<Web::Cookie::Cookie> CookieJar::get_matching_cookies(const URL& url, Depr
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3. Update the last-access-time of each cookie in the cookie-list to the current date and time.
|
// 3. Update the last-access-time of each cookie in the cookie-list to the current date and time.
|
||||||
auto now = Duration::now_realtime();
|
auto now = UnixDateTime::now();
|
||||||
|
|
||||||
for (auto& cookie : cookie_list) {
|
for (auto& cookie : cookie_list) {
|
||||||
cookie.last_access_time = now;
|
cookie.last_access_time = now;
|
||||||
|
@ -462,7 +462,7 @@ static ErrorOr<Web::Cookie::Cookie> parse_cookie(ReadonlySpan<SQL::Value> row)
|
||||||
return Error::from_string_view(name);
|
return Error::from_string_view(name);
|
||||||
|
|
||||||
auto time = value.to_int<i64>().value();
|
auto time = value.to_int<i64>().value();
|
||||||
field = Duration::from_seconds(time);
|
field = UnixDateTime::from_seconds_since_epoch(time);
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -505,9 +505,9 @@ void CookieJar::insert_cookie_into_database(Web::Cookie::Cookie const& cookie)
|
||||||
cookie.name,
|
cookie.name,
|
||||||
cookie.value,
|
cookie.value,
|
||||||
to_underlying(cookie.same_site),
|
to_underlying(cookie.same_site),
|
||||||
cookie.creation_time.to_seconds(),
|
cookie.creation_time.seconds_since_epoch(),
|
||||||
cookie.last_access_time.to_seconds(),
|
cookie.last_access_time.seconds_since_epoch(),
|
||||||
cookie.expiry_time.to_seconds(),
|
cookie.expiry_time.seconds_since_epoch(),
|
||||||
cookie.domain,
|
cookie.domain,
|
||||||
cookie.path,
|
cookie.path,
|
||||||
cookie.secure,
|
cookie.secure,
|
||||||
|
@ -529,9 +529,9 @@ void CookieJar::update_cookie_in_database(Web::Cookie::Cookie const& cookie)
|
||||||
storage.statements.update_cookie, {}, [this]() { purge_expired_cookies(); }, {},
|
storage.statements.update_cookie, {}, [this]() { purge_expired_cookies(); }, {},
|
||||||
cookie.value,
|
cookie.value,
|
||||||
to_underlying(cookie.same_site),
|
to_underlying(cookie.same_site),
|
||||||
cookie.creation_time.to_seconds(),
|
cookie.creation_time.seconds_since_epoch(),
|
||||||
cookie.last_access_time.to_seconds(),
|
cookie.last_access_time.seconds_since_epoch(),
|
||||||
cookie.expiry_time.to_seconds(),
|
cookie.expiry_time.seconds_since_epoch(),
|
||||||
cookie.secure,
|
cookie.secure,
|
||||||
cookie.http_only,
|
cookie.http_only,
|
||||||
cookie.host_only,
|
cookie.host_only,
|
||||||
|
@ -624,7 +624,7 @@ void CookieJar::select_all_cookies_from_database(OnSelectAllCookiesResult on_res
|
||||||
|
|
||||||
void CookieJar::purge_expired_cookies()
|
void CookieJar::purge_expired_cookies()
|
||||||
{
|
{
|
||||||
auto now = Duration::now_realtime().to_seconds();
|
auto now = UnixDateTime::now();
|
||||||
|
|
||||||
m_storage.visit(
|
m_storage.visit(
|
||||||
[&](PersistedStorage& storage) {
|
[&](PersistedStorage& storage) {
|
||||||
|
@ -634,7 +634,7 @@ void CookieJar::purge_expired_cookies()
|
||||||
Vector<CookieStorageKey> keys_to_evict;
|
Vector<CookieStorageKey> keys_to_evict;
|
||||||
|
|
||||||
for (auto const& cookie : storage) {
|
for (auto const& cookie : storage) {
|
||||||
if (cookie.value.expiry_time.to_seconds() < now)
|
if (cookie.value.expiry_time < now)
|
||||||
keys_to_evict.append(cookie.key);
|
keys_to_evict.append(cookie.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ void StorageWidget::clear_session_storage_entries()
|
||||||
void StorageWidget::delete_cookie(Web::Cookie::Cookie cookie)
|
void StorageWidget::delete_cookie(Web::Cookie::Cookie cookie)
|
||||||
{
|
{
|
||||||
// Delete cookie by making its expiry time in the past.
|
// Delete cookie by making its expiry time in the past.
|
||||||
cookie.expiry_time = Duration::from_seconds(0);
|
cookie.expiry_time = UnixDateTime::earliest();
|
||||||
if (on_update_cookie)
|
if (on_update_cookie)
|
||||||
on_update_cookie(move(cookie));
|
on_update_cookie(move(cookie));
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,7 @@ public:
|
||||||
break;
|
break;
|
||||||
m_level = i;
|
m_level = i;
|
||||||
}
|
}
|
||||||
auto const now { Duration::now_realtime() };
|
auto const now { UnixDateTime::now() };
|
||||||
auto const delay = s_level_map[m_level].m_delay;
|
auto const delay = s_level_map[m_level].m_delay;
|
||||||
if (now - m_last_update > delay) {
|
if (now - m_last_update > delay) {
|
||||||
m_last_update = now;
|
m_last_update = now;
|
||||||
|
@ -372,7 +372,7 @@ public:
|
||||||
m_block.random_shape();
|
m_block.random_shape();
|
||||||
m_next_block.random_shape();
|
m_next_block.random_shape();
|
||||||
update_shadow_hint_block();
|
update_shadow_hint_block();
|
||||||
m_last_update = Duration::now_realtime();
|
m_last_update = UnixDateTime::now();
|
||||||
m_state = GameState::Active;
|
m_state = GameState::Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +384,8 @@ private:
|
||||||
unsigned m_level {};
|
unsigned m_level {};
|
||||||
unsigned m_score {};
|
unsigned m_score {};
|
||||||
GameState m_state { GameState::GameOver };
|
GameState m_state { GameState::GameOver };
|
||||||
Duration m_last_update {};
|
// FIXME: Should probably use a monotonic clock instead.
|
||||||
|
UnixDateTime m_last_update {};
|
||||||
|
|
||||||
struct LevelMap final {
|
struct LevelMap final {
|
||||||
unsigned const m_score;
|
unsigned const m_score;
|
||||||
|
|
|
@ -131,8 +131,8 @@ static double parse_simplified_iso8601(DeprecatedString const& iso_8601)
|
||||||
|
|
||||||
// We parsed a valid date simplified ISO 8601 string.
|
// We parsed a valid date simplified ISO 8601 string.
|
||||||
VERIFY(year.has_value()); // A valid date string always has at least a year.
|
VERIFY(year.has_value()); // A valid date string always has at least a year.
|
||||||
auto time = AK::Duration::from_timestamp(*year, month.value_or(1), day.value_or(1), hours.value_or(0), minutes.value_or(0), seconds.value_or(0), milliseconds.value_or(0));
|
auto time = AK::UnixDateTime::from_unix_time_parts(*year, month.value_or(1), day.value_or(1), hours.value_or(0), minutes.value_or(0), seconds.value_or(0), milliseconds.value_or(0));
|
||||||
auto time_ms = static_cast<double>(time.to_milliseconds());
|
auto time_ms = static_cast<double>(time.milliseconds_since_epoch());
|
||||||
|
|
||||||
// https://tc39.es/ecma262/#sec-date.parse:
|
// https://tc39.es/ecma262/#sec-date.parse:
|
||||||
// "When the UTC offset representation is absent, date-only forms are interpreted as a UTC time and date-time forms are interpreted as a local time."
|
// "When the UTC offset representation is absent, date-only forms are interpreted as a UTC time and date-time forms are interpreted as a local time."
|
||||||
|
@ -208,7 +208,7 @@ ThrowCompletionOr<Value> DateConstructor::call()
|
||||||
{
|
{
|
||||||
// 1. If NewTarget is undefined, then
|
// 1. If NewTarget is undefined, then
|
||||||
// a. Let now be the time value (UTC) identifying the current time.
|
// a. Let now be the time value (UTC) identifying the current time.
|
||||||
auto now = AK::Duration::now_realtime().to_milliseconds();
|
auto now = AK::UnixDateTime::now().milliseconds_since_epoch();
|
||||||
|
|
||||||
// b. Return ToDateString(now).
|
// b. Return ToDateString(now).
|
||||||
return PrimitiveString::create(vm(), to_date_string(now));
|
return PrimitiveString::create(vm(), to_date_string(now));
|
||||||
|
@ -225,7 +225,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DateConstructor::construct(FunctionObjec
|
||||||
// 3. If numberOfArgs = 0, then
|
// 3. If numberOfArgs = 0, then
|
||||||
if (vm.argument_count() == 0) {
|
if (vm.argument_count() == 0) {
|
||||||
// a. Let dv be the time value (UTC) identifying the current time.
|
// a. Let dv be the time value (UTC) identifying the current time.
|
||||||
auto now = AK::Duration::now_realtime().to_milliseconds();
|
auto now = AK::UnixDateTime::now().milliseconds_since_epoch();
|
||||||
date_value = static_cast<double>(now);
|
date_value = static_cast<double>(now);
|
||||||
}
|
}
|
||||||
// 4. Else if numberOfArgs = 1, then
|
// 4. Else if numberOfArgs = 1, then
|
||||||
|
|
|
@ -165,7 +165,7 @@ TimeZone* system_time_zone(VM& vm)
|
||||||
BigInt* system_utc_epoch_nanoseconds(VM& vm)
|
BigInt* system_utc_epoch_nanoseconds(VM& vm)
|
||||||
{
|
{
|
||||||
// 1. Let ns be the approximate current UTC date and time, in nanoseconds since the epoch.
|
// 1. Let ns be the approximate current UTC date and time, in nanoseconds since the epoch.
|
||||||
auto now = AK::Duration::now_realtime().to_nanoseconds();
|
auto now = AK::UnixDateTime::now().nanoseconds_since_epoch();
|
||||||
auto ns = Crypto::SignedBigInteger { now };
|
auto ns = Crypto::SignedBigInteger { now };
|
||||||
|
|
||||||
// 2. Set ns to the result of clamping ns between nsMinInstant and nsMaxInstant.
|
// 2. Set ns to the result of clamping ns between nsMinInstant and nsMaxInstant.
|
||||||
|
|
|
@ -140,6 +140,17 @@ Value::Value(Value&& other)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Value::Value(Duration duration)
|
||||||
|
: m_type(SQLType::Integer)
|
||||||
|
, m_value(duration.to_milliseconds())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Value::Value(UnixDateTime time)
|
||||||
|
: Value(time.offset_to_epoch())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Value::~Value() = default;
|
Value::~Value() = default;
|
||||||
|
|
||||||
ResultOr<Value> Value::create_tuple(NonnullRefPtr<TupleDescriptor> descriptor)
|
ResultOr<Value> Value::create_tuple(NonnullRefPtr<TupleDescriptor> descriptor)
|
||||||
|
|
|
@ -57,6 +57,9 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explicit Value(UnixDateTime);
|
||||||
|
explicit Value(Duration);
|
||||||
|
|
||||||
static ResultOr<Value> create_tuple(NonnullRefPtr<TupleDescriptor>);
|
static ResultOr<Value> create_tuple(NonnullRefPtr<TupleDescriptor>);
|
||||||
static ResultOr<Value> create_tuple(Vector<Value>);
|
static ResultOr<Value> create_tuple(Vector<Value>);
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,10 @@
|
||||||
|
|
||||||
namespace Web::Cookie {
|
namespace Web::Cookie {
|
||||||
|
|
||||||
static DeprecatedString time_to_string(Duration const& time)
|
static DeprecatedString time_to_string(UnixDateTime const& time)
|
||||||
{
|
{
|
||||||
auto local_time = Core::DateTime::from_timestamp(time.to_seconds());
|
// FIXME: This roundabout formatting should not be necessary; it also loses precision.
|
||||||
|
auto local_time = Core::DateTime::from_timestamp(time.seconds_since_epoch());
|
||||||
return local_time.to_deprecated_string("%Y-%m-%d %H:%M:%S %Z"sv);
|
return local_time.to_deprecated_string("%Y-%m-%d %H:%M:%S %Z"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,11 +88,11 @@ ErrorOr<Web::Cookie::Cookie> IPC::decode(Decoder& decoder)
|
||||||
auto value = TRY(decoder.decode<DeprecatedString>());
|
auto value = TRY(decoder.decode<DeprecatedString>());
|
||||||
auto domain = TRY(decoder.decode<DeprecatedString>());
|
auto domain = TRY(decoder.decode<DeprecatedString>());
|
||||||
auto path = TRY(decoder.decode<DeprecatedString>());
|
auto path = TRY(decoder.decode<DeprecatedString>());
|
||||||
auto creation_time = TRY(decoder.decode<Duration>());
|
auto creation_time = TRY(decoder.decode<UnixDateTime>());
|
||||||
auto expiry_time = TRY(decoder.decode<Duration>());
|
auto expiry_time = TRY(decoder.decode<UnixDateTime>());
|
||||||
auto host_only = TRY(decoder.decode<bool>());
|
auto host_only = TRY(decoder.decode<bool>());
|
||||||
auto http_only = TRY(decoder.decode<bool>());
|
auto http_only = TRY(decoder.decode<bool>());
|
||||||
auto last_access_time = TRY(decoder.decode<Duration>());
|
auto last_access_time = TRY(decoder.decode<UnixDateTime>());
|
||||||
auto persistent = TRY(decoder.decode<bool>());
|
auto persistent = TRY(decoder.decode<bool>());
|
||||||
auto secure = TRY(decoder.decode<bool>());
|
auto secure = TRY(decoder.decode<bool>());
|
||||||
auto same_site = TRY(decoder.decode<Web::Cookie::SameSite>());
|
auto same_site = TRY(decoder.decode<Web::Cookie::SameSite>());
|
||||||
|
|
|
@ -32,9 +32,9 @@ struct Cookie {
|
||||||
DeprecatedString name;
|
DeprecatedString name;
|
||||||
DeprecatedString value;
|
DeprecatedString value;
|
||||||
SameSite same_site;
|
SameSite same_site;
|
||||||
Duration creation_time {};
|
UnixDateTime creation_time {};
|
||||||
Duration last_access_time {};
|
UnixDateTime last_access_time {};
|
||||||
Duration expiry_time {};
|
UnixDateTime expiry_time {};
|
||||||
DeprecatedString domain {};
|
DeprecatedString domain {};
|
||||||
DeprecatedString path {};
|
DeprecatedString path {};
|
||||||
bool secure { false };
|
bool secure { false };
|
||||||
|
|
|
@ -27,7 +27,7 @@ static void on_path_attribute(ParsedCookie& parsed_cookie, StringView attribute_
|
||||||
static void on_secure_attribute(ParsedCookie& parsed_cookie);
|
static void on_secure_attribute(ParsedCookie& parsed_cookie);
|
||||||
static void on_http_only_attribute(ParsedCookie& parsed_cookie);
|
static void on_http_only_attribute(ParsedCookie& parsed_cookie);
|
||||||
static void on_same_site_attribute(ParsedCookie& parsed_cookie, StringView attribute_value);
|
static void on_same_site_attribute(ParsedCookie& parsed_cookie, StringView attribute_value);
|
||||||
static Optional<Duration> parse_date_time(StringView date_string);
|
static Optional<UnixDateTime> parse_date_time(StringView date_string);
|
||||||
|
|
||||||
Optional<ParsedCookie> parse_cookie(DeprecatedString const& cookie_string)
|
Optional<ParsedCookie> parse_cookie(DeprecatedString const& cookie_string)
|
||||||
{
|
{
|
||||||
|
@ -169,10 +169,10 @@ void on_max_age_attribute(ParsedCookie& parsed_cookie, StringView attribute_valu
|
||||||
if (auto delta_seconds = attribute_value.to_int(); delta_seconds.has_value()) {
|
if (auto delta_seconds = attribute_value.to_int(); delta_seconds.has_value()) {
|
||||||
if (*delta_seconds <= 0) {
|
if (*delta_seconds <= 0) {
|
||||||
// If delta-seconds is less than or equal to zero (0), let expiry-time be the earliest representable date and time.
|
// If delta-seconds is less than or equal to zero (0), let expiry-time be the earliest representable date and time.
|
||||||
parsed_cookie.expiry_time_from_max_age_attribute = Duration::min();
|
parsed_cookie.expiry_time_from_max_age_attribute = UnixDateTime::earliest();
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, let the expiry-time be the current date and time plus delta-seconds seconds.
|
// Otherwise, let the expiry-time be the current date and time plus delta-seconds seconds.
|
||||||
parsed_cookie.expiry_time_from_max_age_attribute = Duration::now_realtime() + Duration::from_seconds(*delta_seconds);
|
parsed_cookie.expiry_time_from_max_age_attribute = UnixDateTime::now() + Duration::from_seconds(*delta_seconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ void on_same_site_attribute(ParsedCookie& parsed_cookie, StringView attribute_va
|
||||||
parsed_cookie.same_site_attribute = same_site_from_string(attribute_value);
|
parsed_cookie.same_site_attribute = same_site_from_string(attribute_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Duration> parse_date_time(StringView date_string)
|
Optional<UnixDateTime> parse_date_time(StringView date_string)
|
||||||
{
|
{
|
||||||
// https://tools.ietf.org/html/rfc6265#section-5.1.1
|
// https://tools.ietf.org/html/rfc6265#section-5.1.1
|
||||||
unsigned hour = 0;
|
unsigned hour = 0;
|
||||||
|
@ -345,7 +345,8 @@ Optional<Duration> parse_date_time(StringView date_string)
|
||||||
// day-of-month-value, the month-value, the year-value, the hour-value, the minute-value, and the second-value, respectively.
|
// day-of-month-value, the month-value, the year-value, the hour-value, the minute-value, and the second-value, respectively.
|
||||||
// If no such date exists, abort these steps and fail to parse the cookie-date.
|
// If no such date exists, abort these steps and fail to parse the cookie-date.
|
||||||
// FIXME: Fail on dates that do not exist.
|
// FIXME: Fail on dates that do not exist.
|
||||||
auto parsed_cookie_date = Duration::from_timestamp(year, month, day_of_month, hour, minute, second, 0);
|
// FIXME: This currently uses UNIX time, which is not equivalent to UTC due to leap seconds.
|
||||||
|
auto parsed_cookie_date = UnixDateTime::from_unix_time_parts(year, month, day_of_month, hour, minute, second, 0);
|
||||||
|
|
||||||
// 7. Return the parsed-cookie-date as the result of this algorithm.
|
// 7. Return the parsed-cookie-date as the result of this algorithm.
|
||||||
return parsed_cookie_date;
|
return parsed_cookie_date;
|
||||||
|
@ -374,8 +375,8 @@ ErrorOr<Web::Cookie::ParsedCookie> IPC::decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
auto name = TRY(decoder.decode<DeprecatedString>());
|
auto name = TRY(decoder.decode<DeprecatedString>());
|
||||||
auto value = TRY(decoder.decode<DeprecatedString>());
|
auto value = TRY(decoder.decode<DeprecatedString>());
|
||||||
auto expiry_time_from_expires_attribute = TRY(decoder.decode<Optional<Duration>>());
|
auto expiry_time_from_expires_attribute = TRY(decoder.decode<Optional<UnixDateTime>>());
|
||||||
auto expiry_time_from_max_age_attribute = TRY(decoder.decode<Optional<Duration>>());
|
auto expiry_time_from_max_age_attribute = TRY(decoder.decode<Optional<UnixDateTime>>());
|
||||||
auto domain = TRY(decoder.decode<Optional<DeprecatedString>>());
|
auto domain = TRY(decoder.decode<Optional<DeprecatedString>>());
|
||||||
auto path = TRY(decoder.decode<Optional<DeprecatedString>>());
|
auto path = TRY(decoder.decode<Optional<DeprecatedString>>());
|
||||||
auto secure_attribute_present = TRY(decoder.decode<bool>());
|
auto secure_attribute_present = TRY(decoder.decode<bool>());
|
||||||
|
|
|
@ -18,8 +18,8 @@ struct ParsedCookie {
|
||||||
DeprecatedString name;
|
DeprecatedString name;
|
||||||
DeprecatedString value;
|
DeprecatedString value;
|
||||||
SameSite same_site_attribute { SameSite::Default };
|
SameSite same_site_attribute { SameSite::Default };
|
||||||
Optional<Duration> expiry_time_from_expires_attribute {};
|
Optional<UnixDateTime> expiry_time_from_expires_attribute {};
|
||||||
Optional<Duration> expiry_time_from_max_age_attribute {};
|
Optional<UnixDateTime> expiry_time_from_max_age_attribute {};
|
||||||
Optional<DeprecatedString> domain {};
|
Optional<DeprecatedString> domain {};
|
||||||
Optional<DeprecatedString> path {};
|
Optional<DeprecatedString> path {};
|
||||||
bool secure_attribute_present { false };
|
bool secure_attribute_present { false };
|
||||||
|
|
|
@ -1651,7 +1651,7 @@ void Document::completely_finish_loading()
|
||||||
VERIFY(browsing_context());
|
VERIFY(browsing_context());
|
||||||
|
|
||||||
// 2. Set document's completely loaded time to the current time.
|
// 2. Set document's completely loaded time to the current time.
|
||||||
m_completely_loaded_time = AK::Duration::now_realtime();
|
m_completely_loaded_time = AK::UnixDateTime::now();
|
||||||
|
|
||||||
// 3. Let container be document's browsing context's container.
|
// 3. Let container be document's browsing context's container.
|
||||||
auto container = JS::make_handle(browsing_context()->container());
|
auto container = JS::make_handle(browsing_context()->container());
|
||||||
|
|
|
@ -612,7 +612,7 @@ private:
|
||||||
JS::GCPtr<HTMLCollection> m_all;
|
JS::GCPtr<HTMLCollection> m_all;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#completely-loaded-time
|
// https://html.spec.whatwg.org/#completely-loaded-time
|
||||||
Optional<AK::Duration> m_completely_loaded_time;
|
Optional<AK::UnixDateTime> m_completely_loaded_time;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/dom.html#concept-document-navigation-id
|
// https://html.spec.whatwg.org/multipage/dom.html#concept-document-navigation-id
|
||||||
Optional<String> m_navigation_id;
|
Optional<String> m_navigation_id;
|
||||||
|
|
|
@ -59,7 +59,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> File::create(JS::Realm& realm, Vecto
|
||||||
|
|
||||||
// 3. If the lastModified member is provided, let d be set to the lastModified dictionary member. If it is not provided, set d to the current date and time represented as the number of milliseconds since the Unix Epoch (which is the equivalent of Date.now() [ECMA-262]).
|
// 3. If the lastModified member is provided, let d be set to the lastModified dictionary member. If it is not provided, set d to the current date and time represented as the number of milliseconds since the Unix Epoch (which is the equivalent of Date.now() [ECMA-262]).
|
||||||
// Note: Since ECMA-262 Date objects convert to long long values representing the number of milliseconds since the Unix Epoch, the lastModified member could be a Date object [ECMA-262].
|
// Note: Since ECMA-262 Date objects convert to long long values representing the number of milliseconds since the Unix Epoch, the lastModified member could be a Date object [ECMA-262].
|
||||||
last_modified = options->last_modified.has_value() ? options->last_modified.value() : Duration::now_realtime().to_milliseconds();
|
last_modified = options->last_modified.has_value() ? options->last_modified.value() : UnixDateTime::now().milliseconds_since_epoch();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Return a new File object F such that:
|
// 4. Return a new File object F such that:
|
||||||
|
|
|
@ -56,7 +56,7 @@ static JsonValue serialize_cookie(Web::Cookie::Cookie const& cookie)
|
||||||
serialized_cookie.set("domain"sv, cookie.domain);
|
serialized_cookie.set("domain"sv, cookie.domain);
|
||||||
serialized_cookie.set("secure"sv, cookie.secure);
|
serialized_cookie.set("secure"sv, cookie.secure);
|
||||||
serialized_cookie.set("httpOnly"sv, cookie.http_only);
|
serialized_cookie.set("httpOnly"sv, cookie.http_only);
|
||||||
serialized_cookie.set("expiry"sv, cookie.expiry_time.to_seconds());
|
serialized_cookie.set("expiry"sv, cookie.expiry_time.seconds_since_epoch());
|
||||||
serialized_cookie.set("sameSite"sv, Web::Cookie::same_site_to_string(cookie.same_site));
|
serialized_cookie.set("sameSite"sv, Web::Cookie::same_site_to_string(cookie.same_site));
|
||||||
|
|
||||||
return serialized_cookie;
|
return serialized_cookie;
|
||||||
|
@ -1602,7 +1602,7 @@ Messages::WebDriverClient::AddCookieResponse WebDriverConnection::add_cookie(Jso
|
||||||
if (data.has("expiry"sv)) {
|
if (data.has("expiry"sv)) {
|
||||||
// NOTE: less than 0 or greater than safe integer are handled by the JSON parser
|
// NOTE: less than 0 or greater than safe integer are handled by the JSON parser
|
||||||
auto expiry = TRY(get_property<u32>(data, "expiry"sv));
|
auto expiry = TRY(get_property<u32>(data, "expiry"sv));
|
||||||
cookie.expiry_time_from_expires_attribute = Duration::from_seconds(expiry);
|
cookie.expiry_time_from_expires_attribute = UnixDateTime::from_seconds_since_epoch(expiry);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cookie same site
|
// Cookie same site
|
||||||
|
@ -2039,7 +2039,7 @@ void WebDriverConnection::delete_cookies(Optional<StringView> const& name)
|
||||||
// -> name is equal to cookie name
|
// -> name is equal to cookie name
|
||||||
if (!name.has_value() || name.value() == cookie.name) {
|
if (!name.has_value() || name.value() == cookie.name) {
|
||||||
// Set the cookie expiry time to a Unix timestamp in the past.
|
// Set the cookie expiry time to a Unix timestamp in the past.
|
||||||
cookie.expiry_time = Duration::from_seconds(0);
|
cookie.expiry_time = UnixDateTime::earliest();
|
||||||
m_page_client.page_did_update_cookie(move(cookie));
|
m_page_client.page_did_update_cookie(move(cookie));
|
||||||
}
|
}
|
||||||
// -> Otherwise
|
// -> Otherwise
|
||||||
|
|
|
@ -63,7 +63,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
||||||
|
|
||||||
auto process_statistics = TRY(Core::ProcessStatisticsReader::get_all());
|
auto process_statistics = TRY(Core::ProcessStatisticsReader::get_all());
|
||||||
|
|
||||||
auto now = Time::now_realtime().to_seconds();
|
auto now = UnixDateTime::now().seconds_since_epoch();
|
||||||
|
|
||||||
if (!hide_header)
|
if (!hide_header)
|
||||||
outln("\033[1m{:10} {:12} {:16} {:6} {}\033[0m", "USER", "TTY", "LOGIN@", "IDLE", "WHAT");
|
outln("\033[1m{:10} {:12} {:16} {:6} {}\033[0m", "USER", "TTY", "LOGIN@", "IDLE", "WHAT");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue