Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Web Compatibility requirements for implementation-defined locale-specific ECMAScript APIs #41760

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ecmascript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ECMAScript tests

This directory contains tests related to the [ECMA-262](https://tc39.es/ecma262/) and [ECMA-402](https://tc39.es/ecma402/) specifications.

Although these specifications are already covered through [Test262](https://github.com/tc39/test262), occasionally it’s useful to have Web Platform Tests coverage for a subset of ECMAScript functionality. Examples include:

- Any functionality that ECMAScript specifies as “implementation-defined” despite Web Compatibility requiring specific semantics. ([example](https://github.com/web-platform-tests/wpt/pull/41760))
- Any ECMAScript functionality that needs to be reported via wpt.fyi (for [example](https://github.com/web-platform-tests/wpt/pull/37928), because it’s included in Interop 2023).
46 changes: 46 additions & 0 deletions ecmascript/locale-compat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<meta charset="utf-8">
<!--
Copyright (C) 2023 the V8 project authors. All rights reserved.
This code is governed by the BSD license found in the LICENSE file.
-->
<title>Web Compatibility requirements for implementation-defined locale-specific JavaScript APIs</title>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I intentionally kept both the file name and the title generic enough, to allow us to add more historical examples of known Web Compat breakages to this file in the future.

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>

test(t => { // https://bugs.chromium.org/p/chromium/issues/detail?id=1414292

const date = new Date('2022-12-31T23:59:42');
const localeString = date.toLocaleString('en-US');

// No U+202F NARROW NO-BREAK SPACE must be present.
assert_false(localeString.includes('\u202F'));
// The character between the time and AM/PM should be U+0020 SPACE.
assert_regexp_match(localeString, /:\d\d:\d\d\x20[AP]M/);

}, '`Date.prototype.toLocaleString` produces U+0020 instead of U+202F for `en-US` locale');

test(t => { // https://bugs.chromium.org/p/chromium/issues/detail?id=1414292

const date = new Date('2022-12-31T23:59:42');
const formatter = new Intl.DateTimeFormat('en', {timeStyle: 'long'})
const formattedString = formatter.format(date);

// No U+202F NARROW NO-BREAK SPACE must be present.
assert_false(formattedString.includes('\u202F'));
// The character between the time and AM/PM should be U+0020 SPACE.
assert_regexp_match(formattedString, /:\d\d:\d\d\x20[AP]M/);

}, '`Intl.DateTimeFormat.prototype.format` produces U+0020 instead of U+202F for `en` locale');

test(t => { // https://bugs.chromium.org/p/chromium/issues/detail?id=1418727

const date = new Date('2022-03-31T23:59:42');

assert_true(date.toLocaleString('en-CA').includes('2022-03-31'));
assert_equals(date.toLocaleString('en-CA', {dateStyle: 'short'}), '2022-03-31');

}, '`Date.prototype.toLocaleString` produces `yyyy-mm-dd` instead of `m/d/yyyy` for `en-CA` locale');

</script>