Closed Bug 924489 Opened 11 years ago Closed 9 years ago

Applying non-generic methods to scripted direct proxies should throw TypeError

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: jorendorff, Unassigned)

Details

I don't think there's anything in ES6 that says this method call should work:

    var p = new Proxy(new Date(), {});
    Date.prototype.getFullYear.call(p); // should throw TypeError

I think it should fail, because:
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-date-prototype-object

> The abstract operation thisTimeValue(value) performs the following steps:
> 
>     1. If Type(value) is Object and value has a [[DateValue]] internal data
>        property, then
>         a. Let n be the Number that is the value of value’s [[DateValue]]
>            internal data property.
>         b. If n is not undefined, then return n.
>     2. Throw a TypeError exception.


This ends up in DirectProxyHandler::nativeCall().

The obvious fix would be to add ScriptedDirectProxyHandler::nativeCall() along the lines of the existing code below:

    bool
    BaseProxyHandler::nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args)
    {
        ReportIncompatible(cx, args);
        return false;
    }
Assignee: general → nobody
The test case is no longer reproducible - resolving as WFM.

ScriptedDirectProxyHandler::nativeCall was added in http://hg.mozilla.org/mozilla-central/rev/c1fb4bf7b043.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.