String.prototype.{search, split, replace} should ignore |null| methods

RESOLVED FIXED in Firefox 50

Status

()

defect
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: anba, Assigned: arai)

Tracking

Trunk
mozilla50
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox47 unaffected, firefox48 unaffected, firefox49 affected, firefox-esr45 unaffected, firefox50 fixed)

Details

Attachments

(1 attachment)

Test case 1:
---
r = "a-a".split({[Symbol.split]: null, toString(){ return "-"; }});
print(r);
---

Expected: Prints "a,a"
Actual: Throws TypeError



Test case 2:
---
r = "a-a".search({[Symbol.search]: null, toString(){ return "-"; }});
print(r);
---

Expected: Prints "1"
Actual: Throws TypeError



Test case 3:
---
r = "a-a".replace({[Symbol.replace]: null, toString(){ return "-"; }}, "+");
print(r);
---

Expected: Prints "a+a"
Actual: Throws TypeError
somehow I forgot to use GetMethod for search/replace/split, but was using on match ... :P
try is running: https://treeherder.mozilla.org/#/jobs?repo=try&revision=16e0e6ce4a45
Assignee: nobody → arai.unmht
Blocks: 887016
Status: NEW → ASSIGNED
Comment on attachment 8776296 [details] [diff] [review]
Call GetMethod in String.prototype.{search,replace,split}.

Review of attachment 8776296 [details] [diff] [review]:
-----------------------------------------------------------------

You could check GetMethod "Step 4. If IsCallable(func) is false, throw a TypeError exception." as well.
Attachment #8776296 - Flags: review?(evilpies) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/d7cca89ce49723337bd50dd04fec86f43096560a
Bug 1290655 - Call GetMethod in String.prototype.{search,replace,split}. r=evilpie
https://hg.mozilla.org/mozilla-central/rev/d7cca89ce497
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in before you can comment on or make changes to this bug.