Open
Bug 1089128
Opened 10 years ago
Updated 2 years ago
DOM Promise are too eager to call `then`
Categories
(Core :: DOM: Core & HTML, defect, P5)
Tracking
()
NEW
People
(Reporter: Yoric, Unassigned)
Details
Here I am, attempting to sanitize code by adding the following proxy: var proxy = new Proxy({}, { get: function(target, name) { if (name in target) { return target[name]; } throw new Error("No such property: " + name); } }); Unfortunately, `proxy` cannot be used to resolve a promise: var p = new Promise(resolve => resolve(proxy)); p.then(() => console.log("Success"), ex => console.error(ex)); // Displays: "No such property: then" I expect that, since `then` is not a key of `proxy`, we should never get `proxy.then`.
Comment 1•10 years ago
|
||
Per spec at http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-resolve-functions there is no check for "then" being a key. As long as the resolution value is not the promise itself and Type(resolution) is Object, we get to step 8, which does: 8. Let then be Get(resolution, "then"). In general, all sorts of algorithms in the spec use Get, not a combination of HasProperty and Get, and this proxy would fail for those. Another example is passing this proxy to Array.from if the target has a "length" property but is not iterable. Since GetIterator simply does a Get on @@iterator, you'll end up throwing... That said, it may be worth a spec issue here since resolving promises with filtering proxies seems like a much more sane use case than passing such proxies to Array.from.
Comment 2•6 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Assignee | ||
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•