<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194394] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194394">194394</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-12-23 12:02:37 -0800 (Wed, 23 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[INTL] Implement String.prototype.localeCompare in ECMA-402
https://bugs.webkit.org/show_bug.cgi?id=147607

Patch by Andy VanWagoner &lt;thetalecrafter@gmail.com&gt; on 2015-12-23
Reviewed by Benjamin Poulain.

Source/JavaScriptCore:

Add localeCompare in builtin JavaScript that delegates comparing to Intl.Collator.
Keep existing native implementation for use if INTL flag is disabled.
For the common case where no locale or options are specified, avoid creating
a new collator and just use the prototype which is initialized with the defaults.

* CMakeLists.txt:
* DerivedSources.make:
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/StringPrototype.js: Added.
(localeCompare):
* runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):

LayoutTests:

* js/script-tests/string-localeCompare.js:
* js/script-tests/string-prototype-properties.js: Update error message.
* js/string-localeCompare-expected.txt:
* js/string-prototype-properties-expected.txt: Update error message.
* js/string-localeCompare.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsdomscripttestsstringprototypepropertiesjs">trunk/LayoutTests/js/dom/script-tests/string-prototype-properties.js</a></li>
<li><a href="#trunkLayoutTestsjsdomstringprototypepropertiesexpectedtxt">trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsstringlocaleComparejs">trunk/LayoutTests/js/script-tests/string-localeCompare.js</a></li>
<li><a href="#trunkLayoutTestsjsstringlocaleCompareexpectedtxt">trunk/LayoutTests/js/string-localeCompare-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsstringlocaleComparehtml">trunk/LayoutTests/js/string-localeCompare.html</a></li>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreDerivedSourcesmake">trunk/Source/JavaScriptCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeStringPrototypecpp">trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCorebuiltinsStringPrototypejs">trunk/Source/JavaScriptCore/builtins/StringPrototype.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/LayoutTests/ChangeLog        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-12-23  Andy VanWagoner  &lt;thetalecrafter@gmail.com&gt;
+
+        [INTL] Implement String.prototype.localeCompare in ECMA-402
+        https://bugs.webkit.org/show_bug.cgi?id=147607
+
+        Reviewed by Benjamin Poulain.
+
+        * js/script-tests/string-localeCompare.js:
+        * js/script-tests/string-prototype-properties.js: Update error message.
+        * js/string-localeCompare-expected.txt:
+        * js/string-prototype-properties-expected.txt: Update error message.
+        * js/string-localeCompare.html:
+
</ins><span class="cx"> 2015-12-23  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rebaselining fast/text/emoji.html for Windows
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomscripttestsstringprototypepropertiesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/script-tests/string-prototype-properties.js (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/script-tests/string-prototype-properties.js        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/LayoutTests/js/dom/script-tests/string-prototype-properties.js        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> shouldThrow(&quot;String.prototype.substring.call(undefined, 1, 3)&quot;);
</span><span class="cx"> shouldThrow(&quot;String.prototype.toLowerCase.call(undefined)&quot;);
</span><span class="cx"> shouldThrow(&quot;String.prototype.toUpperCase.call(undefined)&quot;);
</span><del>-shouldThrow(&quot;String.prototype.localeCompare.call(undefined, '1224')&quot;);
</del><ins>+shouldThrow(&quot;String.prototype.localeCompare.call(undefined, '1224')&quot;, &quot;'TypeError: String.prototype.localeCompare requires that |this| not be undefined'&quot;);
</ins><span class="cx"> shouldThrow(&quot;String.prototype.toLocaleLowerCase.call(undefined)&quot;);
</span><span class="cx"> shouldThrow(&quot;String.prototype.toLocaleUpperCase.call(undefined)&quot;);
</span><span class="cx"> shouldThrow(&quot;String.prototype.trim.call(undefined)&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomstringprototypepropertiesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> PASS String.prototype.substring.call(undefined, 1, 3) threw exception TypeError: Type error.
</span><span class="cx"> PASS String.prototype.toLowerCase.call(undefined) threw exception TypeError: Type error.
</span><span class="cx"> PASS String.prototype.toUpperCase.call(undefined) threw exception TypeError: Type error.
</span><del>-PASS String.prototype.localeCompare.call(undefined, '1224') threw exception TypeError: Type error.
</del><ins>+PASS String.prototype.localeCompare.call(undefined, '1224') threw exception TypeError: String.prototype.localeCompare requires that |this| not be undefined.
</ins><span class="cx"> PASS String.prototype.toLocaleLowerCase.call(undefined) threw exception TypeError: Type error.
</span><span class="cx"> PASS String.prototype.toLocaleUpperCase.call(undefined) threw exception TypeError: Type error.
</span><span class="cx"> PASS String.prototype.trim.call(undefined) threw exception TypeError: Type error.
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsstringlocaleComparejs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/string-localeCompare.js (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/string-localeCompare.js        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/LayoutTests/js/script-tests/string-localeCompare.js        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -1,5 +1,28 @@
</span><del>-description(&quot;This test checks String.localeCompare().&quot;);
</del><ins>+description(&quot;This test checks the behavior of String.prototype.localeCompare as described in the ECMAScript Internationalization API Specification (ECMA-402 2.0).&quot;);
</ins><span class="cx"> 
</span><ins>+shouldBe(&quot;String.prototype.localeCompare.length&quot;, &quot;1&quot;);
+shouldBeFalse(&quot;Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').enumerable&quot;);
+shouldBeTrue(&quot;Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').configurable&quot;);
+shouldBeTrue(&quot;Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').writable&quot;);
+
+// Test RequireObjectCoercible.
+shouldThrow(&quot;String.prototype.localeCompare.call()&quot;, &quot;'TypeError: String.prototype.localeCompare requires that |this| not be undefined'&quot;);
+shouldThrow(&quot;String.prototype.localeCompare.call(undefined)&quot;, &quot;'TypeError: String.prototype.localeCompare requires that |this| not be undefined'&quot;);
+shouldThrow(&quot;String.prototype.localeCompare.call(null)&quot;, &quot;'TypeError: String.prototype.localeCompare requires that |this| not be null'&quot;);
+shouldNotThrow(&quot;String.prototype.localeCompare.call({}, '')&quot;);
+shouldNotThrow(&quot;String.prototype.localeCompare.call([], '')&quot;);
+shouldNotThrow(&quot;String.prototype.localeCompare.call(NaN, '')&quot;);
+shouldNotThrow(&quot;String.prototype.localeCompare.call(5, '')&quot;);
+shouldNotThrow(&quot;String.prototype.localeCompare.call('', '')&quot;);
+shouldNotThrow(&quot;String.prototype.localeCompare.call(() =&gt; {}, '')&quot;);
+
+// Test toString fails.
+shouldThrow(&quot;''.localeCompare.call({ toString() { throw 'thisFail' } }, '')&quot;, &quot;'thisFail'&quot;);
+shouldThrow(&quot;''.localeCompare({ toString() { throw 'thatFail' } })&quot;, &quot;'thatFail'&quot;);
+shouldNotThrow(&quot;''.localeCompare()&quot;);
+shouldNotThrow(&quot;''.localeCompare(null)&quot;);
+
+// Basic support.
</ins><span class="cx"> shouldBeTrue('&quot;a&quot;.localeCompare(&quot;aa&quot;) &lt; 0');
</span><span class="cx"> shouldBeTrue('&quot;a&quot;.localeCompare(&quot;b&quot;) &lt; 0');
</span><span class="cx"> 
</span><span class="lines">@@ -8,3 +31,45 @@
</span><span class="cx"> 
</span><span class="cx"> shouldBeTrue('&quot;aa&quot;.localeCompare(&quot;a&quot;) &gt; 0');
</span><span class="cx"> shouldBeTrue('&quot;b&quot;.localeCompare(&quot;a&quot;) &gt; 0');
</span><ins>+
+// Uses Intl.Collator.
+shouldThrow(&quot;'a'.localeCompare('b', '$')&quot;, &quot;'RangeError: invalid language tag: $'&quot;);
+shouldThrow(&quot;'a'.localeCompare('b', 'en', {usage: 'Sort'})&quot;, '\'RangeError: usage must be either &quot;sort&quot; or &quot;search&quot;\'');
+
+shouldBe(&quot;'ä'.localeCompare('z', 'en')&quot;, &quot;-1&quot;);
+shouldBe(&quot;'ä'.localeCompare('z', 'sv')&quot;, &quot;1&quot;);
+
+shouldBe(&quot;'a'.localeCompare('b', 'en', { sensitivity:'base' })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'a'.localeCompare('ä', 'en', { sensitivity:'base' })&quot;, &quot;0&quot;);
+shouldBe(&quot;'a'.localeCompare('A', 'en', { sensitivity:'base' })&quot;, &quot;0&quot;);
+shouldBe(&quot;'a'.localeCompare('ⓐ', 'en', { sensitivity:'base' })&quot;, &quot;0&quot;);
+
+shouldBe(&quot;'a'.localeCompare('b', 'en', { sensitivity:'accent' })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'a'.localeCompare('ä', 'en', { sensitivity:'accent' })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'a'.localeCompare('A', 'en', { sensitivity:'accent' })&quot;, &quot;0&quot;);
+shouldBe(&quot;'a'.localeCompare('ⓐ', 'en', { sensitivity:'accent' })&quot;, &quot;0&quot;);
+
+shouldBe(&quot;'a'.localeCompare('b', 'en', { sensitivity:'case' })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'a'.localeCompare('ä', 'en', { sensitivity:'case' })&quot;, &quot;0&quot;);
+shouldBe(&quot;'a'.localeCompare('A', 'en', { sensitivity:'case' })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'a'.localeCompare('ⓐ', 'en', { sensitivity:'case' })&quot;, &quot;0&quot;);
+
+shouldBe(&quot;'a'.localeCompare('b', 'en', { sensitivity:'variant' })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'a'.localeCompare('ä', 'en', { sensitivity:'variant' })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'a'.localeCompare('A', 'en', { sensitivity:'variant' })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'a'.localeCompare('ⓐ', 'en', { sensitivity:'variant' })&quot;, &quot;-1&quot;);
+
+shouldBe(&quot;'1'.localeCompare('2', 'en', { numeric:false })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'2'.localeCompare('10', 'en', { numeric:false })&quot;, &quot;1&quot;);
+shouldBe(&quot;'01'.localeCompare('1', 'en', { numeric:false })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'๑'.localeCompare('๒', 'en', { numeric:false })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'๒'.localeCompare('๑๐', 'en', { numeric:false })&quot;, &quot;1&quot;);
+shouldBe(&quot;'๐๑'.localeCompare('๑', 'en', { numeric:false })&quot;, &quot;-1&quot;);
+
+shouldBe(&quot;'1'.localeCompare('2', 'en', { numeric:true })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'2'.localeCompare('10', 'en', { numeric:true })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'01'.localeCompare('1', 'en', { numeric:true })&quot;, &quot;0&quot;);
+shouldBe(&quot;'๑'.localeCompare('๒', 'en', { numeric:true })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'๒'.localeCompare('๑๐', 'en', { numeric:true })&quot;, &quot;-1&quot;);
+shouldBe(&quot;'๐๑'.localeCompare('๑', 'en', { numeric:true })&quot;, &quot;0&quot;);
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsstringlocaleCompareexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/string-localeCompare-expected.txt (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/string-localeCompare-expected.txt        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/LayoutTests/js/string-localeCompare-expected.txt        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -1,14 +1,63 @@
</span><del>-This test checks String.localeCompare().
</del><ins>+This test checks the behavior of String.prototype.localeCompare as described in the ECMAScript Internationalization API Specification (ECMA-402 2.0).
</ins><span class="cx"> 
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+PASS String.prototype.localeCompare.length is 1
+PASS Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').enumerable is false
+PASS Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').configurable is true
+PASS Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').writable is true
+PASS String.prototype.localeCompare.call() threw exception TypeError: String.prototype.localeCompare requires that |this| not be undefined.
+PASS String.prototype.localeCompare.call(undefined) threw exception TypeError: String.prototype.localeCompare requires that |this| not be undefined.
+PASS String.prototype.localeCompare.call(null) threw exception TypeError: String.prototype.localeCompare requires that |this| not be null.
+PASS String.prototype.localeCompare.call({}, '') did not throw exception.
+PASS String.prototype.localeCompare.call([], '') did not throw exception.
+PASS String.prototype.localeCompare.call(NaN, '') did not throw exception.
+PASS String.prototype.localeCompare.call(5, '') did not throw exception.
+PASS String.prototype.localeCompare.call('', '') did not throw exception.
+PASS String.prototype.localeCompare.call(() =&gt; {}, '') did not throw exception.
+PASS ''.localeCompare.call({ toString() { throw 'thisFail' } }, '') threw exception thisFail.
+PASS ''.localeCompare({ toString() { throw 'thatFail' } }) threw exception thatFail.
+PASS ''.localeCompare() did not throw exception.
+PASS ''.localeCompare(null) did not throw exception.
</ins><span class="cx"> PASS &quot;a&quot;.localeCompare(&quot;aa&quot;) &lt; 0 is true
</span><span class="cx"> PASS &quot;a&quot;.localeCompare(&quot;b&quot;) &lt; 0 is true
</span><span class="cx"> PASS &quot;a&quot;.localeCompare(&quot;a&quot;) === 0 is true
</span><span class="cx"> PASS &quot;ạ̈&quot;.localeCompare(&quot;ạ̈&quot;) === 0 is true
</span><span class="cx"> PASS &quot;aa&quot;.localeCompare(&quot;a&quot;) &gt; 0 is true
</span><span class="cx"> PASS &quot;b&quot;.localeCompare(&quot;a&quot;) &gt; 0 is true
</span><ins>+PASS 'a'.localeCompare('b', '$') threw exception RangeError: invalid language tag: $.
+PASS 'a'.localeCompare('b', 'en', {usage: 'Sort'}) threw exception RangeError: usage must be either &quot;sort&quot; or &quot;search&quot;.
+PASS 'ä'.localeCompare('z', 'en') is -1
+PASS 'ä'.localeCompare('z', 'sv') is 1
+PASS 'a'.localeCompare('b', 'en', { sensitivity:'base' }) is -1
+PASS 'a'.localeCompare('ä', 'en', { sensitivity:'base' }) is 0
+PASS 'a'.localeCompare('A', 'en', { sensitivity:'base' }) is 0
+PASS 'a'.localeCompare('ⓐ', 'en', { sensitivity:'base' }) is 0
+PASS 'a'.localeCompare('b', 'en', { sensitivity:'accent' }) is -1
+PASS 'a'.localeCompare('ä', 'en', { sensitivity:'accent' }) is -1
+PASS 'a'.localeCompare('A', 'en', { sensitivity:'accent' }) is 0
+PASS 'a'.localeCompare('ⓐ', 'en', { sensitivity:'accent' }) is 0
+PASS 'a'.localeCompare('b', 'en', { sensitivity:'case' }) is -1
+PASS 'a'.localeCompare('ä', 'en', { sensitivity:'case' }) is 0
+PASS 'a'.localeCompare('A', 'en', { sensitivity:'case' }) is -1
+PASS 'a'.localeCompare('ⓐ', 'en', { sensitivity:'case' }) is 0
+PASS 'a'.localeCompare('b', 'en', { sensitivity:'variant' }) is -1
+PASS 'a'.localeCompare('ä', 'en', { sensitivity:'variant' }) is -1
+PASS 'a'.localeCompare('A', 'en', { sensitivity:'variant' }) is -1
+PASS 'a'.localeCompare('ⓐ', 'en', { sensitivity:'variant' }) is -1
+PASS '1'.localeCompare('2', 'en', { numeric:false }) is -1
+PASS '2'.localeCompare('10', 'en', { numeric:false }) is 1
+PASS '01'.localeCompare('1', 'en', { numeric:false }) is -1
+PASS '๑'.localeCompare('๒', 'en', { numeric:false }) is -1
+PASS '๒'.localeCompare('๑๐', 'en', { numeric:false }) is 1
+PASS '๐๑'.localeCompare('๑', 'en', { numeric:false }) is -1
+PASS '1'.localeCompare('2', 'en', { numeric:true }) is -1
+PASS '2'.localeCompare('10', 'en', { numeric:true }) is -1
+PASS '01'.localeCompare('1', 'en', { numeric:true }) is 0
+PASS '๑'.localeCompare('๒', 'en', { numeric:true }) is -1
+PASS '๒'.localeCompare('๑๐', 'en', { numeric:true }) is -1
+PASS '๐๑'.localeCompare('๑', 'en', { numeric:true }) is 0
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsjsstringlocaleComparehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/string-localeCompare.html (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/string-localeCompare.html        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/LayoutTests/js/string-localeCompare.html        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -1,6 +1,7 @@
</span><span class="cx"> &lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
</span><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;head&gt;
</span><ins>+&lt;meta charset=&quot;utf-8&quot;&gt;
</ins><span class="cx"> &lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -1251,6 +1251,7 @@
</span><span class="cx">     ${JAVASCRIPTCORE_DIR}/builtins/ReflectObject.js
</span><span class="cx">     ${JAVASCRIPTCORE_DIR}/builtins/StringConstructor.js
</span><span class="cx">     ${JAVASCRIPTCORE_DIR}/builtins/StringIteratorPrototype.js
</span><ins>+    ${JAVASCRIPTCORE_DIR}/builtins/StringPrototype.js
</ins><span class="cx">     ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayConstructor.js
</span><span class="cx">     ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayPrototype.js
</span><span class="cx"> )
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2015-12-23  Andy VanWagoner  &lt;thetalecrafter@gmail.com&gt;
+
+        [INTL] Implement String.prototype.localeCompare in ECMA-402
+        https://bugs.webkit.org/show_bug.cgi?id=147607
+
+        Reviewed by Benjamin Poulain.
+
+        Add localeCompare in builtin JavaScript that delegates comparing to Intl.Collator.
+        Keep existing native implementation for use if INTL flag is disabled.
+        For the common case where no locale or options are specified, avoid creating
+        a new collator and just use the prototype which is initialized with the defaults.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * builtins/StringPrototype.js: Added.
+        (localeCompare):
+        * runtime/StringPrototype.cpp:
+        (JSC::StringPrototype::finishCreation):
+
</ins><span class="cx"> 2015-12-23  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix x86_64 after r194388
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/DerivedSources.make (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/DerivedSources.make        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/Source/JavaScriptCore/DerivedSources.make        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx">     $(JavaScriptCore)/builtins/ReflectObject.js \
</span><span class="cx">     $(JavaScriptCore)/builtins/StringConstructor.js \
</span><span class="cx">     $(JavaScriptCore)/builtins/StringIteratorPrototype.js \
</span><ins>+    $(JavaScriptCore)/builtins/StringPrototype.js \
</ins><span class="cx">     $(JavaScriptCore)/builtins/TypedArrayConstructor.js \
</span><span class="cx">     $(JavaScriptCore)/builtins/TypedArrayPrototype.js \
</span><span class="cx"> #
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -2059,7 +2059,7 @@
</span><span class="cx">                 FE99B24A1C24C3D700C82159 /* JITNegGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE99B2471C24B6D300C82159 /* JITNegGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
</span><span class="cx">                 FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861E182B7A0400F6D851 /* Breakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FEA08621182B7A0400F6D851 /* DebuggerPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                FEA1E4391C213A2B00277A16 /* ValueProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEA1E4381C213A2600277A16 /* ValueProfile.cpp */; settings = {ASSET_TAGS = (); }; };
</del><ins>+                FEA1E4391C213A2B00277A16 /* ValueProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEA1E4381C213A2600277A16 /* ValueProfile.cpp */; };
</ins><span class="cx">                 FEB137571BB11EF900CD5100 /* MacroAssemblerARM64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */; };
</span><span class="cx">                 FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */ = {isa = PBXBuildFile; fileRef = FEB51F6B1A97B688001F921C /* Regress141809.mm */; };
</span><span class="cx">                 FEB58C14187B8B160098EF0B /* ErrorHandlingScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEB58C12187B8B160098EF0B /* ErrorHandlingScope.cpp */; };
</span><span class="lines">@@ -3681,6 +3681,7 @@
</span><span class="cx">                 A1D792F91B43864B004516F5 /* IntlNumberFormatConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntlNumberFormatConstructor.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A1D792FA1B43864B004516F5 /* IntlNumberFormatPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntlNumberFormatPrototype.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A1D792FB1B43864B004516F5 /* IntlNumberFormatPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntlNumberFormatPrototype.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                A1E0451B1C25B4B100BB663C /* StringPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = StringPrototype.js; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 A503FA13188E0FAF00110F14 /* JavaScriptCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JavaScriptCallFrame.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A503FA14188E0FAF00110F14 /* JavaScriptCallFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptCallFrame.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A503FA15188E0FB000110F14 /* JSJavaScriptCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSJavaScriptCallFrame.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -6781,6 +6782,7 @@
</span><span class="cx">                                 7CF9BC5F1B65D9B1009DB1EF /* ReflectObject.js */,
</span><span class="cx">                                 7CF9BC601B65D9B1009DB1EF /* StringConstructor.js */,
</span><span class="cx">                                 7CF9BC611B65D9B1009DB1EF /* StringIteratorPrototype.js */,
</span><ins>+                                A1E0451B1C25B4B100BB663C /* StringPrototype.js */,
</ins><span class="cx">                                 53917E831B791CB8000EBD33 /* TypedArrayPrototype.js */,
</span><span class="cx">                                 534C457A1BC703DC007476A7 /* TypedArrayConstructor.js */,
</span><span class="cx">                         );
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsStringPrototypejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/builtins/StringPrototype.js (0 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/StringPrototype.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/builtins/StringPrototype.js        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+/*
+ * Copyright (C) 2015 Andy VanWagoner &lt;thetalecrafter@gmail.com&gt;.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// @conditional=ENABLE(INTL)
+
+function localeCompare(that/*, locales, options */)
+{
+    &quot;use strict&quot;;
+
+    // 13.1.1 String.prototype.localeCompare (that [, locales [, options ]]) (ECMA-402 2.0)
+    // http://ecma-international.org/publications/standards/Ecma-402.htm
+
+    // 1. Let O be RequireObjectCoercible(this value).
+    if (this === null)
+        throw new @TypeError(&quot;String.prototype.localeCompare requires that |this| not be null&quot;);
+    
+    if (this === undefined)
+        throw new @TypeError(&quot;String.prototype.localeCompare requires that |this| not be undefined&quot;);
+
+    // 2. Let S be ToString(O).
+    // 3. ReturnIfAbrupt(S).
+    var thisString = @toString(this);
+
+    // 4. Let That be ToString(that).
+    // 5. ReturnIfAbrupt(That).
+    var thatString = @toString(that);
+
+    // Avoid creating a collator for defaults.
+    if (arguments[1] === undefined &amp;&amp; arguments[2] === undefined)
+        return @Collator.prototype.compare(thisString, thatString);
+
+    // 6. Let collator be Construct(%Collator%, «locales, options»).
+    // 7. ReturnIfAbrupt(collator).
+    var collator = new @Collator(arguments[1], arguments[2]);
+
+    // 8. Return CompareStrings(collator, S, That).
+    return collator.compare(thisString, thatString);
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeStringPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp (194393 => 194394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp        2015-12-23 19:15:13 UTC (rev 194393)
+++ trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp        2015-12-23 20:02:37 UTC (rev 194394)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;Error.h&quot;
</span><span class="cx"> #include &quot;Executable.h&quot;
</span><span class="cx"> #include &quot;IntlObject.h&quot;
</span><ins>+#include &quot;JSCBuiltins.h&quot;
</ins><span class="cx"> #include &quot;JSCInlines.h&quot;
</span><span class="cx"> #include &quot;JSGlobalObjectFunctions.h&quot;
</span><span class="cx"> #include &quot;JSArray.h&quot;
</span><span class="lines">@@ -130,11 +131,12 @@
</span><span class="cx">     JSC_NATIVE_FUNCTION(&quot;substring&quot;, stringProtoFuncSubstring, DontEnum, 2);
</span><span class="cx">     JSC_NATIVE_FUNCTION(&quot;toLowerCase&quot;, stringProtoFuncToLowerCase, DontEnum, 0);
</span><span class="cx">     JSC_NATIVE_FUNCTION(&quot;toUpperCase&quot;, stringProtoFuncToUpperCase, DontEnum, 0);
</span><del>-    JSC_NATIVE_FUNCTION(&quot;localeCompare&quot;, stringProtoFuncLocaleCompare, DontEnum, 1);
</del><span class="cx"> #if ENABLE(INTL)
</span><ins>+    JSC_BUILTIN_FUNCTION(&quot;localeCompare&quot;, stringPrototypeLocaleCompareCodeGenerator, DontEnum);
</ins><span class="cx">     JSC_NATIVE_FUNCTION(&quot;toLocaleLowerCase&quot;, stringProtoFuncToLocaleLowerCase, DontEnum, 0);
</span><span class="cx">     JSC_NATIVE_FUNCTION(&quot;toLocaleUpperCase&quot;, stringProtoFuncToLocaleUpperCase, DontEnum, 0);
</span><span class="cx"> #else
</span><ins>+    JSC_NATIVE_FUNCTION(&quot;localeCompare&quot;, stringProtoFuncLocaleCompare, DontEnum, 1);
</ins><span class="cx">     JSC_NATIVE_FUNCTION(&quot;toLocaleLowerCase&quot;, stringProtoFuncToLowerCase, DontEnum, 0);
</span><span class="cx">     JSC_NATIVE_FUNCTION(&quot;toLocaleUpperCase&quot;, stringProtoFuncToUpperCase, DontEnum, 0);
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>