diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /parser/xml/test/unit/test_namespace_support.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'parser/xml/test/unit/test_namespace_support.js')
-rw-r--r-- | parser/xml/test/unit/test_namespace_support.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/parser/xml/test/unit/test_namespace_support.js b/parser/xml/test/unit/test_namespace_support.js new file mode 100644 index 000000000..bcad61e91 --- /dev/null +++ b/parser/xml/test/unit/test_namespace_support.js @@ -0,0 +1,52 @@ +function noop() {} + +function run_test() { + var contentHandler = { + attrs: null, + reset: function() { + this.attrs = []; + }, + startDocument: noop, + endDocument: noop, + + startElement: function startElement(aNamespaceURI, aLocalName, aNodeName, aAttrs) { + for (var i = 0; i < aAttrs.length; i++) + this.attrs.push(aAttrs.getQName(i)); + }, + + endElement: noop, + characters: noop, + processingInstruction: noop, + ignorableWhitespace: noop, + startPrefixMapping: noop, + endPrefixMapping: noop + }; + + const nsISAXXMLReader = Components.interfaces.nsISAXXMLReader; + const src = "<a:x xmlns:a='foo' y='bar'/>"; + const NS_PREFIX = "http://xml.org/sax/features/namespace-prefixes"; + + var saxReader = Components.classes["@mozilla.org/saxparser/xmlreader;1"] + .createInstance(nsISAXXMLReader); + do_check_false(saxReader.getFeature(NS_PREFIX)); + saxReader.contentHandler = contentHandler; + contentHandler.reset(); + saxReader.parseFromString(src, "application/xml"); + do_check_eq(contentHandler.attrs.length, 1); + do_check_eq(contentHandler.attrs[0], "y"); + + saxReader.setFeature(NS_PREFIX, true); + do_check_true(saxReader.getFeature(NS_PREFIX)); + contentHandler.reset(); + saxReader.parseFromString(src, "application/xml"); + do_check_eq(contentHandler.attrs.length, 2); + do_check_eq(contentHandler.attrs[0], "xmlns:a"); + do_check_eq(contentHandler.attrs[1], "y"); + + saxReader.setFeature(NS_PREFIX, false); + do_check_false(saxReader.getFeature(NS_PREFIX)); + contentHandler.reset(); + saxReader.parseFromString(src, "application/xml"); + do_check_eq(contentHandler.attrs.length, 1); + do_check_eq(contentHandler.attrs[0], "y"); +} |