Bug 1387678 - Allow traversing to the parent if switchToShadowDom is given null; r?ato draft
authorDavid Burns <dburns@mozilla.com>
Sat, 28 Apr 2018 00:12:35 +0100
changeset 801162 ec53ec1bbd6bdc6fd434be9791a6f118403c6234
parent 800874 f01bb6245db1ea2a87e5360104a4110571265137
child 801163 5b9e4b3adc7d407c6db78bae85e5f42a15681b33
push id111602
push userbmo:dburns@mozilla.com
push dateTue, 29 May 2018 22:11:56 +0000
reviewersato
bugs1387678
milestone62.0a1
Bug 1387678 - Allow traversing to the parent if switchToShadowDom is given null; r?ato MozReview-Commit-ID: KO1UwTyhf1R
testing/marionette/driver.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2571,30 +2571,34 @@ GeckoDriver.prototype.clearElement = asy
       await this.listener.clearElement(webEl);
       break;
   }
 };
 
 /**
  * Switch to shadow root of the given host element.
  *
- * @param {string} id
+ * @param {string=} id
  *     Reference ID to the element.
  *
  * @throws {InvalidArgumentError}
  *     If <var>id</var> is not a string.
  * @throws {NoSuchElementError}
  *     If element represented by reference <var>id</var> is unknown.
  */
 GeckoDriver.prototype.switchToShadowRoot = async function(cmd) {
   assert.content(this.context);
   assert.open(this.getCurrentWindow());
 
-  let id = assert.string(cmd.parameters.id);
-  let webEl = WebElement.fromUUID(id, this.context);
+  let id = cmd.parameters.id;
+  let webEl = null;
+  if (id != null) {
+    assert.string(id);
+    webEl = WebElement.fromUUID(id, this.context);
+  }
   await this.listener.switchToShadowRoot(webEl);
 };
 
 /**
  * Add a single cookie to the cookie store associated with the active
  * document's address.
  *
  * @param {Map.<string, (string|number|boolean)> cookie