I am currently investigating a website, and have found a curious thing. If I find a PNACL embed element in the developer console, and evaluate it in the Chrome dev console, it logs > anonymous()
, with an arrow next to it that reveals it's an ordinary HTML element. However, typeof temp1
(the variable name) returns function
, but calling it throws
Uncaught TypeError: temp1 is not a function
at <anonymous>:1:1
and calling toString()
returns "[object HTMLEmbedElement]"
. What does > anonymous()
mean, and how can a Javascript variable be a function but uncallable?
MCVE:
FF
var el=document.createElement("embed"); //<embed>
typeof el;// "function"
el.toString(); //"[object HTMLEmbedElement]"
el(); // [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: debugger eval code :: <TOP_LEVEL> :: line 1" data: no]
Chrome
var el=document.createElement("embed"); // anonymous()
typeof el;// "function"
el.toString(); //"[object HTMLEmbedElement]"
el(); //undefined
This is a known bug, I did filed a year ago.
Affected elements :
- HTMLAllCollection
- NPObject(?)
- HTMLObjectElement
- HTMLEmbedElement
Answer from chromium team :
External users have not complained about it, so I'm thinking of Archiving it.
Damn I'm an "external user"...
Current status : Archived
Causes :
These elements have a [Call]
internal method, hence according to EcmaScript, typeof
must return 'function'
. (And this makes the bug a specification one rather than an implementation one...)