QA/TDAI/Gristmill/Gristmill API: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 325: Line 325:
|}
|}
Returns true if the given image is loaded, false otherwise
Returns true if the given image is loaded, false otherwise
== Element APIs ==
These APIs live on the elementslib object.  You instantiate that object by the following code:
<pre>
var elementslib = {};
Components.utils.import('resource://mozmill/modules/elementslib.js', elementslib);
</pre>
Each of these calls can be used to find elements in either the content or the chrome space.  There are several ways to look up an element, but the general paradigm is: elementslib.<method>(<document>,<node identifier>);
Here are the APIs:
===elementslib.Elem(node)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|node
|A fully specified element.
|}
This is the lowest level API.  You have to give it a fully specified element, and it will wrap that element into an element lib object so that you can pass it to the controller APIs.
An example:
<pre>
elementlib.Elem(controller.window.content.document.getElementById('foo'));
</pre>
We also use this for shortcut elements that we've defined for certain chrome objects like tabs in the preferences window:
<pre>
elementslib.Elem(prefController.tabs.Content.button);
</pre>
===elementslib.ID(document, id)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|document
|Document to reference, ex. controller.window.content.document for content or controller.window.document for chrome.
|-
|id
|The ID of the node you want to grab out of the document
|}
Grabs the node with the corresponding ID from the document and wraps it into an elementlib object.
===elementslib.Name(document, name)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|document
|Document to reference, ex. controller.window.content.document for content or controller.window.document for chrome.
|-
|name
|The name attribute of the node you want to grab out of the document
|}
Grabs the node with the corresponding name attribute from the document and wraps it into an elementlib object.
Confirmed users
3,816

edits