summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js')
-rw-r--r--js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js b/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js
new file mode 100644
index 0000000000..7fec73440a
--- /dev/null
+++ b/js/src/tests/test262/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-string.prototype.replaceall
+description: >
+ [[IsHTMLDDA]] object as @@replace method gets called.
+info: |
+ String.prototype.replaceAll ( searchValue, replaceValue )
+
+ [...]
+ 2. If searchValue is neither undefined nor null, then
+ [...]
+ c. Let replacer be ? GetMethod(searchValue, @@replace).
+ d. If replacer is not undefined, then
+ i. Return ? Call(replacer, searchValue, « O, replaceValue »).
+features: [Symbol.replace, String.prototype.replaceAll, IsHTMLDDA]
+---*/
+
+var searchValue = $262.IsHTMLDDA;
+var replacerGets = 0;
+Object.defineProperty(searchValue, Symbol.replace, {
+ get: function() {
+ replacerGets += 1;
+ return searchValue;
+ },
+ configurable: true,
+});
+
+assert.sameValue("".replaceAll(searchValue), null);
+assert.sameValue(replacerGets, 1);
+
+reportCompare(0, 0);