<!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>[199545] 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/199545">199545</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2016-04-14 11:16:35 -0700 (Thu, 14 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update treatment of invoking RegExp.prototype methods on RegExp.prototype.
https://bugs.webkit.org/show_bug.cgi?id=155922

Reviewed by Keith Miller.

Source/JavaScriptCore:

According to the TC39 committee, when invoking the following RegExp.prototype
methods on the RegExp.prototype:
1. RegExp.prototype.flags yields &quot;&quot;
2. RegExp.prototype.global yields undefined
3. RegExp.prototype.ignoreCase yields undefined
4. RegExp.prototype.multiline yields undefined
5. RegExp.prototype.unicode yields undefined
6. RegExp.prototype.source yields &quot;(?:)&quot;
7. RegExp.prototype.sticky yields undefined
8. RegExp.prototype.toString() yields &quot;/(?:)/&quot;

and RegExp.prototype is still NOT an instance of RegExp.  The above behavior
changes is a special dispensation applicable only to RegExp.prototype.  The ES6
spec of throwing errors still applies if those methods are applied to anything =
else that is not a RegExp object.

* runtime/RegExpPrototype.cpp:
(JSC::regExpProtoGetterGlobal):
(JSC::regExpProtoGetterIgnoreCase):
(JSC::regExpProtoGetterMultiline):
(JSC::regExpProtoGetterSticky):
(JSC::regExpProtoGetterUnicode):
(JSC::regExpProtoGetterFlags):
(JSC::regExpProtoGetterSource):
- Implemented new behavior.

* tests/es6/miscellaneous_built-in_prototypes_are_not_instances.js:
(test):
- Updated to match current kangax test.

LayoutTests:

* fast/regex/script-tests/toString.js:
* fast/regex/toString-expected.txt:
* ietestcenter/Javascript/15.10.7.1-1-expected.txt:
* ietestcenter/Javascript/TestCases/15.10.7.1-1.js:
(ES5Harness.registerTest.test):
* js/kde/RegExp-expected.txt:
* js/kde/script-tests/RegExp.js:
* js/pic/cached-named-property-getter.html:
* js/regexp-flags-expected.txt:
* js/script-tests/regexp-flags.js:
- updated test behaviors in some cases, and rebased results as needed.

