Bug 799008: find_elements to not scope parents when searching with css in Marionette; r=dburns
authorAlfredos-Panagiotis Damkalis <fredy@freemail.gr>
Wed, 17 Oct 2012 15:04:16 -0700
changeset 110797 f5760fcd8420024880880780b9f655c8b2434488
parent 110796 c9fe407b3492765e28b1a0fbc1ec93729bf75048
child 110798 87d06105d0baac795a78d3ca814e6715a2fb3cd3
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersdburns
bugs799008
milestone19.0a1
Bug 799008: find_elements to not scope parents when searching with css in Marionette; r=dburns
testing/marionette/client/marionette/tests/unit/test_findelement.py
testing/marionette/marionette-elements.js
--- a/testing/marionette/client/marionette/tests/unit/test_findelement.py
+++ b/testing/marionette/client/marionette/tests/unit/test_findelement.py
@@ -124,16 +124,24 @@ class TestElements(MarionetteTestCase):
     def test_timeout(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         self.assertRaises(NoSuchElementException, self.marionette.find_element, "id", "newDiv")
         self.assertTrue(True, self.marionette.set_search_timeout(4000))
         self.marionette.navigate(test_html)
         self.assertEqual(HTMLElement, type(self.marionette.find_element("id", "newDiv")))
 
+    def test_css_selector_scope_doesnt_start_at_rootnode(self):
+        test_html = self.marionette.absolute_url("test.html")
+        self.marionette.navigate(test_html)
+        el = self.marionette.find_element("id","mozLink")
+        nav_el = self.marionette.find_element("id","testDiv")
+        found_els = nav_el.find_elements("css selector", "a")
+        self.assertFalse(el.id in [found_el.id for found_el in found_els])
+
 class TestElementsChrome(MarionetteTestCase):
     def setUp(self):
         MarionetteTestCase.setUp(self)
         self.marionette.set_context("chrome")
         self.win = self.marionette.current_window_handle
         self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
         self.marionette.switch_to_window('foo')
         self.assertNotEqual(self.win, self.marionette.current_window_handle)
--- a/testing/marionette/marionette-elements.js
+++ b/testing/marionette/marionette-elements.js
@@ -424,17 +424,17 @@ ElementManager.prototype = {
               elements.push(allLinks[i]);
             }
           } else if (text == value) {
             elements.push(allLinks[i]);
           }
         }
         break;
       case SELECTOR:
-        elements = Array.slice(rootNode.querySelectorAll(value));
+        elements = Array.slice(startNode.querySelectorAll(value));
         break;
       default:
         throw new ElementException("No such strategy", 500, null);
     }
     return elements;
   },
 
   /**