Merge mozilla-central to autoland a=backout
authorAndreea Pavel <apavel@mozilla.com>
Fri, 06 Apr 2018 10:10:19 +0300
changeset 412003 46a5fc19bd7aed9fc92946215ee7f83eea279f8d
parent 412002 0888bc574df1547f2100b7f015f587809f949771 (current diff)
parent 411925 62c2508f27a865dd0ac5ca3f0485cb20afafbbd0 (diff)
child 412004 42cfc3e15726176aa4a45b47ebeaede092188593
child 412077 31756b7db3ddf9bbfffc030aab85c2d41854ddf2
child 412084 e6ecac1e488465a34471999306e1776e7fe11a1d
push id33778
push userapavel@mozilla.com
push dateFri, 06 Apr 2018 09:57:38 +0000
treeherdermozilla-central@46a5fc19bd7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
milestone61.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
Merge mozilla-central to autoland a=backout
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -20,18 +20,18 @@ from six import reraise
 
 from . import errors
 from . import transport
 from .decorators import do_process_check
 from .geckoinstance import GeckoInstance
 from .keys import Keys
 from .timeout import Timeouts
 
-WEB_ELEMENT_KEY = "element-6066-11e4-a52e-4f735466cecf"
-CHROME_ELEMENT_KEY = "chromeelement-9fc5-4b51-a3c8-01716eedeb04"
+WEBELEMENT_KEY = "ELEMENT"
+W3C_WEBELEMENT_KEY = "element-6066-11e4-a52e-4f735466cecf"
 
 
 class HTMLElement(object):
     """Represents a DOM Element."""
 
     def __init__(self, marionette, id):
         self.marionette = marionette
         assert(id is not None)
@@ -745,22 +745,22 @@ class Marionette(object):
             self._handle_error(err)
 
         if key is not None:
             return self._unwrap_response(res.get(key))
         else:
             return self._unwrap_response(res)
 
     def _unwrap_response(self, value):
-        if isinstance(value, dict) and (WEB_ELEMENT_KEY in value or
-                                        CHROME_ELEMENT_KEY in value):
-            if value.get(WEB_ELEMENT_KEY):
-                return HTMLElement(self, value.get(WEB_ELEMENT_KEY))
+        if isinstance(value, dict) and (WEBELEMENT_KEY in value or
+                                        W3C_WEBELEMENT_KEY in value):
+            if value.get(WEBELEMENT_KEY):
+                return HTMLElement(self, value.get(WEBELEMENT_KEY))
             else:
-                return HTMLElement(self, value.get(CHROME_ELEMENT_KEY))
+                return HTMLElement(self, value.get(W3C_WEBELEMENT_KEY))
         elif isinstance(value, list):
             return list(self._unwrap_response(item) for item in value)
         else:
             return value
 
     def _handle_error(self, obj):
         error = obj["error"]
         message = obj["message"]
@@ -1647,35 +1647,35 @@ class Marionette(object):
             wrapped = []
             for arg in args:
                 wrapped.append(self._to_json(arg))
         elif isinstance(args, dict):
             wrapped = {}
             for arg in args:
                 wrapped[arg] = self._to_json(args[arg])
         elif type(args) == HTMLElement:
-            wrapped = {WEB_ELEMENT_KEY: args.id,
-                       CHROME_ELEMENT_KEY: args.id}
+            wrapped = {W3C_WEBELEMENT_KEY: args.id,
+                       WEBELEMENT_KEY: args.id}
         elif (isinstance(args, bool) or isinstance(args, basestring) or
               isinstance(args, int) or isinstance(args, float) or args is None):
             wrapped = args
         return wrapped
 
     def _from_json(self, value):
         if isinstance(value, list):
             unwrapped = []
             for item in value:
                 unwrapped.append(self._from_json(item))
         elif isinstance(value, dict):
             unwrapped = {}
             for key in value:
-                if key == WEB_ELEMENT_KEY:
+                if key == W3C_WEBELEMENT_KEY:
                     unwrapped = HTMLElement(self, value[key])
                     break
