Closed
Bug 978232
Opened 11 years ago
Closed 10 years ago
ES6 Proxies: [[Construct]] hook doesn't throw if handler hook doesn't return an object.
Categories
(Core :: JavaScript: Standard Library, defect)
Core
JavaScript: Standard Library
Tracking
()
RESOLVED
FIXED
mozilla31
People
(Reporter: efaust, Assigned: efaust)
References
Details
(Whiteboard: [js:p1])
Attachments
(2 files, 1 obsolete file)
285 bytes,
application/javascript
|
Details | |
2.49 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
This is trivial. We just have to do it.
Assignee | ||
Comment 1•11 years ago
|
||
A simple test case that should throw, but doesn't
Updated•11 years ago
|
Component: JavaScript Engine → JavaScript: Standard Library
OS: Linux → All
Hardware: x86_64 → All
Whiteboard: [js:p1]
Assignee | ||
Comment 2•11 years ago
|
||
Fix with test
Assignee | ||
Updated•11 years ago
|
Attachment #8386440 -
Flags: review?(jorendorff)
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → efaustbmo
Status: NEW → ASSIGNED
Assignee | ||
Comment 3•11 years ago
|
||
Missed out on updating a test
Attachment #8386440 -
Attachment is obsolete: true
Attachment #8386440 -
Flags: review?(jorendorff)
Attachment #8387151 -
Flags: review?(jorendorff)
Comment 4•11 years ago
|
||
Comment on attachment 8387151 [details] [diff] [review]
Throw if the trap return value is not an object
Review of attachment 8387151 [details] [diff] [review]:
-----------------------------------------------------------------
Swiped, given offhand mention on IRC that I should feel free to take a look at this.
The error message might be kind of internal-ish reading, but I'm not inclined to wordsmith too hard right now.
::: js/src/tests/ecma_6/Proxy/proxy-constructNonObject.js
@@ +1,1 @@
> +function bogusConstruct(target) { return 4; }
Add a second one:
function bogusConstruct(target) {}
and test that as well. The |handler.construct| invoked during construction, is invoked by calling it. So this method returns |undefined|, a primitive, and construction should fail.
@@ +1,3 @@
> +function bogusConstruct(target) { return 4; }
> +
> +var handler = { construct: bogusConstruct }
Trailing semicolon? Do not want ASI.
@@ +12,5 @@
> +} catch(e) {
> + threw = true
> +}
> +
> +reportCompare(threw, true, "[[Construct]] must throw if an object is not returned");
Use assertEq, and add
if (typeof reportCompare === "function")
reportCompare(true, true);
at the end. assertEq's arguments order actual/expected in that order, but reportCompare inverts them, and nobody expects that ordering. (Plus this makes the test runnable standalone, without spinning up the whole jstests harness monstrosity.)
Attachment #8387151 -
Flags: review?(jorendorff) → review+
Assignee | ||
Comment 5•10 years ago
|
||
Comment 6•10 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla31
You need to log in
before you can comment on or make changes to this bug.
Description
•