Repository navigation
gh-15785: Fix right-sidebar gradient shifts in compact mode #15961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mr-cheffy
merged 4 commits into
zen-browser:dev
from
yosofbadr:fix/compact-gradient-right
Oct 15, 2026
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d775869
gh-15785: Keep right sidebar gradients aligned during reveal
yosofbadr 0a7731c
gh-15785: Remove redundant test introduction
yosofbadr bebb53b
gh-15785: Simplify gradient fix after review
yosofbadr 750bdc5
gh-15785: Remove unnecessary background-position priority
yosofbadr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
src/zen/tests/compact_mode/browser_compact_mode_gradient.js
|
yosofbadr marked this conversation as resolved.
Resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| /* Any copyright is dedicated to the Public Domain. | ||
| https://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
|
||
| "use strict"; | ||
|
|
||
| add_task(async function test_compact_sidebar_gradient_during_reveal() { | ||
| await SpecialPowers.pushPrefEnv({ | ||
| set: [ | ||
| ["zen.view.use-single-toolbar", true], | ||
| ["zen.view.sidebar-expanded", true], | ||
| ["zen.view.compact.hide-tabbar", true], | ||
| ["zen.view.compact.animate-sidebar", false], | ||
| ["zen.view.compact.enable-at-startup", false], | ||
| ["zen.theme.acrylic-sidebar", false], | ||
| ["zen.window-sync.enabled", false], | ||
| ], | ||
| }); | ||
|
|
||
| for (const rightSide of [false, true]) { | ||
| await SpecialPowers.pushPrefEnv({ | ||
| set: [["zen.tabs.vertical.right-side", rightSide]], | ||
| }); | ||
| const win = await BrowserTestUtils.openNewBrowserWindow(); | ||
| try { | ||
| await win.gZenWorkspaces.promiseInitialized; | ||
| await BrowserTestUtils.openNewForegroundTab(win.gBrowser, "about:robots"); | ||
| const manager = win.gZenCompactModeManager; | ||
| const sidebar = win.gNavToolbox; | ||
| manager.preference = true; | ||
| await TestUtils.waitForCondition( | ||
| () => | ||
| !win.document.documentElement.hasAttribute("zen-compact-animating") && | ||
| !sidebar.style.transition, | ||
| "Compact-mode setup has finished" | ||
| ); | ||
|
|
||
| const background = sidebar.querySelector(".zen-toolbar-background"); | ||
| const gradient = "linear-gradient(to right, red, blue)"; | ||
| background.style.setProperty( | ||
| "--zen-main-browser-background-toolbar", | ||
| gradient | ||
| ); | ||
| background.style.setProperty( | ||
| "--zen-main-browser-background-toolbar-old", | ||
| gradient | ||
| ); | ||
|
|
||
| const canvas = win.document.createElementNS( | ||
| "http://www.w3.org/1999/xhtml", | ||
| "canvas" | ||
| ); | ||
| canvas.width = canvas.height = 1; | ||
| const context = canvas.getContext("2d"); | ||
| const sample = () => { | ||
| const rect = background.getBoundingClientRect(); | ||
| const x = Math.round(rightSide ? rect.left + 30 : rect.right - 30); | ||
| const y = Math.round(rect.top + rect.height * 0.6); | ||
| Assert.ok( | ||
| x > 0 && x < win.innerWidth, | ||
| "The sample is inside the window" | ||
| ); | ||
| context.drawWindow(win, x, y, 1, 1, "white"); | ||
| return [...context.getImageData(0, 0, 1, 1).data].slice(0, 3); | ||
| }; | ||
|
|
||
| // Exercise both the incoming and outgoing workspace-theme layers. | ||
| for (const opacity of [1, 0]) { | ||
| background.style.setProperty("--zen-background-opacity", opacity); | ||
| sidebar.style.setProperty("transition", "none", "important"); | ||
| manager._setElementExpandAttribute(sidebar, true); | ||
| const expected = sample(); | ||
|
|
||
| sidebar.style.setProperty( | ||
| "transition", | ||
| "translate 250ms linear", | ||
| "important" | ||
| ); | ||
| manager._setElementExpandAttribute(sidebar, false); | ||
| win.getComputedStyle(sidebar).translate; | ||
| for (const animation of sidebar.getAnimations()) { | ||
| animation.finish(); | ||
| } | ||
| sidebar.getBoundingClientRect(); | ||
|
|
||
| manager._setElementExpandAttribute(sidebar, true); | ||
| win.getComputedStyle(sidebar).translate; | ||
| const animation = sidebar | ||
| .getAnimations() | ||
| .find(item => item.transitionProperty === "translate"); | ||
| Assert.ok(animation, "Revealing the sidebar starts a translation"); | ||
| animation.pause(); | ||
| animation.currentTime = 125; | ||
| await new Promise(resolve => | ||
| win.requestAnimationFrame(() => win.requestAnimationFrame(resolve)) | ||
| ); | ||
|
|
||
| const actual = sample(); | ||
| const difference = Math.max( | ||
| ...actual.map((value, index) => Math.abs(value - expected[index])) | ||
| ); | ||
| Assert.lessOrEqual( | ||
| difference, | ||
| 8, | ||
| `${rightSide ? "Right" : "Left"} sidebar layer ${opacity} keeps its gradient during reveal: ${actual} versus ${expected}` | ||
| ); | ||
| animation.finish(); | ||
| } | ||
| } finally { | ||
| await BrowserTestUtils.closeWindow(win); | ||
| await SpecialPowers.popPrefEnv(); | ||
| } | ||
| } | ||
| await SpecialPowers.popPrefEnv(); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.