blob: 3834e6fac555ad462673d180d1ee562bdce2d6da [file] [log] [blame]
//@ runNoFTL
function assert(testedValue, msg) {
if (!testedValue)
throw Error(msg);
}
// String prototype with overridden @@search.
(function () {
let accesses = [];
var obj = String("");
Object.defineProperty(String.prototype, Symbol.search, {
value: function (str) {
accesses.push("Symbol(Symbol.search)");
return /rch/[Symbol.search](str);
},
writable: true,
configurable: true,
});
assert(accesses == "", "unexpected call to overridden props");
let result = "searchme".search(obj);
assert(accesses == "Symbol(Symbol.search)", "Property accesses do not match expectation");
assert(result === 3, "Unexpected result");
Object.defineProperty(String.prototype, Symbol.search, { value: undefined, writable: false, configurable: true });
})();