Bug 1198542: Update Marionette element IDs to be valid UUID. r=ato
authorDavid Burns <dburns@mozilla.com>
Wed, 26 Aug 2015 19:52:09 +0100
changeset 259534 872647dec5da7e61b5a99c5bbf04729f6c905389
parent 259533 2b4d90f62a5c07b151239027434672a4f373c6a8
child 259535 f2f4c7d1bd28a023818b0f7df23dc2c3e088a42e
push id64268
push userdburns@mozilla.com
push dateThu, 27 Aug 2015 07:21:50 +0000
treeherdermozilla-inbound@872647dec5da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1198542
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1198542: Update Marionette element IDs to be valid UUID. r=ato This allows WebDriver compatibility to create valid URI.
testing/marionette/client/marionette/tests/unit/test_findelement.py
testing/marionette/elements.js
--- a/testing/marionette/client/marionette/tests/unit/test_findelement.py
+++ b/testing/marionette/client/marionette/tests/unit/test_findelement.py
@@ -154,8 +154,18 @@ class TestElements(MarionetteTestCase):
         fbody = self.marionette.find_element(By.TAG_NAME, 'body')
         abody = self.marionette.get_active_element()
         self.assertEqual(fbody, abody)
 
     def test_throws_error_when_trying_to_use_invalid_selector_type(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         self.assertRaises(InvalidSelectorException, self.marionette.find_element, "Brie Search Type", "doesn't matter")
+
+    def test_element_id_is_valid_uuid(self):
+        import re
+        test_html = self.marionette.absolute_url("test.html")
+        self.marionette.navigate(test_html)
+        el = self.marionette.find_element(By.TAG_NAME, "body")
+        uuid_regex = re.compile('^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$')
+        self.assertIsNotNone(re.search(uuid_regex, el.id),
+                             'UUID for the WebElement is not valid. ID is {}'\
+                             .format(el.id))
--- a/testing/marionette/elements.js
+++ b/testing/marionette/elements.js
@@ -228,17 +228,18 @@ ElementManager.prototype = {
         if (XPCNativeWrapper(foundEl) == XPCNativeWrapper(element)) {
           return i;
         }
       } else {
         // cleanup reference to GC'd element
         delete this.seenItems[i];
       }
     }
-    let id = uuidGen.generateUUID().toString();
+    let uuid = uuidGen.generateUUID().toString();
+    let id = uuid.substring(1, uuid.length - 1);
     this.seenItems[id] = Components.utils.getWeakReference(element);
     return id;
   },
 
   /**
    * Retrieve element from its unique ID
    *
    * @param String id