Bug 1376128 - Throw RangeError if Window is not found; r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Wed, 28 Jun 2017 11:12:33 -0700
changeset 602391 29eed66deb1bb0fb503fd137ac23d551e025b891
parent 602390 c5d58911e82dd3ab8c959e241a0df2f70b5f98e8
child 602392 8414bf9518cfb97300419f7b5d0d29fa43bdda4d
push id66419
push userbmo:ato@sny.no
push dateThu, 29 Jun 2017 23:42:10 +0000
reviewersautomatedtester
bugs1376128
milestone56.0a1
Bug 1376128 - Throw RangeError if Window is not found; r?automatedtester To ensure a consistent return type from browser.Context#get, this patch introduces a RangeError to be thrown if the weak reference to the window is empty. MozReview-Commit-ID: 2aNOG9Uht3I
testing/marionette/browser.js
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -266,17 +266,18 @@ browser.Context = class {
    * @param {string} uri
    *      URI to open.
    */
   addTab(uri) {
     return this.tabBrowser.addTab(uri, true);
   }
 
   /**
-   * Set the current tab and update remoteness tracking if a tabbrowser is available.
+   * Set the current tab and update remoteness tracking if a tabbrowser
+   * is available.
    *
    * @param {number=} index
    *     Tab index to switch to. If the parameter is undefined,
    *     the currently selected tab will be used.
    * @param {nsIDOMWindow=} win
    *     Switch to this window before selecting the tab.
    * @param {boolean=} focus
    *      A boolean value which determins whether to focus
@@ -444,19 +445,22 @@ browser.Windows = class extends Map {
 
   /**
    * Get the window object stored by provided |id|.
    *
    * @param {string} id
    *     Outer window ID.
    *
    * @return {Window}
-   *     Saved window object, or |undefined| if no window is stored by
-   *     provided |id|.
+   *     Saved window object.
+   *
+   * @throws {RangeError}
+   *     If |id| is not in the store.
    */
   get(id) {
     let wref = super.get(id);
-    if (wref) {
-      return wref.get();
+    if (!wref) {
+      throw new RangeError();
     }
+    return wref.get();
   }
 
 };