Console.log not defined on Prototype
Reported by
pekka201...@gmail.com,
Sep 13 2016
|
||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.101 Safari/537.36 Steps to reproduce the problem: 1. Console.log does not work 2. Applying .method(argument) in prototype not work 3. Works only when manually force in new Proto.method(argument) What is the expected behavior? I want to this work What went wrong? Console.log, variables just not working properly Did this work before? Yes Chrome 52 Chrome version: 53.0.2785.101 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version: Shockwave Flash 22.0 r0
,
Sep 27 2016
Ok; I'm interpreting this as: Object.getPrototypeOf(console).log returns Undefined as opposed to a function for it.
,
Sep 27 2016
Same thing happens in FireFox as well. But in IE Object.getPrototypeOf(console).log is defined.
,
Sep 30 2016
,
Sep 30 2016
According to [1], the console object is [NoInterfaceObject] which means that there is no "Console" interface. IIUC, in that case there is no prototype object. [1] https://console.spec.whatwg.org/#console-interface [2] https://heycam.github.io/webidl/#NoInterfaceObject I think that the current behavior is expected, but yukishiino@ should confirm. FYI: There is a discussion of static console functions (I didn't follow it though) https://github.com/whatwg/console/issues/3
,
Sep 30 2016
[NoInterfaceObject] only means that the global object (e.g. |window|) does not have a property named the interface name (e.g. window.Console), and has nothing to do with the prototype object. My understanding is that we should have console APIs on the prototype object instead of on the platform object. IIRC, Console APIs are implemented by devtools team without using the binding code generator. pfeldman@, could you triage this issue?
,
Oct 3 2016
In particular: Object.getOwnPropertyNames(console) is returning all the properties, where Object.getOwnPropertyNames(Object.getPrototypeOf(console)) is returning an empty list. Now that there's WebIDL for the console API in a spec, ideally we'd use the bindings generator for them so that the semantics really match what the spec says. dgozman: thoughts?
,
Oct 3 2016
domenic@, is https://console.spec.whatwg.org/#console-interface the latest thinking on how this should work? I assume it's not in IDL because other V8 embedders also want the same API?
,
Oct 3 2016
No, the spec is not quite updated with the latest changes. It was blocked for a long time on adding namespaces to Web IDL, which happened recently. The current consensus (which all non-Edge browsers follow) is that `console` is a namespace object, which means it has no prototype or constructor. Except, for legacy-compat reasons, `console.__proto__` must be an empty object, instead of being `Object.prototype`. See https://github.com/whatwg/console/issues/3#issuecomment-219549472 I can prioritize getting the spec updated if that would help people. But looking through this bug thread, I think this is working as intended and should be WontFixed. My understanding of why this is not implemented in IDL in Blink is that the dev tools team prefers to implement things in JavaScript instead of C++?
,
Oct 3 2016
We changed behavior recently to what domenic@ describes after the discussion linked above. Implementation is not in IDL because it's now a part of v8-inspector, not blink. Historically, there was never an agreement on console from different browsers, so we tried to unify with Mozilla but then changed a bit after lengthy discussion. Note there was a fix even after that, which changed console.prototype from Object.prototype to an empty object, because original behavior broke existing code. See issue 613631 . We can follow up with implementation once the spec is updated.
,
Oct 3 2016
To be clear, once the spec is updated, I think the spec and Chrome will match.
,
Oct 3 2016
,
Nov 15 2016
For historical web-compatibility reasons, the namespace object for console must have as its [[Prototype]] an empty object, created as if by ObjectCreate(%ObjectPrototype%), instead of %ObjectPrototype%. [1] [1] https://console.spec.whatwg.org/#console-namespace |
||||||||||
►
Sign in to add a comment |
||||||||||
Comment 1 by kochi@chromium.org
, Sep 13 2016