Open Bug 1158023 Opened 10 years ago Updated 2 years ago

uneval of DOMException can fail to parse

Categories

(Core :: JavaScript Engine, defect)

defect

Tracking

()

People

(Reporter: jruderman, Unassigned)

References

Details

(Keywords: testcase)

> uneval(new DOMException("#", "%")) (new %("#", "", 1)) Why is the second argument being treated as if it's a constructor name?
> Why is the second argument being treated as if it's a constructor name? new DOMException(x, y) creates a DOMException with .message == x and .name == y. uneval does toSource. DOMException has Error.prototype on its prototype chain. So we end up invoking Error.prototype.toSource on this DOMException. Which leads us to a simple way to reproduce this problem without DOMException: uneval(Object.create(Error.prototype, { name: { value: "%" } })) So what's happening is that Error.prototype.toSource (exn_toSource) never checks for thisval being an Error and just happily gets its .name, .message, .fileName, etc and produces a string from all that.
Component: DOM → JavaScript Engine
Or heck, here's another simple example: var e = new Error(); e.name = "%"; uneval(e)
Has Regression Range: --- → irrelevant
Severity: minor → S4
You need to log in before you can comment on or make changes to this bug.