Bug 1198542: Update Marionette element IDs to be valid UUID. r=ato a=testonly
authorDavid Burns <dburns@mozilla.com>
Wed, 26 Aug 2015 19:52:09 +0100
changeset 289131 84c39fd559177869054b7af18caa4d264ac54cad
parent 289130 7ba5523ffb28d1124978af627d921b9c0a956717
child 289132 cef90ae4d2287124496716eb90a29406513e1481
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato, testonly
bugs1198542
milestone42.0a2
Bug 1198542: Update Marionette element IDs to be valid UUID. r=ato a=testonly 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
@@ -226,17 +226,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