Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: src/harmony-string.js

Issue 227113005: Make `String.prototype.contains` throw when passing a regular expression (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Fix test-mark-compact/BootUpMemoryUse on x64 Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/harmony-string.js
diff --git a/src/harmony-string.js b/src/harmony-string.js
index cc3c5cf93c2a1ca45d269b0782e712fd2ef4fedb..e1da24caa39b8edfb4fb71476a1264ed95cbf127 100644
--- a/src/harmony-string.js
+++ b/src/harmony-string.js
@@ -53,7 +53,7 @@ function StringRepeat(count) {
}
-// ES6 draft 01-20-14, section 21.1.3.18
+// ES6 draft 04-05-14, section 21.1.3.18
function StringStartsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.startsWith");
@@ -82,7 +82,7 @@ function StringStartsWith(searchString /* position */) { // length == 1
}
-// ES6 draft 01-20-14, section 21.1.3.7
+// ES6 draft 04-05-14, section 21.1.3.7
function StringEndsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith");
@@ -114,11 +114,17 @@ function StringEndsWith(searchString /* position */) { // length == 1
}
-// ES6 draft 01-20-14, section 21.1.3.6
+// ES6 draft 04-05-14, section 21.1.3.6
function StringContains(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.contains");
var s = TO_STRING_INLINE(this);
+
+ if (IS_REGEXP(searchString)) {
+ throw MakeTypeError("first_argument_not_regexp",
+ ["String.prototype.contains"]);
+ }
+
var ss = TO_STRING_INLINE(searchString);
var pos = 0;
if (%_ArgumentsLength() > 1) {
« no previous file with comments | « no previous file | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698