browser_device_controls_menus.js (1464B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const TEST_ROOT = getRootDirectory(gTestPath).replace( 7 "chrome://mochitests/content/", 8 "https://example.com/" 9 ); 10 const TEST_PAGE = TEST_ROOT + "get_user_media.html"; 11 12 /** 13 * Regression test for bug 1669801, where sharing a window would 14 * result in a device control menu that showed the wrong count. 15 */ 16 add_task(async function test_bug_1669801() { 17 let prefs = [ 18 [PREF_PERMISSION_FAKE, true], 19 [PREF_AUDIO_LOOPBACK, ""], 20 [PREF_VIDEO_LOOPBACK, ""], 21 [PREF_FAKE_STREAMS, true], 22 [PREF_FOCUS_SOURCE, false], 23 ]; 24 await SpecialPowers.pushPrefEnv({ set: prefs }); 25 26 await BrowserTestUtils.withNewTab(TEST_PAGE, async browser => { 27 let indicatorPromise = promiseIndicatorWindow(); 28 29 await shareDevices( 30 browser, 31 false /* camera */, 32 false /* microphone */, 33 SHARE_WINDOW 34 ); 35 36 let indicator = await indicatorPromise; 37 let doc = indicator.document; 38 39 let menupopup = doc.querySelector("menupopup[type='Screen']"); 40 let popupShownPromise = BrowserTestUtils.waitForEvent( 41 menupopup, 42 "popupshown" 43 ); 44 menupopup.openPopup(doc.body, {}); 45 await popupShownPromise; 46 47 let popupHiddenPromise = BrowserTestUtils.waitForEvent( 48 menupopup, 49 "popuphidden" 50 ); 51 menupopup.hidePopup(); 52 await popupHiddenPromise; 53 await closeStream(); 54 }); 55 });