From e5d5b6700569cd82b389d11e7bc29776911401e5 Mon Sep 17 00:00:00 2001 From: mathias Date: Wed, 5 Aug 2015 08:11:10 -0700 Subject: [PATCH] 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} --- src/i18n.js | 6 ++++-- src/string.js | 5 +++-- test/intl/string/normalization.js | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/i18n.js b/src/i18n.js index 1028bbb..53cc487 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -1995,14 +1995,16 @@ OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw * a RangeError Exception. */ -OverrideFunction(GlobalString.prototype, 'normalize', function(form) { + +OverrideFunction(GlobalString.prototype, 'normalize', function() { if (%_IsConstructCall()) { throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); } 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']; diff --git a/src/string.js b/src/string.js index b543a8e..dd2b9d7 100644 --- a/src/string.js +++ b/src/string.js @@ -189,10 +189,11 @@ function StringMatchJS(regexp) { // 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 // proper functionality. -function StringNormalizeJS(form) { +function StringNormalizeJS() { 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 normalizationForm = diff --git a/test/intl/string/normalization.js b/test/intl/string/normalization.js index 446d627..25d314e 100644 --- a/test/intl/string/normalization.js +++ b/test/intl/string/normalization.js @@ -27,6 +27,8 @@ // 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. // These are examples of data one might encounter in real use. -- 2.7.4