diff --git a/gfx/layers/apz/test/mochitest/browser.ini b/gfx/layers/apz/test/mochitest/browser.ini index 2d9eb14706e9..1c80853d7e64 100644 --- a/gfx/layers/apz/test/mochitest/browser.ini +++ b/gfx/layers/apz/test/mochitest/browser.ini @@ -28,3 +28,7 @@ support-files = apz_test_native_event_utils.js apz_test_utils.js helper_test_reset_scaling_zoom.html +[browser_test_scrollbar_in_extension_popup_window.js] +support-files = + !/browser/components/extensions/test/browser/head.js + !/browser/components/extensions/test/browser/head_browserAction.js diff --git a/gfx/layers/apz/test/mochitest/browser_test_scrollbar_in_extension_popup_window.js b/gfx/layers/apz/test/mochitest/browser_test_scrollbar_in_extension_popup_window.js new file mode 100644 index 000000000000..729174babca9 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/browser_test_scrollbar_in_extension_popup_window.js @@ -0,0 +1,116 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +Services.scriptloader.loadSubScript( + "chrome://mochitests/content/browser/browser/components/extensions/test/browser/head.js", + this +); +Services.scriptloader.loadSubScript( + "chrome://mochitests/content/browser/browser/components/extensions/test/browser/head_browserAction.js", + this +); + +add_task(async () => { + let extension = ExtensionTestUtils.loadExtension({ + manifest: { + browser_action: { + default_popup: "popup.html", + browser_style: true, + }, + }, + + files: { + "popup.html": ` + + + + + + + + + `, + }, + }); + + await extension.startup(); + + registerCleanupFunction(() => { + SpecialPowers.clearUserPref("apz.popups.enabled"); + }); + + async function takeSnapshot(browserWin) { + let browser = await openBrowserActionPanel(extension, browserWin, true); + const snapshot = await SpecialPowers.spawn(browser, [], async () => { + await SpecialPowers.snapshotWindow( + content.window, + false /* withCaret */, + undefined /* use the default rect */, + undefined /* use the default bgcolor */, + { DRAWWINDOW_DRAW_VIEW: true } /* to capture scrollbars */ + ) + .toDataURL() + .toString(); + }); + + const popup = getBrowserActionPopup(extension, browserWin); + await closeBrowserAction(extension, browserWin); + is(popup.state, "closed", "browserAction popup has been closed"); + + return snapshot; + } + + // First, take a snapshot with disabling APZ in the popup window, we assume + // scrollbars are rendered properly there. + await SpecialPowers.setBoolPref("apz.popups.enabled", false); + const newWin = await BrowserTestUtils.openNewBrowserWindow(); + const reference = await takeSnapshot(newWin); + await BrowserTestUtils.closeWindow(newWin); + + // Then take a snapshot with enabling APZ. + await SpecialPowers.setBoolPref("apz.popups.enabled", true); + const anotherWin = await BrowserTestUtils.openNewBrowserWindow(); + const test = await takeSnapshot(anotherWin); + await BrowserTestUtils.closeWindow(anotherWin); + + is( + test, + reference, + "Contents in popup window opened by extension should be same regardless of the APZ state in the window" + ); + + await extension.unload(); +}); diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 7b774dc4bbf9..21402dfa12d7 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -6247,27 +6247,31 @@ class MOZ_RAII AutoMinimumScaleSizeChangeDetector final { }; nsSize ScrollFrameHelper::TrueOuterSize(nsDisplayListBuilder* aBuilder) const { - if (RefPtr manager = - mOuter->PresShell()->GetMobileViewportManager()) { - LayoutDeviceIntSize displaySize = manager->DisplaySize(); - - MOZ_ASSERT(aBuilder); - // In case of WebRender, we expand the outer size to include the dynamic - // toolbar area here. - // In case of non WebRender, we expand the size dynamically in - // MoveScrollbarForLayerMargin in AsyncCompositionManager.cpp. - LayerManager* layerManager = aBuilder->GetWidgetLayerManager(); - if (layerManager && - layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) { - displaySize.height += ViewAs( - mOuter->PresContext()->GetDynamicToolbarMaxHeight(), - PixelCastJustification::LayoutDeviceIsScreenForBounds); - } - - return LayoutDeviceSize::ToAppUnits( - displaySize, mOuter->PresContext()->AppUnitsPerDevPixel()); + if (!mOuter->PresShell()->UsesMobileViewportSizing()) { + return mOuter->GetSize(); } - return mOuter->GetSize(); + + RefPtr manager = + mOuter->PresShell()->GetMobileViewportManager(); + MOZ_ASSERT(manager); + + LayoutDeviceIntSize displaySize = manager->DisplaySize(); + + MOZ_ASSERT(aBuilder); + // In case of WebRender, we expand the outer size to include the dynamic + // toolbar area here. + // In case of non WebRender, we expand the size dynamically in + // MoveScrollbarForLayerMargin in AsyncCompositionManager.cpp. + LayerManager* layerManager = aBuilder->GetWidgetLayerManager(); + if (layerManager && + layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) { + displaySize.height += ViewAs( + mOuter->PresContext()->GetDynamicToolbarMaxHeight(), + PixelCastJustification::LayoutDeviceIsScreenForBounds); + } + + return LayoutDeviceSize::ToAppUnits( + displaySize, mOuter->PresContext()->AppUnitsPerDevPixel()); } void ScrollFrameHelper::UpdateMinimumScaleSize(