Bug 1353910 - Fix browser_devices_get_user_media_unprompted_access_in_frame.js. r=florian
MozReview-Commit-ID: 7KLUKd4EaZ6
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_in_frame.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_in_frame.js
@@ -1,16 +1,12 @@
/* 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/. */
-registerCleanupFunction(function() {
- gBrowser.removeCurrentTab();
-});
-
const permissionError = "error: NotAllowedError: The request is not allowed " +
"by the user agent or the platform in the current context.";
var gTests = [
{
desc: "getUserMedia audio+camera in frame 1",
run: function* checkAudioVideoWhileLiveTracksExist_frame() {
@@ -205,42 +201,14 @@ var gTests = [
SitePermissions.remove(null, "screen", gBrowser.selectedBrowser);
SitePermissions.remove(null, "camera", gBrowser.selectedBrowser);
SitePermissions.remove(null, "microphone", gBrowser.selectedBrowser);
}
}
];
-function test() {
- waitForExplicitFinish();
-
- let tab = gBrowser.addTab();
- gBrowser.selectedTab = tab;
- let browser = tab.linkedBrowser;
-
- browser.messageManager.loadFrameScript(CONTENT_SCRIPT_HELPER, true);
-
- browser.addEventListener("load", function() {
- is(PopupNotifications._currentNotifications.length, 0,
- "should start the test without any prior popup notification");
-
- Task.spawn(function* () {
- yield SpecialPowers.pushPrefEnv({"set": [[PREF_PERMISSION_FAKE, true]]});
-
- for (let testCase of gTests) {
- info(testCase.desc);
- yield testCase.run();
-
- // Cleanup before the next test
- yield expectNoObserverCalled();
- }
- }).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/",
"https://example.com/");
- content.location = rootDir + "get_user_media_in_frame.html";
-}
+ await runTests(gTests, rootDir + "get_user_media_in_frame.html", () => expectNoObserverCalled());
+});