blob: 39f04e50b38fa7c7a697dd80eb1f2c1ab1674a38 [file] [log] [blame]
ossy@webkit.org8f73aef2016-07-21 18:08:38 +00001//@ runNoFTL
mark.lam@apple.com2c87b1a2016-04-20 00:02:07 +00002
3function assert(testedValue, msg) {
4 if (!testedValue)
5 throw Error(msg);
6}
7
8// String prototype with overridden @@search: test with string literal.
9(function () {
10 let accesses = [];
11 var obj = "";
12 Object.defineProperty(String.prototype, Symbol.search, {
13 value: function (str) {
14 accesses.push("Symbol(Symbol.search)");
15 return /rch/[Symbol.search](str);
16 },
17 writable: true,
18 configurable: true,
19 });
20
21 assert(accesses == "", "unexpected call to overridden props");
22 let result = "searchme".search(obj);
23 assert(accesses == "Symbol(Symbol.search)", "Property accesses do not match expectation");
24 assert(result === 3, "Unexpected result");
25
26 Object.defineProperty(String.prototype, Symbol.search, { value: undefined, writable: false, configurable: true });
27})();