<!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>[198652] 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/198652">198652</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-03-24 16:18:49 -0700 (Thu, 24 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>ES6: Implement IsRegExp function and use where needed in String.prototype.* methods
https://bugs.webkit.org/show_bug.cgi?id=155854

Reviewed by Mark Lam.

Source/JavaScriptCore:

This patch is a straight forward implementation of IsRegExp
in the ES6 spec:
https://tc39.github.io/ecma262/#sec-isregexp
We now use this IsRegExp function inside String.prototype.(startsWith | endsWith | includes)
as is dictated by the spec.

* runtime/RegExpConstructor.h:
(JSC::RegExpConstructor::recordMatch):
(JSC::isRegExp):
* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncStartsWith):
(JSC::stringProtoFuncEndsWith):
(JSC::stringProtoFuncIncludes):
* tests/es6.yaml:
* tests/es6/well-known_symbols_Symbol.match_String.prototype.endsWith.js: Added.
(test):
* tests/es6/well-known_symbols_Symbol.match_String.prototype.includes.js: Added.
(test):
* tests/es6/well-known_symbols_Symbol.match_String.prototype.startsWith.js: Added.
(test):
* tests/stress/string-prototype-methods-endsWith-startsWith-includes-correctness.js: Added.
(assert):
(test):
(test.get let):
(get let):

LayoutTests:

