Bug 1255520: BrowserTestUtils.withNewTab should just accept a url argument. r?Gijs
Most of the time the test just wants to open a page in the current window. In
that case there is no need to pass an object with the gBrowser, we can just find
it directly. This makes using this function less verbose in most cases.
MozReview-Commit-ID: eUyyOi5HgC
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
+++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
@@ -57,16 +57,22 @@ this.BrowserTestUtils = {
* the tab is loaded. The first argument passed to the function is a
* reference to the browser object for the new tab.
*
* @return {} Returns the value that is returned from taskFn.
* @resolves When the tab has been closed.
* @rejects Any exception from taskFn is propagated.
*/
withNewTab: Task.async(function* (options, taskFn) {
+ if (typeof(options) == "string") {
+ options = {
+ gBrowser: Services.wm.getMostRecentWindow("navigator:browser").gBrowser,
+ url: options
+ }
+ }
let tab = yield BrowserTestUtils.openNewForegroundTab(options.gBrowser, options.url);
let result = yield taskFn(tab.linkedBrowser);
options.gBrowser.removeTab(tab);
return Promise.resolve(result);
}),
/**
* Opens a new tab in the foreground.