From 9e3770b2b31a1f17d6d0208f30a097b015a207b8 Mon Sep 17 00:00:00 2001 From: "anodelman%mozilla.com" Date: Tue, 29 Jun 2010 18:23:52 +0000 Subject: [PATCH] bug 559929 (Run performance tests on top addons) expanded support for discovering em:id in addon install.rdf (take 3) p=anodelman r=jhammel git-svn-id: svn://10.0.0.236/trunk@260596 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/testing/performance/talos/ffsetup.py | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/mozilla/testing/performance/talos/ffsetup.py b/mozilla/testing/performance/talos/ffsetup.py index d944be7a24b..6367af083d6 100644 --- a/mozilla/testing/performance/talos/ffsetup.py +++ b/mozilla/testing/performance/talos/ffsetup.py @@ -108,8 +108,22 @@ class FFSetup(object): # Clint Talbert # Henrik Skupin """ + def find_id(desc): + addon_id = None + for elem in desc: + apps = elem.getElementsByTagName('em:targetApplication') + if apps: + for app in apps: + #remove targetApplication nodes, they contain id's we aren't interested in + elem.removeChild(app) + if elem.getElementsByTagName('em:id'): + addon_id = str(elem.getElementsByTagName('em:id')[0].firstChild.data) + elif elem.hasAttribute('em:id'): + addon_id = str(elem.getAttribute('em:id')) + return addon_id + tmpdir = None - addon_id = '' + addon_id = None tmpdir = tempfile.mkdtemp(suffix = "." + os.path.split(addon)[-1]) compressed_file = zipfile.ZipFile(addon, "r") #in python2.6 can use extractall, currently limited to python2.4 @@ -127,15 +141,12 @@ class FFSetup(object): doc = minidom.parse(os.path.join(addon, 'install.rdf')) # description_element = # tree.find('.//{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description/') - + desc = doc.getElementsByTagName('Description') - for elem in desc: - apps = elem.getElementsByTagName('em:targetApplication') - if apps: - for app in apps: - #remove targetApplication nodes, they contain id's we aren't interested in - elem.removeChild(app) - addon_id = str(elem.getElementsByTagName('em:id')[0].firstChild.data) + addon_id = find_id(desc) + if not addon_id: + desc = doc.getElementsByTagName('RDF:Description') + addon_id = find_id(desc) if not addon_id: #bail out, we don't have an addon id raise talosError("no addon_id found for extension")