Bug 1198228 - Support em:foo attributes on Description elements. r=whimboo

The install.rdf in language packs uses em:id attributes etc, instead
of child elements. All fine with RDF/XML.
This adds support to addon_details to allow for those attributes in
addition to child elements.
This commit is contained in:
Axel Hecht 2015-08-26 13:21:30 +02:00
parent c36ec9adc7
commit d9e570bdaf
2 changed files with 31 additions and 1 deletions

View File

@ -297,6 +297,11 @@ class AddonManager(object):
rdf = get_namespace_id(doc, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')
description = doc.getElementsByTagName(rdf + 'Description').item(0)
for entry, value in description.attributes.items():
# Remove the namespace prefix from the tag for comparison
entry = entry.replace(em, "")
if entry in details.keys():
details.update({entry: value})
for node in description.childNodes:
# Remove the namespace prefix from the tag for comparison
entry = node.nodeName.replace(em, "")

View File

@ -148,7 +148,32 @@ class AddonIDTest(unittest.TestCase):
<foobar:description>A testing extension based on the Windmill Testing Framework client source</foobar:description>
<foobar:unpack>true</foobar:unpack>
</Description>
</RDF>"""]
</RDF>""",
"""<?xml version="1.0"?>
<!--
-->
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest"
em:id="winning"
em:name="Language Pack"
em:version="42.0a2"
em:type="8"
em:creator="Some Contributor">
<em:contributor></em:contributor>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>42.0a2</em:minVersion>
<em:maxVersion>42.0a2</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>
"""]
return tests
if __name__ == '__main__':