@@ -722,13 +722,7 @@ func TestSetKeyRetrievers_SatisfiesInterface(t *testing.T) {
722722 } = (* Browser )(nil )
723723}
724724
725- // ---------------------------------------------------------------------------
726- // timeEpoch
727- // ---------------------------------------------------------------------------
728-
729- // Anchor: 2024-01-15T10:30:00Z = Unix seconds 1705314600. Chromium stores
730- // this as microseconds since 1601-01-01 UTC, so the stored value is
731- // (1705314600 + 11644473600) * 1e6.
725+ // Anchor: 2024-01-15T10:30:00Z as Chromium microseconds since 1601 UTC.
732726const anchorUnixSeconds = int64 (1705314600 )
733727
734728var anchorChromiumMicros = (anchorUnixSeconds + 11644473600 ) * 1_000_000
@@ -741,41 +735,30 @@ func TestTimeEpoch_AnchorDate(t *testing.T) {
741735}
742736
743737func TestTimeEpoch_ZeroReturnsZeroTime (t * testing.T ) {
744- // Chromium uses 0 for session cookies (no persistent expiry).
745738 assert .True (t , timeEpoch (0 ).IsZero ())
746739}
747740
748741func TestTimeEpoch_NegativeReturnsZeroTime (t * testing.T ) {
749- // -1 is the legacy "never expires" sentinel on older profiles.
750742 assert .True (t , timeEpoch (- 1 ).IsZero ())
751743}
752744
753745func TestTimeEpoch_AlwaysUTC (t * testing.T ) {
754- // Location must be UTC regardless of the test runner's TZ. Set a
755- // non-UTC local zone via t.Setenv so the assertion catches any
756- // accidental time.Local usage.
757746 t .Setenv ("TZ" , "Asia/Shanghai" )
758747 got := timeEpoch (anchorChromiumMicros )
759748 assert .Equal (t , time .UTC , got .Location ())
760749}
761750
762751func TestTimeEpoch_MicrosecondPrecisionPreserved (t * testing.T ) {
763- // Add 123456 μs to the anchor and confirm the nanosecond component
764- // survives the conversion (no silent truncation to seconds).
765752 got := timeEpoch (anchorChromiumMicros + 123456 )
766753 assert .Equal (t , 123456 * int64 (time .Microsecond ), int64 (got .Nanosecond ()))
767754}
768755
769756func TestTimeEpoch_UnixEpochBoundary (t * testing.T ) {
770- // Exactly the offset constant → 1970-01-01T00:00:00 UTC.
771757 got := timeEpoch (chromiumEpochOffsetMicros )
772758 assert .Equal (t , time .Unix (0 , 0 ).UTC (), got )
773759}
774760
775761func TestTimeEpoch_OutOfJSONRangeReturnsZero (t * testing.T ) {
776- // Some sites write nonsense "never expires" sentinels that compute
777- // to years past 9999. time.Time.MarshalJSON would crash on those;
778- // the helper must defensively return zero so JSON export works.
779762 jsonBytes , err := timeEpoch (1 << 62 ).MarshalJSON ()
780763 require .NoError (t , err )
781764 assert .JSONEq (t , `"0001-01-01T00:00:00Z"` , string (jsonBytes ))
0 commit comments