browser_indicator_popuphiding.js (1430B)
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 1668838 - make sure that a popuphiding 14 * event that fires for any popup not related to the device control 15 * menus is ignored and doesn't cause the targets contents to be all 16 * removed. 17 */ 18 add_task(async function test_popuphiding() { 19 let prefs = [ 20 [PREF_PERMISSION_FAKE, true], 21 [PREF_AUDIO_LOOPBACK, ""], 22 [PREF_VIDEO_LOOPBACK, ""], 23 [PREF_FAKE_STREAMS, true], 24 [PREF_FOCUS_SOURCE, false], 25 ]; 26 await SpecialPowers.pushPrefEnv({ set: prefs }); 27 28 await BrowserTestUtils.withNewTab(TEST_PAGE, async browser => { 29 let indicatorPromise = promiseIndicatorWindow(); 30 31 await shareDevices( 32 browser, 33 true /* camera */, 34 true /* microphone */, 35 SHARE_SCREEN 36 ); 37 38 let indicator = await indicatorPromise; 39 let doc = indicator.document; 40 41 Assert.ok(doc.body, "Should have a document body in the indicator."); 42 43 let event = new indicator.MouseEvent("popuphiding", { bubbles: true }); 44 doc.documentElement.dispatchEvent(event); 45 46 Assert.ok(doc.body, "Should still have a document body in the indicator."); 47 }); 48 49 await checkNotSharing(); 50 });