Bug 1353910 - Stop using withNewTab to avoid warnings in a couple of tests.
MozReview-Commit-ID: AelEqNZvzRQ
--- 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);
}