Commit e5d5b670 authored by mathias's avatar mathias Committed by Commit bot

Ensure `String.prototype.normalize.length` is `0`

TEST=test/intl/string/normalization
BUG=v8:4303
LOG=N

Review URL: https://codereview.chromium.org/1274653002

Cr-Commit-Position: refs/heads/master@{#30030}
parent 0a1a714f
...@@ -1995,14 +1995,16 @@ OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { ...@@ -1995,14 +1995,16 @@ OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
* If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw
* a RangeError Exception. * a RangeError Exception.
*/ */
OverrideFunction(GlobalString.prototype, 'normalize', function(form) {
OverrideFunction(GlobalString.prototype, 'normalize', function() {
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
} }
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
form = IS_UNDEFINED(form) ? 'NFC' : form; var formArg = %_Arguments(0);
var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING_INLINE(formArg);
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
......
...@@ -189,10 +189,11 @@ function StringMatchJS(regexp) { ...@@ -189,10 +189,11 @@ function StringMatchJS(regexp) {
// For now we do nothing, as proper normalization requires big tables. // For now we do nothing, as proper normalization requires big tables.
// If Intl is enabled, then i18n.js will override it and provide the the // If Intl is enabled, then i18n.js will override it and provide the the
// proper functionality. // proper functionality.
function StringNormalizeJS(form) { function StringNormalizeJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
var form = IS_UNDEFINED(form) ? 'NFC' : TO_STRING_INLINE(form); var formArg = %_Arguments(0);
var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING_INLINE(formArg);
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
var normalizationForm = var normalizationForm =
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
// Tests the new String.prototype.normalize method. // Tests the new String.prototype.normalize method.
assertEquals(String.prototype.normalize.length, 0);
assertEquals(String.prototype.propertyIsEnumerable("normalize"), false);
// Common use case when searching for 'not very exact' match. // Common use case when searching for 'not very exact' match.
// These are examples of data one might encounter in real use. // These are examples of data one might encounter in real use.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment