Bug 1742797 - Discard WebRender resources when popup hides. r=Gijs,emilio

The browser test in this change was originally written by Gijs.

Differential Revision: https://phabricator.services.mozilla.com/D134444
This commit is contained in:
Hiroyuki Ikezoe 2022-07-18 18:01:51 +00:00
Родитель 4cc772b589
Коммит 2468744569
3 изменённых файлов: 66 добавлений и 0 удалений

Просмотреть файл

@ -30,6 +30,9 @@ skip-if =
debug
(os == 'win') # Win32 because of intermittent OOM failures, bug 1533141 for aarch64, Bug 1775626
(os == 'linux' && socketprocess_networking) # Bug 1382809, bug 1369959
[browser_panel_vsync.js]
support-files =
!/browser/components/downloads/test/browser/head.js
[browser_preferences_usage.js]
https_first_disabled = true
skip-if =

Просмотреть файл

@ -0,0 +1,59 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from ../../../../components/downloads/test/browser/head.js */
"use strict";
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/browser/components/downloads/test/browser/head.js",
this
);
add_task(
async function test_opening_panel_and_closing_should_not_leave_vsync() {
await SpecialPowers.pushPrefEnv({
set: [["browser.download.autohideButton", false]],
});
await promiseButtonShown("downloads-button");
const downloadsButton = document.getElementById("downloads-button");
const shownPromise = promisePanelOpened();
EventUtils.synthesizeNativeMouseEvent({
type: "click",
target: downloadsButton,
atCenter: true,
});
await shownPromise;
is(DownloadsPanel.panel.state, "open", "Check that panel state is 'open'");
await TestUtils.waitForCondition(
() => !ChromeUtils.vsyncEnabled(),
"Make sure vsync disabled"
);
// Should not already be using vsync
ok(!ChromeUtils.vsyncEnabled(), "vsync should be off initially");
const hiddenPromise = BrowserTestUtils.waitForEvent(
DownloadsPanel.panel,
"popuphidden"
);
EventUtils.synthesizeNativeMouseEvent({
type: "click",
target: downloadsButton,
atCenter: true,
});
await Promise.all([
hiddenPromise,
TestUtils.waitForCondition(() => !ChromeUtils.vsyncEnabled()),
]);
ok(!ChromeUtils.vsyncEnabled(), "vsync should still be off");
is(
DownloadsPanel.panel.state,
"closed",
"Check that panel state is 'closed'"
);
}
);

Просмотреть файл

@ -1098,6 +1098,10 @@ void nsMenuPopupFrame::HidePopup(bool aDeselectMenu, nsPopupState aNewState) {
mCurrentMenu = nullptr; // make sure no current menu is set
mHFlip = mVFlip = false;
if (auto* widget = GetWidget()) {
widget->ClearCachedWebrenderResources();
}
nsView* view = GetView();
nsViewManager* viewManager = view->GetViewManager();
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);