Bug 1353910 - Stop using withNewTab to avoid warnings in a couple of tests. draft
authorBlake Kaplan <mrbkap@gmail.com>
Fri, 07 Apr 2017 13:08:48 -0400
changeset 558419 f292b8eee8ce4d6bc44709fae054daaa58fb818d
parent 558418 6f9b197f68af3b7f7ade953299f46dd3ece3073d
child 558420 9b2a3ceb808f3cee80d94f194400047b1ab90fed
push id52889
push userbmo:mrbkap@mozilla.com
push dateFri, 07 Apr 2017 17:30:02 +0000
bugs1353910
milestone55.0a1
Bug 1353910 - Stop using withNewTab to avoid warnings in a couple of tests. MozReview-Commit-ID: AelEqNZvzRQ
browser/base/content/test/webrtc/browser_devices_get_user_media_tear_off_tab.js
browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_tear_off_tab.js
browser/base/content/test/webrtc/head.js
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_tear_off_tab.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_tear_off_tab.js
@@ -60,14 +60,10 @@ var gTests = [
 
 add_task(async function test() {
   await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 1]]});
 
   // An empty tab where we can load the content script without leaving it
   // behind at the end of the test.
   let tab = gBrowser.addTab();
 
-  // NB: This causes withNewTab to warn that we already closed the tab. That
-  // doesn't cause the test to fail, so that's OK.
   await runTests(gTests);
-
-  await BrowserTestUtils.removeTab(tab);
 });
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_tear_off_tab.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_tear_off_tab.js
@@ -54,14 +54,10 @@ var gTests = [
 
 add_task(async function test() {
   await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 1]]});
 
   // An empty tab where we can load the content script without leaving it
   // behind at the end of the test.
   let tab = gBrowser.addTab();
 
-  // NB: This causes withNewTab to warn that we already closed the tab. That
-  // doesn't cause the test to fail, so that's OK.
   await runTests(gTests);
-
-  await BrowserTestUtils.removeTab(tab);
 });
--- a/browser/base/content/test/webrtc/head.js
+++ b/browser/base/content/test/webrtc/head.js
@@ -530,26 +530,29 @@ async function runTests(tests, options =
 
     let rootDir = getRootDirectory(gTestPath);
     rootDir = rootDir.replace("chrome://mochitests/content/",
                               "https://example.com/");
     absoluteURI = rootDir + leaf;
   }
   cleanup = options.cleanup || (() => expectNoObserverCalled());
 
-  await BrowserTestUtils.withNewTab({ gBrowser, url: absoluteURI },
-    function* (browser) {
-      browser.messageManager.loadFrameScript(CONTENT_SCRIPT_HELPER, true);
+  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, absoluteURI);
+  let browser = tab.linkedBrowser;
+
+  browser.messageManager.loadFrameScript(CONTENT_SCRIPT_HELPER, true);
 
-      is(PopupNotifications._currentNotifications.length, 0,
-         "should start the test without any prior popup notification");
-      ok(gIdentityHandler._identityPopup.hidden,
-         "should start the test with the control center hidden");
+  is(PopupNotifications._currentNotifications.length, 0,
+     "should start the test without any prior popup notification");
+  ok(gIdentityHandler._identityPopup.hidden,
+     "should start the test with the control center hidden");
 
-      yield SpecialPowers.pushPrefEnv({"set": [[PREF_PERMISSION_FAKE, true]]});
+  await SpecialPowers.pushPrefEnv({"set": [[PREF_PERMISSION_FAKE, true]]});
 
-      for (let testCase of tests) {
-        info(testCase.desc);
-        yield testCase.run(browser);
-        yield cleanup();
-      }
-    });
+  for (let testCase of tests) {
+    info(testCase.desc);
+    await Task.spawn(testCase.run(browser));
+    await cleanup();
+  }
+
+  // Some tests destroy the original tab and leave a new one in its place.
+  await BrowserTestUtils.removeTab(gBrowser.selectedTab);
 }