File tree Expand file tree Collapse file tree 3 files changed +27
-13
lines changed
lib/selenium/webdriver/firefox
spec/unit/selenium/webdriver/firefox Expand file tree Collapse file tree 3 files changed +27
-13
lines changed Original file line number Diff line number Diff line change 3
3
4
4
Ruby:
5
5
* Removed dependency on "multi_json" (issue 1632)
6
+ * Properly handle namespaces in install manifest of Firefox add-ons (issue 1143)
6
7
7
8
2.52.0 (2016-02-12)
8
9
===================
Original file line number Diff line number Diff line change @@ -21,8 +21,13 @@ module Selenium
21
21
module WebDriver
22
22
module Firefox
23
23
24
+ #
24
25
# @api private
26
+ #
27
+
25
28
class Extension
29
+ NAMESPACE = 'http://www.mozilla.org/2004/em-rdf#'
30
+
26
31
def initialize ( path )
27
32
unless File . exist? ( path )
28
33
raise Error ::WebDriverError , "could not find extension at #{ path . inspect } "
@@ -61,20 +66,17 @@ def create_root
61
66
def read_id_from_install_rdf ( directory )
62
67
rdf_path = File . join ( directory , "install.rdf" )
63
68
doc = REXML ::Document . new ( File . read ( rdf_path ) )
69
+ namespace = doc . root . namespaces . key ( NAMESPACE )
64
70
65
- id_node = REXML ::XPath . first ( doc , "//em:id" )
66
-
67
- if id_node
68
- id_node . text
69
- else
70
- attr_node = REXML ::XPath . first ( doc , "//@em:id" )
71
+ if namespace
72
+ id_node = REXML ::XPath . first ( doc , "//#{ namespace } :id" )
73
+ return id_node . text if id_node
71
74
72
- if attr_node . nil?
73
- raise Error ::WebDriverError , "cannot locate extension id in #{ rdf_path } "
74
- end
75
-
76
- attr_node . value
75
+ attr_node = REXML ::XPath . first ( doc , "//@#{ namespace } :id" )
76
+ return attr_node . value if attr_node
77
77
end
78
+
79
+ raise Error ::WebDriverError , "cannot locate extension id in #{ rdf_path } "
78
80
end
79
81
80
82
end # Extension
Original file line number Diff line number Diff line change @@ -60,6 +60,19 @@ def ext.read_id(dir); read_id_from_install_rdf(dir); end
60
60
expect ( extension . read_id ( '/foo' ) ) . to eq ( '{f5198635-4eb3-47a5-b6a5-366b15cd2107}' )
61
61
end
62
62
63
+ it 'finds the rdf extension id regardless of namespace' do
64
+ allow ( File ) . to receive ( :read ) . with ( '/foo/install.rdf' ) . and_return <<-XML
65
+ <?xml version="1.0"?>
66
+ <r:RDF xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.mozilla.org/2004/em-rdf#">
67
+ <r:Description about="urn:mozilla:install-manifest">
68
+ <id>{f5198635-4eb3-47a5-b6a5-366b15cd2107}</id>
69
+ </r:Description>
70
+ </r:RDF>
71
+ XML
72
+
73
+ expect ( extension . read_id ( '/foo' ) ) . to eq ( '{f5198635-4eb3-47a5-b6a5-366b15cd2107}' )
74
+ end
75
+
63
76
it 'raises if the node id is not found' do
64
77
allow ( File ) . to receive ( :read ) . with ( '/foo/install.rdf' ) . and_return <<-XML
65
78
<?xml version="1.0"?>
@@ -68,10 +81,8 @@ def ext.read_id(dir); read_id_from_install_rdf(dir); end
68
81
69
82
expect { extension . read_id ( '/foo' ) } . to raise_error ( Error ::WebDriverError )
70
83
end
71
-
72
84
end
73
85
74
86
end # Firefox
75
87
end # WebDriver
76
88
end # Selenium
77
-
You can’t perform that action at this time.
0 commit comments