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
Changes from 1 commit
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
37 changes: 37 additions & 0 deletions ecmascript/locale-compat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!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');

</script>