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
--- 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();
}
};