mirror of
https://github.com/zen-browser/desktop.git
synced 2026-08-29 01:41:33 +00:00
test: Fixed restore tests and fixed possible memory leak on theme modifiers, b=no-bug, c=common, workspaces, tests
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#tabbrowser-tabpanels[dragging-split='true'] {
|
||||
width: -moz-available;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
overflow: clip;
|
||||
|
||||
&.browserSidebarContainer {
|
||||
:root:not([zen-no-padding='true']) & {
|
||||
|
||||
@@ -46,11 +46,15 @@ var ZenThemeModifier = {
|
||||
Services.prefs.addObserver(pref, handleEvent);
|
||||
}
|
||||
|
||||
window.addEventListener('unload', () => {
|
||||
for (let pref of kZenThemePrefsList) {
|
||||
Services.prefs.removeObserver(pref, handleEvent);
|
||||
}
|
||||
});
|
||||
window.addEventListener(
|
||||
'unload',
|
||||
() => {
|
||||
for (let pref of kZenThemePrefsList) {
|
||||
Services.prefs.removeObserver(pref, handleEvent);
|
||||
}
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
},
|
||||
|
||||
handleEvent(event) {
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
'use strict';
|
||||
|
||||
add_task(async function test_Restore_Closed_Tabs() {
|
||||
const currentTab = gBrowser.selectedTab;
|
||||
const currentTab = BrowserTestUtils.addTab(window.gBrowser, 'https://example.com/current', {
|
||||
skipAnimation: true,
|
||||
});
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
const tabsToClose = [];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
@@ -35,7 +38,7 @@ add_task(async function test_Restore_Closed_Tabs() {
|
||||
ok(!currentTab.selected, 'Current tab should not be selected after restore');
|
||||
Assert.equal(
|
||||
gBrowser.tabs.length,
|
||||
5, // 1 initial tab + 3 restored tabs
|
||||
5, // 1 initial tab + 3 restored tabs + 1 for empty tab
|
||||
'There should be four tabs after restoring closed tabs'
|
||||
);
|
||||
gBrowser.selectedTab = currentTab;
|
||||
|
||||
@@ -151,14 +151,20 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
}
|
||||
|
||||
if (!this.privateWindowOrDisabled) {
|
||||
const observerFunction = async function observe(subject) {
|
||||
this._workspaceBookmarksCache = null;
|
||||
await this.workspaceBookmarks();
|
||||
this._invalidateBookmarkContainers();
|
||||
};
|
||||
Services.obs.addObserver(this, 'weave:engine:sync:finish');
|
||||
Services.obs.addObserver(
|
||||
async function observe(subject) {
|
||||
this._workspaceBookmarksCache = null;
|
||||
await this.workspaceBookmarks();
|
||||
this._invalidateBookmarkContainers();
|
||||
}.bind(this),
|
||||
'workspace-bookmarks-updated'
|
||||
Services.obs.addObserver(observerFunction, 'workspace-bookmarks-updated');
|
||||
window.addEventListener(
|
||||
'unload',
|
||||
() => {
|
||||
Services.obs.removeObserver(this, 'weave:engine:sync:finish');
|
||||
Services.obs.removeObserver(observerFunction, 'workspace-bookmarks-updated');
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -962,7 +968,14 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
) {
|
||||
this.log(`Found tab to select: ${this._tabToSelect}, ${tabs.length}`);
|
||||
setTimeout(() => {
|
||||
gBrowser.selectedTab = gZenGlanceManager.getTabOrGlanceParent(tabs[this._tabToSelect]);
|
||||
let tabToUse = gZenGlanceManager.getTabOrGlanceParent(tabs[this._tabToSelect]);
|
||||
if (tabToUse.pinned) {
|
||||
// We are before the empty tab here, so we need to select the next tab
|
||||
tabToUse = gZenGlanceManager.getTabOrGlanceParent(
|
||||
tabs[this._tabToSelect + 1] || tabs[this._tabToSelect]
|
||||
);
|
||||
}
|
||||
gBrowser.selectedTab = tabToUse;
|
||||
this._removedByStartupPage = true;
|
||||
gBrowser.removeTab(this._tabToRemoveForEmpty, {
|
||||
skipSessionStore: true,
|
||||
|
||||
Reference in New Issue
Block a user