dom.js
No description.

File Location

/goog/testing/dom.js


Public Protected Private

Global Functions

goog.testing.dom.assertHtmlContentsMatch&advanceActualNode()
No description.
code »
goog.testing.dom.assertAttributesEqual_(errorSuffixexpectedElemactualElemstrictAttributes)
Assert that the attributes of two Nodes are the same (ignoring any instances of the style attribute).
Arguments:
errorSuffix : string
String to add to end of error messages.
expectedElem : !Element
The element whose attributes we are expecting.
actualElem : !Element
The element with the actual attributes.
strictAttributes : boolean
If false, attributes that appear in expectedNode must also be in actualNode, but actualNode can have attributes not present in expectedNode. If true, expectedNode and actualNode must have the same set of attributes.
code »
goog.testing.dom.assertHtmlContentsMatch(htmlPatternactualopt_strictAttributes)
Assert that the html in actual is substantially similar to htmlPattern. This method tests for the same set of styles, for the same order of nodes, and the presence of attributes. Breaking whitespace nodes are ignored. Elements can be annotated with classnames corresponding to keys in goog.userAgent and will be expected to show up in that user agent and expected not to show up in others.
Arguments:
htmlPattern : string
The pattern to match.
actual : !Node
The element to check: its contents are matched against the HTML pattern.
opt_strictAttributes : boolean=
If false, attributes that appear in htmlPattern must be in actual, but actual can have attributes not present in htmlPattern. If true, htmlPattern and actual must have the same set of attributes. Default is false.
code »
goog.testing.dom.assertHtmlMatches(htmlPatternactual)
Assert that the html in actual is substantially similar to htmlPattern. This method tests for the same set of styles, and for the same order of nodes. Breaking whitespace nodes are ignored. Elements can be annotated with classnames corresponding to keys in goog.userAgent and will be expected to show up in that user agent and expected not to show up in others.
Arguments:
htmlPattern : string
The pattern to match.
actual : string
The html to check.
code »
goog.testing.dom.assertNodesMatch(itarray)
Tests if the given iterator over nodes matches the given Array of node descriptors. Throws an error if any match fails.
Arguments:
it : goog.iter.Iterator
An iterator over nodes.
array : Array.<Node | number | string>
Array of node descriptors to match against. Node descriptors can be any of the following: Node: Test if the two nodes are equal. number: Test node.nodeType == number. string starting with '#': Match the node's id with the text after "#". other string: Match the text node's contents.
code »
goog.testing.dom.assertRangeEquals(startstartOffsetendendOffsetrange)
Assert the end points of a range. Notice that "Are two ranges visually identical?" and "Do two ranges have the same endpoint?" are independent questions. Two visually identical ranges may have different endpoints. And two ranges with the same endpoints may be visually different.
Arguments:
start : Node
The expected start node.
startOffset : number
The expected start offset.
end : Node
The expected end node.
endOffset : number
The expected end offset.
range : goog.dom.AbstractRange
The actual range.
code »
goog.testing.dom.checkUserAgents_(userAgents) boolean
Determines if the current user agent matches the specified string. Returns false if the string does specify at least one user agent but does not match the running agent.
Arguments:
userAgents : string
Space delimited string of user agents.
Returns: boolean  Whether the user agent was matched. Also true if no user agent was listed in the expectation string.
code »
goog.testing.dom.compareClassAttribute_(expectedElemactualElem)
Assert the class attribute of actualElem is the same as the one in expectedElem, ignoring classes that are useragents.
Arguments:
expectedElem : !Element
The DOM element whose class we expect.
actualElem : !Element
The DOM element with the actual class.
code »
goog.testing.dom.compareIdAttributeForIe_(expectedValueactualAttributestrictAttributeserrorSuffix)
Compare id attributes for IE. In IE, if an element lacks an id attribute in the original HTML, the element object will still have such an attribute, but its value will be the empty string.
Arguments:
expectedValue : string
The expected value of the id attribute.
actualAttribute : Attr
The actual id attribute.
strictAttributes : boolean
Whether strict attribute checking should be done.
errorSuffix : string
String to append to error messages.
code »
goog.testing.dom.createEndTagMarker_() !Node
No description.
Returns: !Node  A DIV node with a unique ID identifying the END_TAG_MARKER_.
code »
goog.testing.dom.describeNode_(node) string
Describes the given node.
Arguments:
node : Node
The node to describe.
Returns: string  A description of the node.
code »
goog.testing.dom.endTagMap_(nodeignoreiterator) Node
Map function that converts end tags to a specific object.
Arguments:
node : Node
The node to map.
ignore : undefined
Always undefined.
iterator : !goog.iter.Iterator.<Node>
The iterator.
Returns: Node  The resulting iteration item.
code »
goog.testing.dom.exposeNode(node) string
Exposes a node as a string.
Arguments:
node : Node
A node.
Returns: string  A string representation of the node.
code »
goog.testing.dom.exposeRange(range) string
Exposes the nodes of a range wrapper as a string.
Arguments:
range : goog.dom.AbstractRange
A range.
Returns: string  A string representation of the range.
code »
goog.testing.dom.findTextNode(textOrRegexproot) Node
Finds the first text node descendant of root with the given content. Note that this operates on a text node level, so if text nodes get split this may not match the user visible text. Using normalize() may help here.
Arguments:
textOrRegexp : string | RegExp
The text to find, or a regular expression to find a match of.
root : Element
The element to search in.
Returns: Node  The first text node that matches, or null if none is found.
code »
goog.testing.dom.getAttributeValue_(nodename) *
Gets the value of a DOM attribute in deterministic way.
Arguments:
node : !Node
A node.
name : string
Attribute name.
Returns: *  Attribute value.
code »
goog.testing.dom.getExpectedText_(node) string
Determines the text to match from the given node, removing browser specification strings.
Arguments:
node : Node
The node expected to match.
Returns: string  The text, stripped of browser specification strings.
code »
goog.testing.dom.ignoreAttribute_(name) boolean
Whether to ignore the attribute.
Arguments:
name : string
Name of the attribute.
Returns: boolean  True if the attribute should be ignored.
code »
goog.testing.dom.nodeFilter_(node) boolean
Check if the given node is important. A node is important if it is a non-empty text node, a non-annotated element, or an element annotated to match on this user agent.
Arguments:
node : Node
The node to test.
Returns: boolean  Whether this node should be included for iteration.
code »

Directory testing

File Reference