-                elif key == CHROME_ELEMENT_KEY:
+                elif key == WEBELEMENT_KEY:
                     unwrapped = HTMLElement(self, value[key])
                     break
                 else:
                     unwrapped[key] = self._from_json(value[key])
         else:
             unwrapped = value
         return unwrapped
 
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -1447,16 +1447,17 @@ class WebElement {
    */
   static fromJSON(json) {
     assert.object(json);
     let keys = Object.keys(json);
 
     for (let key of keys) {
       switch (key) {
         case ContentWebElement.Identifier:
+        case ContentWebElement.LegacyIdentifier:
           return ContentWebElement.fromJSON(json);
 
         case ContentWebWindow.Identifier:
           return ContentWebWindow.fromJSON(json);
 
         case ContentWebFrame.Identifier:
           return ContentWebFrame.fromJSON(json);
 
@@ -1505,30 +1506,32 @@ class WebElement {
 
       default:
         throw new InvalidArgumentError("Unknown context: " + context);
     }
   }
 
   /**
    * Checks if <var>ref<var> is a {@link WebElement} reference,
-   * i.e. if it has {@link ContentWebElement.Identifier}, or
+   * i.e. if it has {@link ContentWebElement.Identifier},
+   * {@link ContentWebElement.LegacyIdentifier}, or
    * {@link ChromeWebElement.Identifier} as properties.
    *
    * @param {Object.<string, string>} obj
    *     Object that represents a reference to a {@link WebElement}.
    * @return {boolean}
    *     True if <var>obj</var> is a {@link WebElement}, false otherwise.
    */
   static isReference(obj) {
     if (Object.prototype.toString.call(obj) != "[object Object]") {
       return false;
     }
 
     if ((ContentWebElement.Identifier in obj) ||
+        (ContentWebElement.LegacyIdentifier in obj) ||
         (ContentWebWindow.Identifier in obj) ||
         (ContentWebFrame.Identifier in obj) ||
         (ChromeWebElement.Identifier in obj)) {
       return true;
     }
     return false;
   }
 
@@ -1548,43 +1551,46 @@ this.WebElement = WebElement;
 /**
  * DOM elements are represented as web elements when they are
  * transported over the wire protocol.
  */
 class ContentWebElement extends WebElement {
   toJSON() {
     return {
       [ContentWebElement.Identifier]: this.uuid,
+      [ContentWebElement.LegacyIdentifier]: this.uuid,
     };
   }
 
   static fromJSON(json) {
-    const {Identifier} = ContentWebElement;
+    const {Identifier, LegacyIdentifier} = ContentWebElement;
 
-    if (!(Identifier in json)) {
+    if (!(Identifier in json) && !(LegacyIdentifier in json)) {
       throw new InvalidArgumentError(
           pprint`Expected web element reference, got: ${json}`);
     }
 
-    let uuid = json[Identifier];
+    let uuid = json[Identifier] || json[LegacyIdentifier];
     return new ContentWebElement(uuid);
   }
 }
 ContentWebElement.Identifier = "element-6066-11e4-a52e-4f735466cecf";
+ContentWebElement.LegacyIdentifier = "ELEMENT";
 this.ContentWebElement = ContentWebElement;
 
 /**
  * Top-level browsing contexts, such as <code>WindowProxy</code>
  * whose <code>opener</code> is null, are represented as web windows
  * over the wire protocol.
  */
 class ContentWebWindow extends WebElement {
   toJSON() {
     return {
       [ContentWebWindow.Identifier]: this.uuid,
+      [ContentWebElement.LegacyIdentifier]: this.uuid,
     };
   }
 
   static fromJSON(json) {
     if (!(ContentWebWindow.Identifier in json)) {
       throw new InvalidArgumentError(
           pprint`Expected web window reference, got: ${json}`);
     }
@@ -1599,16 +1605,17 @@ this.ContentWebWindow = ContentWebWindow
  * Nested browsing contexts, such as the <code>WindowProxy</code>
  * associated with <tt>&lt;frame&gt;</tt> and <tt>&lt;iframe&gt;</tt>,
  * are represented as web frames over the wire protocol.
  */
 class ContentWebFrame extends WebElement {
   toJSON() {
     return {
       [ContentWebFrame.Identifier]: this.uuid,
+      [ContentWebElement.LegacyIdentifier]: this.uuid,
     };
   }
 
   static fromJSON(json) {
     if (!(ContentWebFrame.Identifier in json)) {
       throw new InvalidArgumentError(
           pprint`Expected web frame reference, got: ${json}`);
     }
@@ -1622,16 +1629,17 @@ this.ContentWebFrame = ContentWebFrame;
 /**
  * XUL elements in chrome space are represented as chrome web elements
  * over the wire protocol.
  */
 class ChromeWebElement extends WebElement {
   toJSON() {
     return {
       [ChromeWebElement.Identifier]: this.uuid,
+      [ContentWebElement.LegacyIdentifier]: this.uuid,
     };
   }
 
   static fromJSON(json) {
     if (!(ChromeWebElement.Identifier in json)) {
       throw new InvalidArgumentError("Expected chrome element reference " +
           pprint`for XUL/XBL element, got: ${json}`);
     }
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py
@@ -3,17 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import
 
 import urllib
 
 from marionette_driver import By, errors, Wait
 from marionette_driver.keys import Keys
-from marionette_driver.marionette import WEB_ELEMENT_KEY
+from marionette_driver.marionette import W3C_WEBELEMENT_KEY
 
 from marionette_harness import MarionetteTestCase
 
 
 def inline(doc):
     return "data:text/html;charset=utf-8,{}".format(urllib.quote(doc))
 
 
@@ -36,17 +36,17 @@ class Actions(object):
         }]}
 
         return self.marionette._send_message("performActions", params=params)
 
     def move(self, element, x=0, y=0, duration=250):
         self.action_chain.append({
             "duration": duration,
             "origin": {
-                WEB_ELEMENT_KEY: element.id
+                W3C_WEBELEMENT_KEY: element.id
             },
             "type": "pointerMove",
             "x": x,
             "y": y,
         })
 
         return self
 
--- a/testing/marionette/test_element.js
+++ b/testing/marionette/test_element.js
@@ -353,25 +353,47 @@ add_test(function test_WebElement_from()
   ok(WebElement.from(xulEl) instanceof ChromeWebElement);
 
   Assert.throws(() => WebElement.from({}), InvalidArgumentError);
 
   run_next_test();
 });
 
 add_test(function test_WebElement_fromJSON_ContentWebElement() {
-  const {Identifier} = ContentWebElement;
+  const {Identifier, LegacyIdentifier} = ContentWebElement;
+
+  let refNew = {[Identifier]: "foo"};
+  let webElNew = WebElement.fromJSON(refNew);
+  ok(webElNew instanceof ContentWebElement);
+  equal(webElNew.uuid, "foo");
+
+  let refOld = {[LegacyIdentifier]: "foo"};
+  let webElOld = WebElement.fromJSON(refOld);
+  ok(webElOld instanceof ContentWebElement);
+  equal(webElOld.uuid, "foo");
 
-  let ref = {[Identifier]: "foo"};
-  let webEl = WebElement.fromJSON(ref);
-  ok(webEl instanceof ContentWebElement);
-  equal(webEl.uuid, "foo");
+  ok(webElNew.is(webElOld));
+  ok(webElOld.is(webElNew));
+
+  let refBoth = {
+    [Identifier]: "foo",
+    [LegacyIdentifier]: "foo",
+  };
+  let webElBoth = WebElement.fromJSON(refBoth);
+  ok(webElBoth instanceof ContentWebElement);
+  equal(webElBoth.uuid, "foo");
+
+  ok(webElBoth.is(webElNew));
+  ok(webElBoth.is(webElOld));
+  ok(webElNew.is(webElBoth));
+  ok(webElOld.is(webElBoth));
 
   let identifierPrecedence = {
     [Identifier]: "identifier-uuid",
+    [LegacyIdentifier]: "legacyidentifier-uuid",
   };
   let precedenceEl = WebElement.fromJSON(identifierPrecedence);
   ok(precedenceEl instanceof ContentWebElement);
   equal(precedenceEl.uuid, "identifier-uuid");
 
   run_next_test();
 });
 
@@ -423,46 +445,61 @@ add_test(function test_WebElement_fromUU
 });
 
 add_test(function test_WebElement_isReference() {
   for (let t of [42, true, "foo", [], {}]) {
     ok(!WebElement.isReference(t));
   }
 
   ok(WebElement.isReference({[ContentWebElement.Identifier]: "foo"}));
+  ok(WebElement.isReference({[ContentWebElement.LegacyIdentifier]: "foo"}));
   ok(WebElement.isReference({[ContentWebWindow.Identifier]: "foo"}));
   ok(WebElement.isReference({[ContentWebFrame.Identifier]: "foo"}));
   ok(WebElement.isReference({[ChromeWebElement.Identifier]: "foo"}));
 
   run_next_test();
 });
 
 add_test(function test_WebElement_generateUUID() {
   equal(typeof WebElement.generateUUID(), "string");
   run_next_test();
 });
 
 add_test(function test_ContentWebElement_toJSON() {
-  const {Identifier} = ContentWebElement;
+  const {Identifier, LegacyIdentifier} = ContentWebElement;
 
   let el = new ContentWebElement("foo");
   let json = el.toJSON();
 
   ok(Identifier in json);
+  ok(LegacyIdentifier in json);
   equal(json[Identifier], "foo");
+  equal(json[LegacyIdentifier], "foo");
 
   run_next_test();
 });
 
 add_test(function test_ContentWebElement_fromJSON() {
-  const {Identifier} = ContentWebElement;
+  const {Identifier, LegacyIdentifier} = ContentWebElement;
+
+  let newEl = ContentWebElement.fromJSON({[Identifier]: "foo"});
+  ok(newEl instanceof ContentWebElement);
+  equal(newEl.uuid, "foo");
 
-  let el = ContentWebElement.fromJSON({[Identifier]: "foo"});
-  ok(el instanceof ContentWebElement);
-  equal(el.uuid, "foo");
+  let oldEl = ContentWebElement.fromJSON({[LegacyIdentifier]: "foo"});
+  ok(oldEl instanceof ContentWebElement);
+  equal(oldEl.uuid, "foo");
+
+  let bothRef = {
+    [Identifier]: "identifier-uuid",
+    [LegacyIdentifier]: "legacyidentifier-foo",
+  };
+  let bothEl = ContentWebElement.fromJSON(bothRef);
+  ok(bothEl instanceof ContentWebElement);
+  equal(bothEl.uuid, "identifier-uuid");
 
   Assert.throws(() => ContentWebElement.fromJSON({}), InvalidArgumentError);
 
   run_next_test();
 });
 
 add_test(function test_ContentWebWindow_toJSON() {
   let win = new ContentWebWindow("foo");