-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: Add tests for fast path in ToTemporalTimeZone
Normally, a plain object passed into an API that takes a Temporal.TimeZone has its 'timeZone' property checked (observably) with a Has operation followed by a Get operation if the property is present. In the normative change tc39/proposal-temporal#2392 which reached consensus at the September 2022 TC39 meeting, this was changed so that this check is skipped for objects which have the Temporal.TimeZone internal slots. This adds tests to all entry points that pass a user-supplied object to ToTemporalTimeZone, with a "poisoned" timeZone object which has the correct internal slots but a 'timeZone' accessor property whose getter throws. A correct implementation should not cause this getter to throw.
- Loading branch information
Showing
26 changed files
with
551 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...ration/compare/relativeto-propertybag-timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.duration.compare | ||
description: > | ||
A Temporal.TimeZone instance passed to compare() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); | ||
Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }); |
22 changes: 22 additions & 0 deletions
22
.../prototype/add/relativeto-propertybag-timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.duration.prototype.add | ||
description: > | ||
A Temporal.TimeZone instance passed to add() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.Duration(1); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); | ||
instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }); |
22 changes: 22 additions & 0 deletions
22
...rototype/round/relativeto-propertybag-timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.duration.prototype.round | ||
description: > | ||
A Temporal.TimeZone instance passed to round() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.Duration(1); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); | ||
instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }); |
22 changes: 22 additions & 0 deletions
22
...otype/subtract/relativeto-propertybag-timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.duration.prototype.subtract | ||
description: > | ||
A Temporal.TimeZone instance passed to subtract() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.Duration(1); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); | ||
instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }); |
22 changes: 22 additions & 0 deletions
22
...rototype/total/relativeto-propertybag-timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.duration.prototype.total | ||
description: > | ||
A Temporal.TimeZone instance passed to total() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.Duration(1); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); | ||
instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }); |
22 changes: 22 additions & 0 deletions
22
...s/Temporal/Instant/prototype/toString/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.instant.prototype.tostring | ||
description: > | ||
A Temporal.TimeZone instance passed to toString() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.Instant(0n); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.toString({ timeZone }); | ||
instance.toString({ timeZone: { timeZone } }); |
22 changes: 22 additions & 0 deletions
22
...ral/Instant/prototype/toZonedDateTime/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.instant.prototype.tozoneddatetime | ||
description: > | ||
A Temporal.TimeZone instance passed to toZonedDateTime() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.Instant(0n); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); | ||
instance.toZonedDateTime({ timeZone: { timeZone }, calendar: "iso8601" }); |
22 changes: 22 additions & 0 deletions
22
.../Instant/prototype/toZonedDateTimeISO/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.instant.prototype.tozoneddatetimeiso | ||
description: > | ||
A Temporal.TimeZone instance passed to toZonedDateTimeISO() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.Instant(0n); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.toZonedDateTimeISO(timeZone); | ||
instance.toZonedDateTimeISO({ timeZone }); |
20 changes: 20 additions & 0 deletions
20
test/built-ins/Temporal/Now/plainDate/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.now.plaindate | ||
description: > | ||
A Temporal.TimeZone instance passed to plainDate() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
Temporal.Now.plainDate("iso8601", timeZone); | ||
Temporal.Now.plainDate("iso8601", { timeZone }); |
20 changes: 20 additions & 0 deletions
20
test/built-ins/Temporal/Now/plainDateISO/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.now.plaindateiso | ||
description: > | ||
A Temporal.TimeZone instance passed to plainDateISO() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
Temporal.Now.plainDateISO(timeZone); | ||
Temporal.Now.plainDateISO({ timeZone }); |
20 changes: 20 additions & 0 deletions
20
.../built-ins/Temporal/Now/plainDateTime/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.now.plaindatetime | ||
description: > | ||
A Temporal.TimeZone instance passed to plainDateTime() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
Temporal.Now.plainDateTime("iso8601", timeZone); | ||
Temporal.Now.plainDateTime("iso8601", { timeZone }); |
20 changes: 20 additions & 0 deletions
20
...ilt-ins/Temporal/Now/plainDateTimeISO/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.now.plaindatetimeiso | ||
description: > | ||
A Temporal.TimeZone instance passed to plainDateTimeISO() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
Temporal.Now.plainDateTimeISO(timeZone); | ||
Temporal.Now.plainDateTimeISO({ timeZone }); |
20 changes: 20 additions & 0 deletions
20
test/built-ins/Temporal/Now/plainTimeISO/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.now.plaintimeiso | ||
description: > | ||
A Temporal.TimeZone instance passed to plainTimeISO() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
Temporal.Now.plainTimeISO(timeZone); | ||
Temporal.Now.plainTimeISO({ timeZone }); |
20 changes: 20 additions & 0 deletions
20
.../built-ins/Temporal/Now/zonedDateTime/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.now.zoneddatetime | ||
description: > | ||
A Temporal.TimeZone instance passed to zonedDateTime() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
Temporal.Now.zonedDateTime("iso8601", timeZone); | ||
Temporal.Now.zonedDateTime("iso8601", { timeZone }); |
20 changes: 20 additions & 0 deletions
20
...ilt-ins/Temporal/Now/zonedDateTimeISO/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.now.zoneddatetimeiso | ||
description: > | ||
A Temporal.TimeZone instance passed to zonedDateTimeISO() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
Temporal.Now.zonedDateTimeISO(timeZone); | ||
Temporal.Now.zonedDateTimeISO({ timeZone }); |
22 changes: 22 additions & 0 deletions
22
...l/PlainDate/prototype/toZonedDateTime/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plaindate.prototype.tozoneddatetime | ||
description: > | ||
A Temporal.TimeZone instance passed to toZonedDateTime() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.PlainDate(2000, 5, 2); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.toZonedDateTime(timeZone); | ||
instance.toZonedDateTime({ timeZone }); |
22 changes: 22 additions & 0 deletions
22
...ainDateTime/prototype/toZonedDateTime/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plaindatetime.prototype.tozoneddatetime | ||
description: > | ||
A Temporal.TimeZone instance passed to toZonedDateTime() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.PlainDateTime(2000, 5, 2); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.toZonedDateTime(timeZone); | ||
instance.toZonedDateTime({ timeZone }); |
22 changes: 22 additions & 0 deletions
22
...l/PlainTime/prototype/toZonedDateTime/timezone-instance-does-not-get-timeZone-property.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plaintime.prototype.tozoneddatetime | ||
description: > | ||
A Temporal.TimeZone instance passed to toZonedDateTime() does not have its | ||
'timeZone' property observably checked | ||
features: [Temporal] | ||
---*/ | ||
|
||
const instance = new Temporal.PlainTime(); | ||
|
||
const timeZone = new Temporal.TimeZone("UTC"); | ||
Object.defineProperty(timeZone, "timeZone", { | ||
get() { | ||
throw new Test262Error("timeZone.timeZone should not be accessed"); | ||
}, | ||
}); | ||
|
||
instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); | ||
instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone: { timeZone } }); |
Oops, something went wrong.