browser_panel_vsync.js (2052B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 Services.scriptloader.loadSubScript( 7 "chrome://mochitests/content/browser/browser/components/downloads/test/browser/head.js", 8 this 9 ); 10 11 add_task( 12 async function test_opening_panel_and_closing_should_not_leave_vsync() { 13 await SpecialPowers.pushPrefEnv({ 14 set: [["browser.download.autohideButton", false]], 15 }); 16 await promiseButtonShown("downloads-button"); 17 18 const downloadsButton = document.getElementById("downloads-button"); 19 const shownPromise = promisePanelOpened(); 20 EventUtils.synthesizeNativeMouseEvent({ 21 type: "click", 22 target: downloadsButton, 23 atCenter: true, 24 }); 25 await shownPromise; 26 27 is(DownloadsPanel.panel.state, "open", "Check that panel state is 'open'"); 28 29 await TestUtils.waitForCondition( 30 () => !ChromeUtils.vsyncEnabled(), 31 "Make sure vsync disabled" 32 ); 33 // Should not already be using vsync 34 ok(!ChromeUtils.vsyncEnabled(), "vsync should be off initially"); 35 36 if ( 37 AppConstants.platform == "linux" && 38 DownloadsPanel.panel.state != "open" 39 ) { 40 // Panels sometime receive spurious popuphiding events on Linux. 41 // Given the main target of this test is Windows, avoid causing 42 // intermittent failures and just make the test return early. 43 todo( 44 false, 45 "panel should still be 'open', current state: " + 46 DownloadsPanel.panel.state 47 ); 48 return; 49 } 50 51 const hiddenPromise = BrowserTestUtils.waitForEvent( 52 DownloadsPanel.panel, 53 "popuphidden" 54 ); 55 EventUtils.synthesizeKey("VK_ESCAPE", {}, window); 56 await hiddenPromise; 57 await TestUtils.waitForCondition( 58 () => !ChromeUtils.vsyncEnabled(), 59 "wait for vsync to be disabled again" 60 ); 61 62 ok(!ChromeUtils.vsyncEnabled(), "vsync should still be off"); 63 is( 64 DownloadsPanel.panel.state, 65 "closed", 66 "Check that panel state is 'closed'" 67 ); 68 } 69 );