[webkit-dev] Invocation with undefined this on JS binding object

Xabier Rodríguez Calvar calvaris at igalia.com
Wed Jul 1 10:59:06 PDT 2015


I need some help with some JS bindings code. I am implementing
CountQueuingStrategy [1], which is an object containing two properties,
one of them a function. That strategy is passed to another
ReadableStream object [2] and as you can see at step 8, the size method
is extracted from the strategy and kept inside the stream for later
use. That use happens at [3], step 5.b.i, when the spec says that we
have to pass undefined as this (and we do).

[1] https://streams.spec.whatwg.org/#cqs-class
[2] https://streams.spec.whatwg.org/#rs-constructor
[3] https://streams.spec.whatwg.org/#enqueue-in-readable-stream

The problem comes when invoking that method at the generated bindings:

jsCountQueuingStrategyPrototypeFunctionSize(ExecState* exec)
    JSValue thisValue = exec->thisValue();
    JSCountQueuingStrategy* castedThis =
    if (UNLIKELY(!castedThis))
        return throwThisTypeError(*exec, "CountQueuingStrategy",
    return JSValue::encode(castedThis->size(exec));

The problem is that it checks that "this" casts to the class and of
course it fails because the spec says it has to be undefined. I haven't
found any way to overcome this, even making the method custom.

Any ideas here?

Thanks in advance and best regards.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20150701/185c08de/attachment.sig>

More information about the webkit-dev mailing list