Search code examples
javascripthtmlgwtobjectgarmin

Discover HTML Object tags methods/properties


The Garmin Communicator API operates through a browser plugin that is exposed to JS from an <object> tag embedded in the HTML body.

I'm trying to find any undocumented methods/properties of this object as I build the GWT-Garmin-API. Working with their JS API source I can see the official methods, but I want to find any other methods/props. So far I cannot find a way to list these from a reference to the Object element in the page.

No debugger I use shows any such props. I was hoping there might be some Object reflection kungfu I don't know about. Thanks.

Update:

Example can be found at the Garmin Hello Device example.

From the console, iterate across the object you'll find from the following:

var plugin = document.getElementsByTagName('object')[0];

for(var prop in plugin) {
    console.log( prop );
}

However this will not find plugin methods like plugin.Unlock(), which you can easily call from the same console line.


Solution

  • No debugger I use shows any such props

    Then there is no such thing, assuming those host objects are not implemented as Proxies.

    Your approach of enumerating properties with a for-in-loop (and even heavier weapons such as Object.getOwnPropertyNames and Object.getPrototypeOf) is flawed, as anything visible like that would be shown in your debugger.

    If you really want to find "hidden" properties (I'm very sure there are none), you would need to brute-force test all possible property names. Or have a look into their source, which might be hidden from you if it's a host object.