* js/string-includes-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsstringincludesexpectedtxt">trunk/LayoutTests/js/string-includes-expected.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeRegExpConstructorh">trunk/Source/JavaScriptCore/runtime/RegExpConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeStringPrototypecpp">trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6yaml">trunk/Source/JavaScriptCore/tests/es6.yaml</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestses6wellknown_symbols_Symbolmatch_StringprototypeendsWithjs">trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.endsWith.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6wellknown_symbols_Symbolmatch_Stringprototypeincludesjs">trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.includes.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6wellknown_symbols_Symbolmatch_StringprototypestartsWithjs">trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.startsWith.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressstringprototypemethodsendsWithstartsWithincludescorrectnessjs">trunk/Source/JavaScriptCore/tests/stress/string-prototype-methods-endsWith-startsWith-includes-correctness.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198651 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-24 23:16:53 UTC (rev 198651)
+++ trunk/LayoutTests/ChangeLog        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2016-03-24  Saam barati  &lt;sbarati@apple.com&gt;
+
+        ES6: Implement IsRegExp function and use where needed in String.prototype.* methods
+        https://bugs.webkit.org/show_bug.cgi?id=155854
+
+        Reviewed by Mark Lam.
+
+        * js/string-includes-expected.txt:
+
</ins><span class="cx"> 2016-03-24  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r198627.
</span></span></pre></div>
<a id="trunkLayoutTestsjsstringincludesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/string-includes-expected.txt (198651 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/string-includes-expected.txt        2016-03-24 23:16:53 UTC (rev 198651)
+++ trunk/LayoutTests/js/string-includes-expected.txt        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -118,9 +118,9 @@
</span><span class="cx"> PASS (function() { var f = String.prototype.startsWith; (function() { f('a'); })(); })() threw exception TypeError: Type error.
</span><span class="cx"> PASS (function() { var f = String.prototype.endsWith; (function() { f('a'); })(); })() threw exception TypeError: Type error.
</span><span class="cx"> PASS (function() { var f = String.prototype.includes; (function() { f('a'); })(); })() threw exception TypeError: Type error.
</span><del>-PASS 'foo bar'.startsWith(/w+/) threw exception TypeError: Type error.
-PASS 'foo bar'.endsWith(/w+/) threw exception TypeError: Type error.
-PASS 'foo bar'.includes(/w+/) threw exception TypeError: Type error.
</del><ins>+PASS 'foo bar'.startsWith(/w+/) threw exception TypeError: Argument to String.prototype.startsWith can not be a RegExp..
+PASS 'foo bar'.endsWith(/w+/) threw exception TypeError: Argument to String.prototype.endsWith can not be a RegExp..
+PASS 'foo bar'.includes(/w+/) threw exception TypeError: Argument to String.prototype.includes can not be a RegExp..
</ins><span class="cx"> PASS stringToSearchIn.startsWith(searchString, startOffset) is true
</span><span class="cx"> PASS sideEffect == 'ABC' is true
</span><span class="cx"> PASS stringToSearchIn.startsWith(searchString, startOffset) threw exception error.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (198651 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-03-24 23:16:53 UTC (rev 198651)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -1,5 +1,38 @@
</span><span class="cx"> 2016-03-24  Saam barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        ES6: Implement IsRegExp function and use where needed in String.prototype.* methods
+        https://bugs.webkit.org/show_bug.cgi?id=155854
+
+        Reviewed by Mark Lam.
+
+        This patch is a straight forward implementation of IsRegExp
+        in the ES6 spec:
+        https://tc39.github.io/ecma262/#sec-isregexp
+        We now use this IsRegExp function inside String.prototype.(startsWith | endsWith | includes)
+        as is dictated by the spec.
+
+        * runtime/RegExpConstructor.h:
+        (JSC::RegExpConstructor::recordMatch):
+        (JSC::isRegExp):
+        * runtime/StringPrototype.cpp:
+        (JSC::stringProtoFuncStartsWith):
+        (JSC::stringProtoFuncEndsWith):
+        (JSC::stringProtoFuncIncludes):
+        * tests/es6.yaml:
+        * tests/es6/well-known_symbols_Symbol.match_String.prototype.endsWith.js: Added.
+        (test):
+        * tests/es6/well-known_symbols_Symbol.match_String.prototype.includes.js: Added.
+        (test):
+        * tests/es6/well-known_symbols_Symbol.match_String.prototype.startsWith.js: Added.
+        (test):
+        * tests/stress/string-prototype-methods-endsWith-startsWith-includes-correctness.js: Added.
+        (assert):
+        (test):
+        (test.get let):
+        (get let):
+
+2016-03-24  Saam barati  &lt;sbarati@apple.com&gt;
+
</ins><span class="cx">         Web Inspector: Separate Debugger enable state from the debugger breakpoints enabled state
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=152193
</span><span class="cx">         &lt;rdar://problem/23867520&gt;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeRegExpConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/RegExpConstructor.h (198651 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/RegExpConstructor.h        2016-03-24 23:16:53 UTC (rev 198651)
+++ trunk/Source/JavaScriptCore/runtime/RegExpConstructor.h        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -131,6 +131,21 @@
</span><span class="cx">     m_cachedResult.record(vm, this, regExp, string, result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ALWAYS_INLINE bool isRegExp(VM&amp; vm, ExecState* exec, JSValue value)
+{
+    if (!value.isObject())
+        return false;
+
+    JSObject* object = asObject(value);
+    JSValue matchValue = object-&gt;get(exec, vm.propertyNames-&gt;matchSymbol);
+    if (vm.exception())
+        return false;
+    if (!matchValue.isUndefined())
+        return matchValue.toBoolean(exec);
+
+    return object-&gt;inherits(RegExpObject::info());
+}
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif // RegExpConstructor_h
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeStringPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp (198651 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp        2016-03-24 23:16:53 UTC (rev 198651)
+++ trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -1840,8 +1840,12 @@
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><span class="cx"> 
</span><span class="cx">     JSValue a0 = exec-&gt;argument(0);
</span><del>-    if (jsDynamicCast&lt;RegExpObject*&gt;(a0))
-        return throwVMTypeError(exec);
</del><ins>+    VM&amp; vm = exec-&gt;vm();
+    bool isRegularExpression = isRegExp(vm, exec, a0);
+    if (vm.exception())
+        return JSValue::encode(JSValue());
+    if (isRegularExpression)
+        return throwVMTypeError(exec, &quot;Argument to String.prototype.startsWith can not be a RegExp.&quot;);
</ins><span class="cx"> 
</span><span class="cx">     String searchString = a0.toString(exec)-&gt;value(exec);
</span><span class="cx">     if (exec-&gt;hadException())
</span><span class="lines">@@ -1872,8 +1876,12 @@
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><span class="cx"> 
</span><span class="cx">     JSValue a0 = exec-&gt;argument(0);
</span><del>-    if (jsDynamicCast&lt;RegExpObject*&gt;(a0))
-        return throwVMTypeError(exec);
</del><ins>+    VM&amp; vm = exec-&gt;vm();
+    bool isRegularExpression = isRegExp(vm, exec, a0);
+    if (vm.exception())
+        return JSValue::encode(JSValue());
+    if (isRegularExpression)
+        return throwVMTypeError(exec, &quot;Argument to String.prototype.endsWith can not be a RegExp.&quot;);
</ins><span class="cx"> 
</span><span class="cx">     String searchString = a0.toString(exec)-&gt;value(exec);
</span><span class="cx">     if (exec-&gt;hadException())
</span><span class="lines">@@ -1905,8 +1913,12 @@
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><span class="cx"> 
</span><span class="cx">     JSValue a0 = exec-&gt;argument(0);
</span><del>-    if (jsDynamicCast&lt;RegExpObject*&gt;(a0))
-        return throwVMTypeError(exec);
</del><ins>+    VM&amp; vm = exec-&gt;vm();
+    bool isRegularExpression = isRegExp(vm, exec, a0);
+    if (vm.exception())
+        return JSValue::encode(JSValue());
+    if (isRegularExpression)
+        return throwVMTypeError(exec, &quot;Argument to String.prototype.includes can not be a RegExp.&quot;);
</ins><span class="cx"> 
</span><span class="cx">     String searchString = a0.toString(exec)-&gt;value(exec);
</span><span class="cx">     if (exec-&gt;hadException())
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6wellknown_symbols_Symbolmatch_StringprototypeendsWithjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.endsWith.js (0 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.endsWith.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.endsWith.js        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+function test() {
+    var re = /./;
+    try {
+        '/./'.endsWith(re);
+    } catch(e){
+        re[Symbol.match] = false;
+        return '/./'.endsWith(re);
+    }
+}
+
+if (!test())
+    throw new Error(&quot;Test failed&quot;);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6wellknown_symbols_Symbolmatch_Stringprototypeincludesjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.includes.js (0 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.includes.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.includes.js        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+function test() {
+    var re = /./;
+    try {
+        '/./'.includes(re);
+    } catch(e){
+        re[Symbol.match] = false;
+        return '/./'.includes(re);
+    }
+}
+
+if (!test())
+    throw new Error(&quot;Test failed&quot;);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6wellknown_symbols_Symbolmatch_StringprototypestartsWithjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.startsWith.js (0 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.startsWith.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/es6/well-known_symbols_Symbol.match_String.prototype.startsWith.js        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+function test() {
+    var re = /./;
+    try {
+        '/./'.startsWith(re);
+    } catch(e){
+        re[Symbol.match] = false;
+        return '/./'.startsWith(re);
+    }
+}
+
+if (!test())
+    throw new Error(&quot;Test failed&quot;);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6yaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/es6.yaml (198651 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6.yaml        2016-03-24 23:16:53 UTC (rev 198651)
+++ trunk/Source/JavaScriptCore/tests/es6.yaml        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -1220,6 +1220,12 @@
</span><span class="cx">   cmd: runES6 :normal
</span><span class="cx"> - path: es6/well-known_symbols_Symbol.toStringTag_misc._built-ins.js
</span><span class="cx">   cmd: runES6 :normal
</span><ins>+- path: es6/well-known_symbols_Symbol.match_String.prototype.startsWith.js
+  cmd: runES6 :normal
+- path: es6/well-known_symbols_Symbol.match_String.prototype.endsWith.js
+  cmd: runES6 :normal
+- path: es6/well-known_symbols_Symbol.match_String.prototype.includes.js
+  cmd: runES6 :normal
</ins><span class="cx"> # Late-stage proposals for a future ECMAScript standard
</span><span class="cx"> # FIXME: move these to a new directory?
</span><span class="cx"> - path: es6/Object_static_methods_Object.getOwnPropertyDescriptors.js
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressstringprototypemethodsendsWithstartsWithincludescorrectnessjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/string-prototype-methods-endsWith-startsWith-includes-correctness.js (0 => 198652)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/string-prototype-methods-endsWith-startsWith-includes-correctness.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/string-prototype-methods-endsWith-startsWith-includes-correctness.js        2016-03-24 23:18:49 UTC (rev 198652)
</span><span class="lines">@@ -0,0 +1,180 @@
</span><ins>+function assert(b) {
+    if (!b)
+        throw new Error(&quot;Bad assertion!&quot;);
+}
+
+function test(f) {
+    for (let i = 0; i &lt; 500; i++)
+        f();
+}
+
+test(function() {
+    let foo = &quot;hello&quot;;
+    let threw = false;
+    try {
+        foo.endsWith(/foo/);
+    } catch(e) {
+        assert(e.toString() === &quot;TypeError: Argument to String.prototype.endsWith can not be a RegExp.&quot;);
+        threw = true;
+    }
+    assert(threw);
+});
+
+test(function() {
+    let foo = &quot;hello&quot;;
+    let threw = false;
+    try {
+        foo.startsWith(/foo/);
+    } catch(e) {
+        assert(e.toString() === &quot;TypeError: Argument to String.prototype.startsWith can not be a RegExp.&quot;);
+        threw = true;
+    }
+    assert(threw);
+});
+
+test(function() {
+    let foo = &quot;hello&quot;;
+    let threw = false;
+    try {
+        foo.includes(/foo/);
+    } catch(e) {
+        assert(e.toString() === &quot;TypeError: Argument to String.prototype.includes can not be a RegExp.&quot;);
+        threw = true;
+    }
+    assert(threw);
+});
+
+test(function() {
+    let props = [];
+    let proxy = new Proxy(/foo/, {
+        get(theTarget, prop) {
+            props.push(prop);
+            return theTarget[prop];
+        }
+    });
+
+    let foo = &quot;hello&quot;;
+    let threw = false;
+    try {
+        foo.endsWith(proxy);
+    } catch(e) {
+        assert(e.toString() === &quot;TypeError: Argument to String.prototype.endsWith can not be a RegExp.&quot;);
+        threw = true;
+    }
+    assert(threw);
+    assert(props.length === 1);
+    assert(props[0] === Symbol.match);
+});
+
+test(function() {
+    let props = [];
+    let proxy = new Proxy(/foo/, {
+        get(theTarget, prop) {
+            props.push(prop);
+            return theTarget[prop];
+        }
+    });
+
+    let foo = &quot;hello&quot;;
+    let threw = false;
+    try {
+        foo.startsWith(proxy);
+    } catch(e) {
+        assert(e.toString() === &quot;TypeError: Argument to String.prototype.startsWith can not be a RegExp.&quot;);
+        threw = true;
+    }
+    assert(threw);
+    assert(props.length === 1);
+    assert(props[0] === Symbol.match);
+});
+
+test(function() {
+    let props = [];
+    let proxy = new Proxy(/foo/, {
+        get(theTarget, prop) {
+            props.push(prop);
+            return theTarget[prop];
+        }
+    });
+
+    let foo = &quot;hello&quot;;
+    let threw = false;
+    try {
+        foo.includes(proxy);
+    } catch(e) {
+        assert(e.toString() === &quot;TypeError: Argument to String.prototype.includes can not be a RegExp.&quot;);
+        threw = true;
+    }
+    assert(threw);
+    assert(props.length === 1);
+    assert(props[0] === Symbol.match);
+});
+
+test(function() {
+    let props = [];
+    let proxy = new Proxy(/foo/, {
+        get(theTarget, prop) {
+            props.push(prop);
+            if (prop === Symbol.match)
+                return undefined;
+            return theTarget[prop];
+        }
+    });
+
+    let foo = &quot;/foo/&quot;;
+    let threw = false;
+    let result = foo.includes(proxy);
+    assert(result);
+    assert(props.length === 5);
+    assert(props[0] === Symbol.match);
+    assert(props[1] === Symbol.toPrimitive);
+    assert(props[2] === &quot;toString&quot;);
+    assert(props[3] === &quot;source&quot;);
+    assert(props[4] === &quot;flags&quot;);
+});
+
+test(function() {
+    let props = [];
+    let proxy = new Proxy(/foo/, {
+        get(theTarget, prop) {
+            props.push(prop);
+            if (prop === Symbol.match)
+                return undefined;
+            return theTarget[prop];
+        }
+    });
+
+    let foo = &quot;/foo/&quot;;
+    let threw = false;
+    let result = foo.startsWith(proxy);
+    assert(result);
+    assert(props.length === 5);
+    assert(props[0] === Symbol.match);
+    assert(props[1] === Symbol.toPrimitive);
+    assert(props[2] === &quot;toString&quot;);
+    assert(props[3] === &quot;source&quot;);
+    assert(props[4] === &quot;flags&quot;);
+});
+
+test(function() {
+    let props = [];
+    let proxy = new Proxy(/foo/, {
+        get(theTarget, prop) {
+            props.push(prop);
+            if (prop === Symbol.match)
+                return undefined;
+            return theTarget[prop];
+        }
+    });
+
+    let foo = &quot;/foo/&quot;;
+    let threw = false;
+    let result = foo.endsWith(proxy);
+    assert(result);
+    assert(props.length === 5);
+    assert(props[0] === Symbol.match);
+    assert(props[1] === Symbol.toPrimitive);
+    assert(props[2] === &quot;toString&quot;);
+    assert(props[3] === &quot;source&quot;);
+    assert(props[4] === &quot;flags&quot;);
+});
</ins></span></pre>
</div>
</div>

</body>
</html>