diff --git a/testing/marionette/element.js b/testing/marionette/element.js index 677153d5067e..51e69c6efc0f 100644 --- a/testing/marionette/element.js +++ b/testing/marionette/element.js @@ -32,7 +32,6 @@ const { ORDERED_NODE_ITERATOR_TYPE, } = Ci.nsIDOMXPathResult; -const SVGNS = "http://www.w3.org/2000/svg"; const XBLNS = "http://www.mozilla.org/xbl"; const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; @@ -143,14 +142,14 @@ element.Store = class { */ add(el) { const isDOMElement = element.isDOMElement(el); - const isSVGElement = element.isSVGElement(el); const isDOMWindow = element.isDOMWindow(el); const isXULElement = element.isXULElement(el); const context = isXULElement ? "chrome" : "content"; - if (!(isDOMElement || isSVGElement || isDOMWindow || isXULElement)) { - throw new TypeError("Expected Element, SVGElement, " + - pprint`WindowProxy, or XULElement, got: ${el}`); + if (!(isDOMElement || isDOMWindow || isXULElement)) { + throw new TypeError( + "Expected an element or WindowProxy, " + + pprint`got: ${el}`); } for (let i in this.els) { @@ -1058,16 +1057,14 @@ element.scrollIntoView = function(el) { * Ascertains whether node is a DOM-, SVG-, or XUL element. * * @param {*} node - * Element thought to be an Element, - * SVGElement, or XULElement. + * Element thought to be an Element or + * XULElement. * * @return {boolean} * True if node is an element, false otherwise. */ element.isElement = function(node) { - return element.isDOMElement(node) || - element.isSVGElement(node) || - element.isXULElement(node); + return element.isDOMElement(node) || element.isXULElement(node); }; /** @@ -1082,26 +1079,11 @@ element.isElement = function(node) { element.isDOMElement = function(node) { return typeof node == "object" && node !== null && + "nodeType" in node && node.nodeType === node.ELEMENT_NODE && !element.isXULElement(node); }; -/** - * Ascertains whether node is an SVG element. - * - * @param {*} node - * Object thought to be an SVGElement. - * - * @return {boolean} - * True if node is an SVG element, false otherwise. - */ -element.isSVGElement = function(node) { - return typeof node == "object" && - node !== null && - node.nodeType === node.ELEMENT_NODE && - node.namespaceURI === SVGNS; -}; - /** * Ascertains whether el is a XUL- or XBL element. * @@ -1252,7 +1234,7 @@ class WebElement { static from(node) { const uuid = WebElement.generateUUID(); - if (element.isDOMElement(node) || element.isSVGElement(node)) { + if (element.isDOMElement(node)) { return new ContentWebElement(uuid); } else if (element.isDOMWindow(node)) { if (node.parent === node) { diff --git a/testing/marionette/evaluate.js b/testing/marionette/evaluate.js index 17d33d8fd513..4d04adc4106c 100644 --- a/testing/marionette/evaluate.js +++ b/testing/marionette/evaluate.js @@ -265,7 +265,7 @@ evaluate.toJSON = function(obj, seenEls) { if (t == "[object Undefined]" || t == "[object Null]") { return null; - // literals + // primitives } else if (t == "[object Boolean]" || t == "[object Number]" || t == "[object String]") { @@ -279,7 +279,7 @@ evaluate.toJSON = function(obj, seenEls) { } else if (WebElement.isReference(obj)) { return obj; - // Element, SVGElement, XULElement + // Element (HTMLElement, SVGElement, XULElement, &c.) } else if (element.isElement(obj)) { let webEl = seenEls.add(obj); return webEl.toJSON(); diff --git a/testing/marionette/test_element.js b/testing/marionette/test_element.js index 4220a9c50cf8..7866a6436406 100644 --- a/testing/marionette/test_element.js +++ b/testing/marionette/test_element.js @@ -149,19 +149,6 @@ add_test(function test_isDOMElement() { run_next_test(); }); -add_test(function test_isSVGElement() { - ok(element.isSVGElement(svgEl)); - ok(!element.isSVGElement(domEl)); - ok(!element.isSVGElement(xulEl)); - ok(!element.isSVGElement(domWin)); - ok(!element.isSVGElement(domFrame)); - for (let typ of [true, 42, {}, [], undefined, null]) { - ok(!element.isSVGElement(typ)); - } - - run_next_test(); -}); - add_test(function test_isXULElement() { ok(element.isXULElement(xulEl)); ok(element.isXULElement(xblEl));