summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/String/prototype/startsWith
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/String/prototype/startsWith')
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/coerced-values-of-position.js41
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/length.js24
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/name.js24
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/out-of-bounds-position.js45
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position-as-symbol.js24
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position.js27
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-as-symbol.js23
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js44
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring.js26
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this-as-symbol.js22
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this.js25
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/return-true-if-searchstring-is-empty.js42
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-with-position.js36
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-without-position.js26
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-is-regexp-throws.js23
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-with-position.js33
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-without-position.js36
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/startsWith.js24
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-null-throws.js18
-rw-r--r--js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-undefined-throws.js18
23 files changed, 616 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/browser.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/browser.js
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/coerced-values-of-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/coerced-values-of-position.js
new file mode 100644
index 0000000000..b12e6d8e0f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/coerced-values-of-position.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns based on coerced values of position.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 9. Let pos be ToInteger(position). (If position is undefined, this step
+ produces the value 0).
+ 10. ReturnIfAbrupt(pos).
+ 11. Let len be the number of elements in S.
+ 12. Let start be min(max(pos, 0), len).
+ 13. Let searchLength be the number of elements in searchStr.
+ 14. If searchLength+start is greater than len, return false.
+ 15. If the sequence of elements of S starting at start of length searchLength
+ is the same as the full element sequence of searchStr, return true.
+ 16. Otherwise, return false.
+ ...
+---*/
+
+var str = 'The future is cool!';
+
+assert(str.startsWith('The future', NaN), 'NaN coerced to 0');
+assert(str.startsWith('The future', null), 'null coerced to 0');
+assert(str.startsWith('The future', false), 'false coerced to 0');
+assert(str.startsWith('The future', ''), '"" coerced to 0');
+assert(str.startsWith('The future', '0'), '"0" coerced to 0');
+assert(str.startsWith('The future', undefined), 'undefined coerced to 0');
+assert(str.startsWith('The future', 0.4), '0.4 coerced to 0');
+
+assert.sameValue(
+ str.startsWith('The future', true), false,
+ 'true coerced to 1'
+);
+assert.sameValue(str.startsWith('The future', '1'), false, '"1" coerced to 1');
+assert.sameValue(str.startsWith('The future', 1.4), false, '1.4 coerced to 1');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js
new file mode 100644
index 0000000000..3e19e74994
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ String.prototype.startsWith.length value and descriptor.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ The length property of the startsWith method is 1.
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ String.prototype.startsWith.length, 1,
+ 'The value of `String.prototype.startsWith.length` is `1`'
+);
+
+verifyNotEnumerable(String.prototype.startsWith, 'length');
+verifyNotWritable(String.prototype.startsWith, 'length');
+verifyConfigurable(String.prototype.startsWith, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js
new file mode 100644
index 0000000000..4baa4a3076
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ String.prototype.startsWith.name value and descriptor.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ String.prototype.startsWith.name, 'startsWith',
+ 'The value of `String.prototype.startsWith.name` is `"startsWith"`'
+);
+
+verifyNotEnumerable(String.prototype.startsWith, 'name');
+verifyNotWritable(String.prototype.startsWith, 'name');
+verifyConfigurable(String.prototype.startsWith, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js
new file mode 100644
index 0000000000..a286537efc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ String.prototype.startsWith does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, arrow-function]
+---*/
+
+assert.sameValue(
+ isConstructor(String.prototype.startsWith),
+ false,
+ 'isConstructor(String.prototype.startsWith) must return false'
+);
+
+assert.throws(TypeError, () => {
+ new String.prototype.startsWith();
+}, '`new String.prototype.startsWith()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/out-of-bounds-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/out-of-bounds-position.js
new file mode 100644
index 0000000000..820e85662d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/out-of-bounds-position.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns false if searchLength + start position is greater than string length.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 11. Let len be the number of elements in S.
+ 12. Let start be min(max(pos, 0), len).
+ 13. Let searchLength be the number of elements in searchStr.
+ 14. If searchLength+start is greater than len, return false.
+ ...
+---*/
+
+var str = 'The future is cool!';
+
+assert.sameValue(
+ str.startsWith('!', str.length), false,
+ 'str.startsWith("!", str.length) returns false'
+);
+
+assert.sameValue(
+ str.startsWith('!', 100), false,
+ 'str.startsWith("!", 100) returns false'
+);
+
+assert.sameValue(
+ str.startsWith('!', Infinity), false,
+ 'str.startsWith("!", Infinity) returns false'
+);
+
+assert(
+ str.startsWith('The future', -1),
+ 'position argument < 0 will search from the start of the string (-1)'
+);
+
+assert(
+ str.startsWith('The future', -Infinity),
+ 'position argument < 0 will search from the start of the string (-Infinity)'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position-as-symbol.js
new file mode 100644
index 0000000000..668ab343aa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position-as-symbol.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns abrupt from ToInteger(position) as a Symbol.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 9. Let pos be ToInteger(position). (If position is undefined, this step
+ produces the value 0).
+ 10. ReturnIfAbrupt(pos).
+ ...
+features: [Symbol]
+---*/
+
+var position = Symbol();
+
+assert.throws(TypeError, function() {
+ ''.startsWith('', position);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position.js
new file mode 100644
index 0000000000..2a8e9b9917
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns abrupt from ToInteger(position).
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 9. Let pos be ToInteger(position). (If position is undefined, this step
+ produces the value 0).
+ 10. ReturnIfAbrupt(pos).
+ ...
+---*/
+
+var position = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ ''.startsWith('', position);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-as-symbol.js
new file mode 100644
index 0000000000..d4a53cff06
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-as-symbol.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns abrupt from ToString(searchString) as a Symbol
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 7. Let searchStr be ToString(searchString).
+ 8. ReturnIfAbrupt(searchString).
+ ...
+features: [Symbol]
+---*/
+
+var s = Symbol();
+
+assert.throws(TypeError, function() {
+ ''.startsWith(s);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js
new file mode 100644
index 0000000000..5fd775ad0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns abrupt from IsRegExp(searchString).
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 4. Let isRegExp be IsRegExp(searchString).
+ 5. ReturnIfAbrupt(isRegExp).
+ ...
+
+ 7.2.8 IsRegExp ( argument )
+
+ 2. Let isRegExp be Get(argument, @@match).
+ 3. ReturnIfAbrupt(isRegExp).
+features: [Symbol.match]
+---*/
+
+var obj = {};
+Object.defineProperty(obj, Symbol.match, {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ ''.startsWith(obj);
+});
+
+var regexp = /./;
+Object.defineProperty(regexp, Symbol.match, {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ ''.startsWith(regexp);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring.js
new file mode 100644
index 0000000000..26a9376388
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns abrupt from ToString(searchString)
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 7. Let searchStr be ToString(searchString).
+ 8. ReturnIfAbrupt(searchString).
+ ...
+---*/
+
+var obj = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ ''.startsWith(obj);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this-as-symbol.js
new file mode 100644
index 0000000000..2e66a64380
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this-as-symbol.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns abrupt from ToString(this) where this is a Symbol
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ 1. Let O be RequireObjectCoercible(this value).
+ 2. Let S be ToString(O).
+ 3. ReturnIfAbrupt(S).
+features: [Symbol]
+---*/
+
+var s = Symbol('');
+
+assert.throws(TypeError, function() {
+ String.prototype.startsWith.call(s, '');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this.js
new file mode 100644
index 0000000000..727cd25b93
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns abrupt from ToString(this)
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ 1. Let O be RequireObjectCoercible(this value).
+ 2. Let S be ToString(O).
+ 3. ReturnIfAbrupt(S).
+---*/
+
+var o = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ String.prototype.startsWith.call(o, '');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-true-if-searchstring-is-empty.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-true-if-searchstring-is-empty.js
new file mode 100644
index 0000000000..a65c494055
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-true-if-searchstring-is-empty.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns true if searchString.length == 0.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 11. Let len be the number of elements in S.
+ 12. Let start be min(max(pos, 0), len).
+ 13. Let searchLength be the number of elements in searchStr.
+ 14. If searchLength+start is greater than len, return false.
+ 15. If the sequence of elements of S starting at start of length searchLength
+ is the same as the full element sequence of searchStr, return true.
+ ...
+---*/
+
+var str = 'The future is cool!';
+
+assert(
+ str.startsWith(''),
+ 'str.startsWith("") returns true'
+);
+
+assert(
+ str.startsWith('', str.length),
+ 'str.startsWith("", str.length) returns true'
+);
+
+assert(
+ str.startsWith(''),
+ 'str.startsWith("") returns true'
+);
+
+assert(
+ str.startsWith('', Infinity),
+ 'str.startsWith("", Infinity) returns true'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-with-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-with-position.js
new file mode 100644
index 0000000000..bae9a17f2e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-with-position.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns true if searchString appears as a substring of the given string with a
+ given position.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 11. Let len be the number of elements in S.
+ 12. Let start be min(max(pos, 0), len).
+ 13. Let searchLength be the number of elements in searchStr.
+ 14. If searchLength+start is greater than len, return false.
+ 15. If the sequence of elements of S starting at start of length searchLength
+ is the same as the full element sequence of searchStr, return true.
+ ...
+---*/
+
+var str = 'The future is cool!';
+
+assert(
+ str.startsWith('The future', 0),
+ 'str.startsWith("The future", 0) === true'
+);
+assert(
+ str.startsWith('future', 4),
+ 'str.startsWith("future", 4) === true'
+);
+assert(
+ str.startsWith(' is cool!', 10),
+ 'str.startsWith(" is cool!", 10) === true'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-without-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-without-position.js
new file mode 100644
index 0000000000..252a877cae
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-without-position.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns true if searchString appears as a substring of the given string.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 11. Let len be the number of elements in S.
+ 12. Let start be min(max(pos, 0), len).
+ 13. Let searchLength be the number of elements in searchStr.
+ 14. If searchLength+start is greater than len, return false.
+ 15. If the sequence of elements of S starting at start of length searchLength
+ is the same as the full element sequence of searchStr, return true.
+ ...
+---*/
+
+var str = 'The future is cool!';
+
+assert(str.startsWith('The '), 'str.startsWith("The ") === true');
+assert(str.startsWith('The future'), 'str.startsWith("The future") === true');
+assert(str.startsWith(str), 'str.startsWith(str) === true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-is-regexp-throws.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-is-regexp-throws.js
new file mode 100644
index 0000000000..e07883e18b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-is-regexp-throws.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Throws a TypeError if searchString is a RegExp.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 4. Let isRegExp be IsRegExp(searchString).
+ 5. ReturnIfAbrupt(isRegExp).
+ 6. If isRegExp is true, throw a TypeError exception.
+ ...
+---*/
+
+var searchString = /./;
+
+assert.throws(TypeError, function() {
+ ''.startsWith(searchString);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-with-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-with-position.js
new file mode 100644
index 0000000000..103223214b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-with-position.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns false if searchString is not found with a given position.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 11. Let len be the number of elements in S.
+ 12. Let start be min(max(pos, 0), len).
+ 13. Let searchLength be the number of elements in searchStr.
+ 14. If searchLength+start is greater than len, return false.
+ 15. If the sequence of elements of S starting at start of length searchLength
+ is the same as the full element sequence of searchStr, return true.
+ 16. Otherwise, return false.
+ ...
+---*/
+
+var str = 'The future is cool!';
+
+assert.sameValue(
+ str.startsWith('The future', 1), false,
+ 'str.startsWith("The future", 1) === false'
+);
+
+assert.sameValue(
+ str.startsWith(str, 1), false,
+ 'str.startsWith(str, 1) === false'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-without-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-without-position.js
new file mode 100644
index 0000000000..04afa3c929
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-without-position.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Returns false if searchString is not found.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ ...
+ 11. Let len be the number of elements in S.
+ 12. Let start be min(max(pos, 0), len).
+ 13. Let searchLength be the number of elements in searchStr.
+ 14. If searchLength+start is greater than len, return false.
+ 15. If the sequence of elements of S starting at start of length searchLength
+ is the same as the full element sequence of searchStr, return true.
+ 16. Otherwise, return false.
+ ...
+---*/
+
+var str = 'The future is cool!';
+
+assert.sameValue(
+ str.startsWith('Flash'), false,
+ 'str.startsWith("Flash") === false'
+);
+assert.sameValue(
+ str.startsWith('THE FUTURE'), false,
+ 'startsWith is case sensitive'
+);
+assert.sameValue(
+ str.startsWith('future is cool!'), false,
+ 'str.startsWith("future is cool!") === false'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/shell.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/shell.js
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/startsWith.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/startsWith.js
new file mode 100644
index 0000000000..a0f0397a0c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/startsWith.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Property type and descriptor.
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ 17 ECMAScript Standard Built-in Objects
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ typeof String.prototype.startsWith,
+ 'function',
+ '`typeof String.prototype.startsWith` is `function`'
+);
+
+verifyNotEnumerable(String.prototype, 'startsWith');
+verifyWritable(String.prototype, 'startsWith');
+verifyConfigurable(String.prototype, 'startsWith');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-null-throws.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-null-throws.js
new file mode 100644
index 0000000000..962a68f925
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-null-throws.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Throws TypeError when `this` is null
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ 1. Let O be RequireObjectCoercible(this value).
+ 2. Let S be ToString(O).
+---*/
+
+assert.throws(TypeError, function() {
+ String.prototype.startsWith.call(null, '');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-undefined-throws.js
new file mode 100644
index 0000000000..6b0803a2f6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-undefined-throws.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 21.1.3.18
+description: >
+ Throws TypeError when `this` is undefined
+info: |
+ 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] )
+
+ 1. Let O be RequireObjectCoercible(this value).
+ 2. Let S be ToString(O).
+---*/
+
+assert.throws(TypeError, function() {
+ String.prototype.startsWith.call(undefined, '');
+});
+
+reportCompare(0, 0);