Bug 1353910 - Fix browser_webrtc_hooks.js. r=florian
MozReview-Commit-ID: KPCTaQzoQfK
--- a/browser/base/content/test/webrtc/browser_webrtc_hooks.js
+++ b/browser/base/content/test/webrtc/browser_webrtc_hooks.js
@@ -1,20 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Cu.import("resource:///modules/webrtcUI.jsm");
const ORIGIN = "https://example.com";
-registerCleanupFunction(function() {
- gBrowser.removeCurrentTab();
-});
-
function* tryPeerConnection(browser, expectedError = null) {
let errtype = yield ContentTask.spawn(browser, null, function*() {
let pc = new content.RTCPeerConnection();
try {
yield pc.createOffer({offerToReceiveAudio: true});
return null;
} catch (err) {
return err.name;
@@ -321,41 +317,18 @@ var gTests = [
isnot(details.callID, undefined, "peer-request-cancel event includes callID");
is(details.origin, ORIGIN, "peer-request-cancel event has correct origin");
webrtcUI.removePeerConnectionBlocker(blocker);
},
},
];
-function test() {
- waitForExplicitFinish();
-
- let tab = gBrowser.addTab();
- gBrowser.selectedTab = tab;
- let browser = tab.linkedBrowser;
-
- browser.addEventListener("load", function() {
- 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");
-
- Task.spawn(function* () {
- yield SpecialPowers.pushPrefEnv({"set": [[PREF_PERMISSION_FAKE, true]]});
-
- for (let testCase of gTests) {
- info(testCase.desc);
- yield testCase.run(browser);
-
- // Make sure the test cleaned up after itself.
- is(webrtcUI.peerConnectionBlockers.size, 0, "Peer connection blockers list is empty");
- }
- }).then(finish, ex => {
- Cu.reportError(ex);
- ok(false, "Unexpected Exception: " + ex);
- finish();
- });
- }, {capture: true, once: true});
+add_task(async function test() {
let rootDir = getRootDirectory(gTestPath);
- rootDir = rootDir.replace("chrome://mochitests/content", ORIGIN);
- content.location = rootDir + "get_user_media.html";
-}
+ rootDir = rootDir.replace("chrome://mochitests/content",
+ ORIGIN);
+ await runTests(gTests, rootDir + "get_user_media.html",
+ () => {
+ is(webrtcUI.peerConnectionBlockers.size, 0,
+ "Peer connection blockers list is empty");
+ });
+});
--- a/browser/base/content/test/webrtc/head.js
+++ b/browser/base/content/test/webrtc/head.js
@@ -533,15 +533,15 @@ async function runTests(tests, page, tes
"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]]});
for (let testCase of tests) {
info(testCase.desc);
- yield testCase.run();
+ yield testCase.run(browser);
if (testCleanup) {
yield testCleanup();
}
}
});
}