* js/regress/regexp-prototype-is-not-instance-expected.txt: Added.
* js/regress/regexp-prototype-is-not-instance.html: Added.
* js/regress/script-tests/regexp-prototype-is-not-instance.js: Added.
- Tests new RegExp.prototype method behaviors.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastregexscriptteststoStringjs">trunk/LayoutTests/fast/regex/script-tests/toString.js</a></li>
<li><a href="#trunkLayoutTestsfastregextoStringexpectedtxt">trunk/LayoutTests/fast/regex/toString-expected.txt</a></li>
<li><a href="#trunkLayoutTestsietestcenterJavascript1510711expectedtxt">trunk/LayoutTests/ietestcenter/Javascript/15.10.7.1-1-expected.txt</a></li>
<li><a href="#trunkLayoutTestsietestcenterJavascriptTestCases1510711js">trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.1-1.js</a></li>
<li><a href="#trunkLayoutTestsjskdeRegExpexpectedtxt">trunk/LayoutTests/js/kde/RegExp-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjskdescripttestsRegExpjs">trunk/LayoutTests/js/kde/script-tests/RegExp.js</a></li>
<li><a href="#trunkLayoutTestsjspiccachednamedpropertygetterhtml">trunk/LayoutTests/js/pic/cached-named-property-getter.html</a></li>
<li><a href="#trunkLayoutTestsjsregexpflagsexpectedtxt">trunk/LayoutTests/js/regexp-flags-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsregexpflagsjs">trunk/LayoutTests/js/script-tests/regexp-flags.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeRegExpPrototypecpp">trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6miscellaneous_builtin_prototypes_are_not_instancesjs">trunk/Source/JavaScriptCore/tests/es6/miscellaneous_built-in_prototypes_are_not_instances.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsregressregexpprototypeisnotinstanceexpectedtxt">trunk/LayoutTests/js/regress/regexp-prototype-is-not-instance-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregressregexpprototypeisnotinstancehtml">trunk/LayoutTests/js/regress/regexp-prototype-is-not-instance.html</a></li>
<li><a href="#trunkLayoutTestsjsregressscripttestsregexpprototypeisnotinstancejs">trunk/LayoutTests/js/regress/script-tests/regexp-prototype-is-not-instance.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/ChangeLog        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-04-14  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Update treatment of invoking RegExp.prototype methods on RegExp.prototype.
+        https://bugs.webkit.org/show_bug.cgi?id=155922
+
+        Reviewed by Keith Miller.
+
+        * fast/regex/script-tests/toString.js:
+        * fast/regex/toString-expected.txt:
+        * ietestcenter/Javascript/15.10.7.1-1-expected.txt:
+        * ietestcenter/Javascript/TestCases/15.10.7.1-1.js:
+        (ES5Harness.registerTest.test):
+        * js/kde/RegExp-expected.txt:
+        * js/kde/script-tests/RegExp.js:
+        * js/pic/cached-named-property-getter.html:
+        * js/regexp-flags-expected.txt:
+        * js/script-tests/regexp-flags.js:
+        - updated test behaviors in some cases, and rebased results as needed.
+
+        * js/regress/regexp-prototype-is-not-instance-expected.txt: Added.
+        * js/regress/regexp-prototype-is-not-instance.html: Added.
+        * js/regress/script-tests/regexp-prototype-is-not-instance.js: Added.
+        - Tests new RegExp.prototype method behaviors.
+
+
</ins><span class="cx"> 2016-04-14  Frederic Wang  &lt;fwang@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Ensure that RenderMathMLOperator::stretchTo functions are called with stretchy operators that have the correct direction
</span></span></pre></div>
<a id="trunkLayoutTestsfastregexscriptteststoStringjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/regex/script-tests/toString.js (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/regex/script-tests/toString.js        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/fast/regex/script-tests/toString.js        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -19,11 +19,11 @@
</span><span class="cx"> 
</span><span class="cx"> shouldBe(&quot;RegExp('/').source&quot;, '&quot;\\\\/&quot;');
</span><span class="cx"> shouldBe(&quot;RegExp('').source&quot;, '&quot;(?:)&quot;');
</span><del>-shouldThrow(&quot;RegExp.prototype.source&quot;, '&quot;TypeError: Type error&quot;');
</del><ins>+shouldBe(&quot;RegExp.prototype.source&quot;, '&quot;(?:)&quot;');
</ins><span class="cx"> 
</span><span class="cx"> shouldBe(&quot;RegExp('/').toString()&quot;, '&quot;/\\\\//&quot;');
</span><span class="cx"> shouldBe(&quot;RegExp('').toString()&quot;, '&quot;/(?:)/&quot;');
</span><del>-shouldThrow(&quot;RegExp.prototype.toString()&quot;, '&quot;TypeError: Type error&quot;');
</del><ins>+shouldBe(&quot;RegExp.prototype.toString()&quot;, '&quot;/(?:)/&quot;');
</ins><span class="cx"> 
</span><span class="cx"> // These strings are equivalent, since the '\' is identity escaping the '/' at the string level.
</span><span class="cx"> shouldBeTrue('testForwardSlash(&quot;^/$&quot;, &quot;/&quot;);');
</span></span></pre></div>
<a id="trunkLayoutTestsfastregextoStringexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/regex/toString-expected.txt (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/regex/toString-expected.txt        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/fast/regex/toString-expected.txt        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -5,10 +5,10 @@
</span><span class="cx"> 
</span><span class="cx"> PASS RegExp('/').source is &quot;\\/&quot;
</span><span class="cx"> PASS RegExp('').source is &quot;(?:)&quot;
</span><del>-PASS RegExp.prototype.source threw exception TypeError: Type error.
</del><ins>+PASS RegExp.prototype.source is &quot;(?:)&quot;
</ins><span class="cx"> PASS RegExp('/').toString() is &quot;/\\//&quot;
</span><span class="cx"> PASS RegExp('').toString() is &quot;/(?:)/&quot;
</span><del>-PASS RegExp.prototype.toString() threw exception TypeError: Type error.
</del><ins>+PASS RegExp.prototype.toString() is &quot;/(?:)/&quot;
</ins><span class="cx"> PASS testForwardSlash(&quot;^/$&quot;, &quot;/&quot;); is true
</span><span class="cx"> PASS testForwardSlash(&quot;^/$&quot;, &quot;/&quot;); is true
</span><span class="cx"> PASS testForwardSlash(&quot;^\/$&quot;, &quot;/&quot;); is true
</span></span></pre></div>
<a id="trunkLayoutTestsietestcenterJavascript1510711expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ietestcenter/Javascript/15.10.7.1-1-expected.txt (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ietestcenter/Javascript/15.10.7.1-1-expected.txt        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/ietestcenter/Javascript/15.10.7.1-1-expected.txt        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-15.10.7.1-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.1/15.10.7.1-1.js) RegExp.prototype.source should throw because RegExp.prototype is not a RegExp
</del><ins>+15.10.7.1-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.1/15.10.7.1-1.js) RegExp.prototype.source should be '(?:)'
</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></pre></div>
<a id="trunkLayoutTestsietestcenterJavascriptTestCases1510711js"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.1-1.js (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.1-1.js        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.1-1.js        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -24,14 +24,9 @@
</span><span class="cx"> 
</span><span class="cx"> path: &quot;TestCases/chapter15/15.10/15.10.7/15.10.7.1/15.10.7.1-1.js&quot;,
</span><span class="cx"> 
</span><del>-description: &quot;RegExp.prototype.source should throw because RegExp.prototype is not a RegExp&quot;,
</del><ins>+description: &quot;RegExp.prototype.source should be '(?:)'&quot;,
</ins><span class="cx"> 
</span><span class="cx"> test: function testcase() {
</span><del>-    try {
-        RegExp.prototype.source;
-        return false;
-    } catch (e) {
-        return true;
-    }
</del><ins>+    return RegExp.prototype.source === '(?:)';
</ins><span class="cx">  }
</span><span class="cx"> });
</span></span></pre></div>
<a id="trunkLayoutTestsjskdeRegExpexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/kde/RegExp-expected.txt (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/kde/RegExp-expected.txt        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/js/kde/RegExp-expected.txt        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -91,7 +91,7 @@
</span><span class="cx"> PASS /\u0061/.source is '\\u0061'
</span><span class="cx"> PASS 'abc'.match(/\u0062/).toString() is 'b'
</span><span class="cx"> PASS Object.prototype.toString.apply(RegExp.prototype) is '[object Object]'
</span><del>-PASS RegExp.prototype.toString() threw exception TypeError: Type error.
</del><ins>+PASS RegExp.prototype.toString() is '/(?:)/'
</ins><span class="cx"> PASS new RegExp().toString() is '/(?:)/'
</span><span class="cx"> PASS (new RegExp('(?:)')).source is '(?:)'
</span><span class="cx"> PASS /(?:)/.toString() is '/(?:)/'
</span></span></pre></div>
<a id="trunkLayoutTestsjskdescripttestsRegExpjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/kde/script-tests/RegExp.js (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/kde/script-tests/RegExp.js        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/js/kde/script-tests/RegExp.js        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -147,7 +147,7 @@
</span><span class="cx"> 
</span><span class="cx"> // not sure what this should return. most importantly
</span><span class="cx"> // it doesn't throw an exception
</span><del>-shouldThrow(&quot;RegExp.prototype.toString()&quot;, &quot;'TypeError: Type error'&quot;);
</del><ins>+shouldBe(&quot;RegExp.prototype.toString()&quot;, &quot;'/(?:)/'&quot;);
</ins><span class="cx"> 
</span><span class="cx"> // Empty regular expressions have string representation /(?:)/
</span><span class="cx"> shouldBe(&quot;new RegExp().toString()&quot;, &quot;'/(?:)/'&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestsjspiccachednamedpropertygetterhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/pic/cached-named-property-getter.html (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/pic/cached-named-property-getter.html        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/js/pic/cached-named-property-getter.html        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -92,9 +92,9 @@
</span><span class="cx"> 
</span><span class="cx">     shouldThrow(function () {
</span><span class="cx">         testCustomGetter({__proto__: r});
</span><del>-    }, &quot;TypeError: Type error&quot;);
</del><ins>+    }, &quot;TypeError: The RegExp.prototype.source getter can only be called on a RegExp object&quot;);
</ins><span class="cx">     shouldThrow(function () {
</span><span class="cx">         testCustomGetter({__proto__: {__proto__: r}});
</span><del>-    }, &quot;TypeError: Type error&quot;);
</del><ins>+    }, &quot;TypeError: The RegExp.prototype.source getter can only be called on a RegExp object&quot;);
</ins><span class="cx"> })();
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsjsregexpflagsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/regexp-flags-expected.txt (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regexp-flags-expected.txt        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/js/regexp-flags-expected.txt        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -14,10 +14,10 @@
</span><span class="cx"> PASS new RegExp('a', 'gmi').flags is 'gim'
</span><span class="cx"> PASS flags.call(/a/ig) is 'gi'
</span><span class="cx"> non-object receivers
</span><del>-PASS flags.call(undefined) threw exception TypeError: Type error.
-PASS flags.call(null) threw exception TypeError: Type error.
-PASS flags.call(false) threw exception TypeError: Type error.
-PASS flags.call(true) threw exception TypeError: Type error.
</del><ins>+PASS flags.call(undefined) threw exception TypeError: The RegExp.prototype.flags getter can only be called on an object.
+PASS flags.call(null) threw exception TypeError: The RegExp.prototype.flags getter can only be called on an object.
+PASS flags.call(false) threw exception TypeError: The RegExp.prototype.flags getter can only be called on an object.
+PASS flags.call(true) threw exception TypeError: The RegExp.prototype.flags getter can only be called on an object.
</ins><span class="cx"> non-regex objects
</span><span class="cx"> PASS flags.call({}) is ''
</span><span class="cx"> PASS flags.call({global: true, multiline: true, ignoreCase: true}) is 'gim'
</span></span></pre></div>
<a id="trunkLayoutTestsjsregressregexpprototypeisnotinstanceexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/regexp-prototype-is-not-instance-expected.txt (0 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/regexp-prototype-is-not-instance-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/regress/regexp-prototype-is-not-instance-expected.txt        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+JSRegress/regexp-prototype-is-not-instance
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressregexpprototypeisnotinstancehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/regexp-prototype-is-not-instance.html (0 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/regexp-prototype-is-not-instance.html                                (rev 0)
+++ trunk/LayoutTests/js/regress/regexp-prototype-is-not-instance.html        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;../../resources/regress-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/regexp-prototype-is-not-instance.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/regress-post.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressscripttestsregexpprototypeisnotinstancejs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/script-tests/regexp-prototype-is-not-instance.js (0 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/script-tests/regexp-prototype-is-not-instance.js                                (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/regexp-prototype-is-not-instance.js        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+//@ runDefault
+
+function stringify(x) {
+    if (typeof x == &quot;string&quot;)
+        return '&quot;' + x + '&quot;';
+    return x;
+}
+
+function assert(actual, expected) {
+    if (actual !== expected)
+        throw Error(&quot;FAIL: expected &quot; + stringify(expected) + &quot;, actual &quot; + stringify(actual));
+}
+
+function assertThrows(func, expectedErrMsg) {
+    let actualErrMsg;
+    try {
+        func();
+        throw(&quot;FAIL: did not throw&quot;);
+    } catch(e) {
+        actualErrMsg = e.toString();
+    }
+    assert(actualErrMsg, expectedErrMsg);
+}
+
+assert(RegExp.prototype instanceof RegExp, false);
+
+assert(RegExp.prototype.flags, &quot;&quot;);
+assert(RegExp.prototype.global, void 0);
+assert(RegExp.prototype.ignoreCase, void 0);
+assert(RegExp.prototype.multiline, void 0);
+assert(RegExp.prototype.unicode, void 0);
+assert(RegExp.prototype.sticky, void 0);
+assert(RegExp.prototype.source, &quot;(?:)&quot;);
+assert(RegExp.prototype.toString(), &quot;/(?:)/&quot;);
+
+assert(Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get.call({}), &quot;&quot;);
+
+assertThrows(() =&gt; {
+        Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get.call(1);
+    }, 
+    &quot;TypeError: The RegExp.prototype.flags getter can only be called on an object&quot;);
+
+assertThrows(() =&gt; {
+        Object.getOwnPropertyDescriptor(RegExp.prototype, 'ignoreCase').get.call({});
+    },
+    &quot;TypeError: The RegExp.prototype.ignoreCase getter can only be called on a RegExp object&quot;);
+
+assertThrows(() =&gt; {
+        Object.getOwnPropertyDescriptor(RegExp.prototype, 'multiline').get.call({});
+    },
+    &quot;TypeError: The RegExp.prototype.multiline getter can only be called on a RegExp object&quot;);
+
+assertThrows(() =&gt; {
+        Object.getOwnPropertyDescriptor(RegExp.prototype, 'unicode').get.call({});
+    },
+    &quot;TypeError: The RegExp.prototype.unicode getter can only be called on a RegExp object&quot;);
+
+assertThrows(() =&gt; {
+        Object.getOwnPropertyDescriptor(RegExp.prototype, 'sticky').get.call({});
+    },
+    &quot;TypeError: The RegExp.prototype.sticky getter can only be called on a RegExp object&quot;);
+
+assertThrows(() =&gt; {
+        Object.getOwnPropertyDescriptor(RegExp.prototype, 'source').get.call({});
+    },
+    &quot;TypeError: The RegExp.prototype.source getter can only be called on a RegExp object&quot;);
+
+assertThrows(() =&gt; {
+        Object.getOwnPropertyDescriptor(RegExp.prototype, 'toString').get.call({});
+    },
+    &quot;TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(RegExp.prototype, 'toString').get.call')&quot;);
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsregexpflagsjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/regexp-flags.js (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/regexp-flags.js        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/LayoutTests/js/script-tests/regexp-flags.js        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -16,10 +16,10 @@
</span><span class="cx"> shouldBe(&quot;flags.call(/a/ig)&quot;, &quot;'gi'&quot;);
</span><span class="cx"> 
</span><span class="cx"> debug(&quot;non-object receivers&quot;);
</span><del>-shouldThrow(&quot;flags.call(undefined)&quot;, &quot;'TypeError: Type error'&quot;);
-shouldThrow(&quot;flags.call(null)&quot;, &quot;'TypeError: Type error'&quot;);
-shouldThrow(&quot;flags.call(false)&quot;, &quot;'TypeError: Type error'&quot;);
-shouldThrow(&quot;flags.call(true)&quot;, &quot;'TypeError: Type error'&quot;);
</del><ins>+shouldThrow(&quot;flags.call(undefined)&quot;, &quot;'TypeError: The RegExp.prototype.flags getter can only be called on an object'&quot;);
+shouldThrow(&quot;flags.call(null)&quot;, &quot;'TypeError: The RegExp.prototype.flags getter can only be called on an object'&quot;);
+shouldThrow(&quot;flags.call(false)&quot;, &quot;'TypeError: The RegExp.prototype.flags getter can only be called on an object'&quot;);
+shouldThrow(&quot;flags.call(true)&quot;, &quot;'TypeError: The RegExp.prototype.flags getter can only be called on an object'&quot;);
</ins><span class="cx"> 
</span><span class="cx"> debug(&quot;non-regex objects&quot;);
</span><span class="cx"> shouldBe(&quot;flags.call({})&quot;, &quot;''&quot;);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2016-04-14  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Update treatment of invoking RegExp.prototype methods on RegExp.prototype.
+        https://bugs.webkit.org/show_bug.cgi?id=155922
+
+        Reviewed by Keith Miller.
+
+        According to the TC39 committee, when invoking the following RegExp.prototype
+        methods on the RegExp.prototype:
+        1. RegExp.prototype.flags yields &quot;&quot;
+        2. RegExp.prototype.global yields undefined
+        3. RegExp.prototype.ignoreCase yields undefined
+        4. RegExp.prototype.multiline yields undefined
+        5. RegExp.prototype.unicode yields undefined
+        6. RegExp.prototype.source yields &quot;(?:)&quot;
+        7. RegExp.prototype.sticky yields undefined
+        8. RegExp.prototype.toString() yields &quot;/(?:)/&quot;
+
+        and RegExp.prototype is still NOT an instance of RegExp.  The above behavior
+        changes is a special dispensation applicable only to RegExp.prototype.  The ES6
+        spec of throwing errors still applies if those methods are applied to anything =
+        else that is not a RegExp object.
+
+        * runtime/RegExpPrototype.cpp:
+        (JSC::regExpProtoGetterGlobal):
+        (JSC::regExpProtoGetterIgnoreCase):
+        (JSC::regExpProtoGetterMultiline):
+        (JSC::regExpProtoGetterSticky):
+        (JSC::regExpProtoGetterUnicode):
+        (JSC::regExpProtoGetterFlags):
+        (JSC::regExpProtoGetterSource):
+        - Implemented new behavior.
+
+        * tests/es6/miscellaneous_built-in_prototypes_are_not_instances.js:
+        (test):
+        - Updated to match current kangax test.
+
</ins><span class="cx"> 2016-04-14  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Some imported ES6 tests are missing __createIterableObject
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeRegExpPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -244,8 +244,11 @@
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoGetterGlobal(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><del>-    if (!thisValue.inherits(RegExpObject::info()))
-        return JSValue::encode(jsUndefined());
</del><ins>+    if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) {
+        if (thisValue.inherits(RegExpPrototype::info()))
+            return JSValue::encode(jsUndefined());
+        return throwVMTypeError(exec, ASCIILiteral(&quot;The RegExp.prototype.global getter can only be called on a RegExp object&quot;));
+    }
</ins><span class="cx"> 
</span><span class="cx">     return JSValue::encode(jsBoolean(asRegExpObject(thisValue)-&gt;regExp()-&gt;global()));
</span><span class="cx"> }
</span><span class="lines">@@ -253,8 +256,11 @@
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoGetterIgnoreCase(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><del>-    if (!thisValue.inherits(RegExpObject::info()))
-        return JSValue::encode(jsUndefined());
</del><ins>+    if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) {
+        if (thisValue.inherits(RegExpPrototype::info()))
+            return JSValue::encode(jsUndefined());
+        return throwVMTypeError(exec, ASCIILiteral(&quot;The RegExp.prototype.ignoreCase getter can only be called on a RegExp object&quot;));
+    }
</ins><span class="cx"> 
</span><span class="cx">     return JSValue::encode(jsBoolean(asRegExpObject(thisValue)-&gt;regExp()-&gt;ignoreCase()));
</span><span class="cx"> }
</span><span class="lines">@@ -262,8 +268,11 @@
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoGetterMultiline(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><del>-    if (!thisValue.inherits(RegExpObject::info()))
-        return JSValue::encode(jsUndefined());
</del><ins>+    if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) {
+        if (thisValue.inherits(RegExpPrototype::info()))
+            return JSValue::encode(jsUndefined());
+        return throwVMTypeError(exec, ASCIILiteral(&quot;The RegExp.prototype.multiline getter can only be called on a RegExp object&quot;));
+    }
</ins><span class="cx"> 
</span><span class="cx">     return JSValue::encode(jsBoolean(asRegExpObject(thisValue)-&gt;regExp()-&gt;multiline()));
</span><span class="cx"> }
</span><span class="lines">@@ -271,8 +280,11 @@
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoGetterSticky(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><del>-    if (!thisValue.inherits(RegExpObject::info()))
-        return JSValue::encode(jsUndefined());
</del><ins>+    if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) {
+        if (thisValue.inherits(RegExpPrototype::info()))
+            return JSValue::encode(jsUndefined());
+        return throwVMTypeError(exec, ASCIILiteral(&quot;The RegExp.prototype.sticky getter can only be called on a RegExp object&quot;));
+    }
</ins><span class="cx">     
</span><span class="cx">     return JSValue::encode(jsBoolean(asRegExpObject(thisValue)-&gt;regExp()-&gt;sticky()));
</span><span class="cx"> }
</span><span class="lines">@@ -280,8 +292,11 @@
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoGetterUnicode(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><del>-    if (!thisValue.inherits(RegExpObject::info()))
-        return JSValue::encode(jsUndefined());
</del><ins>+    if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) {
+        if (thisValue.inherits(RegExpPrototype::info()))
+            return JSValue::encode(jsUndefined());
+        return throwVMTypeError(exec, ASCIILiteral(&quot;The RegExp.prototype.unicode getter can only be called on a RegExp object&quot;));
+    }
</ins><span class="cx">     
</span><span class="cx">     return JSValue::encode(jsBoolean(asRegExpObject(thisValue)-&gt;regExp()-&gt;unicode()));
</span><span class="cx"> }
</span><span class="lines">@@ -289,8 +304,8 @@
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoGetterFlags(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><del>-    if (!thisValue.isObject())
-        return throwVMTypeError(exec);
</del><ins>+    if (UNLIKELY(!thisValue.isObject()))
+        return throwVMTypeError(exec, ASCIILiteral(&quot;The RegExp.prototype.flags getter can only be called on an object&quot;));
</ins><span class="cx"> 
</span><span class="cx">     auto flags = flagsString(exec, asObject(thisValue));
</span><span class="cx">     if (exec-&gt;hadException())
</span><span class="lines">@@ -408,8 +423,11 @@
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoGetterSource(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><del>-    if (!thisValue.inherits(RegExpObject::info()))
-        return throwVMTypeError(exec);
</del><ins>+    if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) {
+        if (thisValue.inherits(RegExpPrototype::info()))
+            return JSValue::encode(jsString(exec, ASCIILiteral(&quot;(?:)&quot;)));
+        return throwVMTypeError(exec, ASCIILiteral(&quot;The RegExp.prototype.source getter can only be called on a RegExp object&quot;));
+    }
</ins><span class="cx"> 
</span><span class="cx">     String pattern = asRegExpObject(thisValue)-&gt;regExp()-&gt;pattern();
</span><span class="cx">     if (pattern.is8Bit())
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6miscellaneous_builtin_prototypes_are_not_instancesjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/es6/miscellaneous_built-in_prototypes_are_not_instances.js (199544 => 199545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6/miscellaneous_built-in_prototypes_are_not_instances.js        2016-04-14 18:04:44 UTC (rev 199544)
+++ trunk/Source/JavaScriptCore/tests/es6/miscellaneous_built-in_prototypes_are_not_instances.js        2016-04-14 18:16:35 UTC (rev 199545)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> function test() {
</span><span class="cx"> 
</span><span class="cx"> try {
</span><del>-  RegExp.prototype.source; return false;
</del><ins>+  RegExp.prototype.exec(); return false;
</ins><span class="cx"> } catch(e) {}
</span><span class="cx"> try {
</span><span class="cx">   Date.prototype.valueOf(); return false;
</span></span></pre>
</div>
</div>

</body>
</html>