Closed Bug 1355558 Opened 7 years ago Closed 7 years ago

Throw TypeError when calling RegExp flag and source getters with RegExp.prototype from different global

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(1 file)

Test case:
---
var g = newGlobal();
var r = g.eval("RegExp.prototype");
Object.getOwnPropertyDescriptor(RegExp.prototype, "source").get.call(r);
---

Expected: Throws TypeError
Actual: No TypeError

https://tc39.github.io/ecma262/#sec-get-regexp.prototype.source
Step 3.a compares the this-value with the %RegExpPrototype% of the running execution context, so a wrapped RegExp.prototype object should throw per step 3.b.
Attached patch bug1355558.patchSplinter Review
I've also removed some trivial unnecessary rooting.
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #8857470 - Flags: review?(evilpies)
This seems correct, but this is change might still cause regressions. Can you please push this to try?
(In reply to Tom Schuster [:evilpie] from comment #2)
> This seems correct, but this is change might still cause regressions. Can
> you please push this to try?

Try looks good. 

Chrome is also throwing for cross-global RegExp.prototypes, so I hope this change is web-compatible. We'll see... :-)
Comment on attachment 8857470 [details] [diff] [review]
bug1355558.patch

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

Okay, you are probably right.
Attachment #8857470 - Flags: review?(evilpies) → review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/9dd3f067044f
Throw when calling RegExp.prototype getters with RegExp.prototype from different global. r=evilpie
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/9dd3f067044f
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: