From 826380207b7a8a9e1bcc3554fbe7c539995d082d Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Thu, 2 May 2024 14:17:13 +0000 Subject: [PATCH] Bug 1893644 - [devtools] Display ::backdrop rules for popover elements. r=devtools-reviewers,bomsy. Differential Revision: https://phabricator.services.mozilla.com/D208746 --- .../test/browser_rules_pseudo-element_01.js | 78 ++++++++++++++++++- .../rules/test/doc_pseudoelement.html | 14 +++- devtools/server/actors/page-style.js | 2 +- 3 files changed, 89 insertions(+), 5 deletions(-) diff --git a/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js b/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js index a569aa7f4d6d..7973a0c27176 100644 --- a/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js @@ -13,6 +13,8 @@ add_task(async function () { await pushPref("dom.customHighlightAPI.enabled", true); await pushPref("dom.text_fragments.enabled", true); await pushPref("layout.css.modern-range-pseudos.enabled", true); + await pushPref("full-screen-api.transition-duration.enter", "0 0"); + await pushPref("full-screen-api.transition-duration.leave", "0 0"); await addTab(TEST_URI); const { inspector, view } = await openRuleView(); @@ -24,7 +26,7 @@ add_task(async function () { await testParagraph(inspector, view); await testBody(inspector, view); await testList(inspector, view); - await testDialogBackdrop(inspector, view); + await testBackdrop(inspector, view); await testCustomHighlight(inspector, view); await testSlider(inspector, view); await testUrlFragmentTextDirective(inspector, view); @@ -290,13 +292,85 @@ async function testList(inspector, view) { assertGutters(view); } -async function testDialogBackdrop(inspector, view) { +async function testBackdrop(inspector, view) { + info("Test ::backdrop for dialog element"); await assertPseudoElementRulesNumbers("dialog", inspector, view, { elementRulesNb: 3, backdropRules: 1, }); + info("Test ::backdrop for popover element"); + await assertPseudoElementRulesNumbers( + "#in-dialog[popover]", + inspector, + view, + { + elementRulesNb: 3, + backdropRules: 1, + } + ); + assertGutters(view); + + info("Test ::backdrop rules are displayed when elements is fullscreen"); + + // Wait for the document being activated, so that + // fullscreen request won't be denied. + const onTabFocused = SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => { + return ContentTaskUtils.waitForCondition( + () => content.browsingContext.isActive && content.document.hasFocus(), + "document is active" + ); + }); + gBrowser.selectedBrowser.focus(); + await onTabFocused; + + const onFullscreen = new Promise(resolve => { + BrowserTestUtils.addContentEventListener( + gBrowser.selectedBrowser, + "fullscreenchange", + resolve, + { once: true } + ); + }); + + info("Request fullscreen"); + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => { + const canvas = content.document.querySelector("canvas"); + canvas.requestFullscreen(); + }); + + await onFullscreen; + ok(true, "canvas is fullscreen"); + + await assertPseudoElementRulesNumbers("canvas", inspector, view, { + elementRulesNb: 3, + backdropRules: 1, + }); + + assertGutters(view); + + info("Exit fullscreen"); + const onFullscreenExit = new Promise(resolve => { + BrowserTestUtils.addContentEventListener( + gBrowser.selectedBrowser, + "fullscreenchange", + resolve, + { once: true } + ); + }); + SpecialPowers.spawn(gBrowser.selectedBrowser, [], async () => { + content.document.exitFullscreen(); + }); + await onFullscreenExit; + + info( + "Test ::backdrop rules are not displayed when elements are not fullscreen" + ); + await assertPseudoElementRulesNumbers("canvas", inspector, view, { + elementRulesNb: 3, + backdropRules: 0, + }); } async function testCustomHighlight(inspector, view) { diff --git a/devtools/client/inspector/rules/test/doc_pseudoelement.html b/devtools/client/inspector/rules/test/doc_pseudoelement.html index c28195cc9230..88611d6633d6 100644 --- a/devtools/client/inspector/rules/test/doc_pseudoelement.html +++ b/devtools/client/inspector/rules/test/doc_pseudoelement.html @@ -110,7 +110,11 @@ p:first-letter { color: purple; } -dialog::backdrop { +:is( + dialog, + [popover], + :fullscreen, +)::backdrop { background-color: transparent; } @@ -171,7 +175,10 @@ input::slider-track {
  • List element
  • - In dialog + + In dialog +
    hello
    +
    @@ -183,10 +190,13 @@ input::slider-track {
    May the fox be with you
    + +