Backed out changeset 00270dd961d6 (bug 1828606) for causing leaked window related bc failures
This commit is contained in:
@@ -28,7 +28,6 @@ class CardContainer extends MozLitElement {
|
|||||||
|
|
||||||
static queries = {
|
static queries = {
|
||||||
detailsEl: "details",
|
detailsEl: "details",
|
||||||
mainSlot: "slot[name=main]",
|
|
||||||
summaryEl: "summary",
|
summaryEl: "summary",
|
||||||
viewAllLink: ".view-all-link",
|
viewAllLink: ".view-all-link",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ fxview-category-button[name="overview"]::part(icon) {
|
|||||||
fxview-category-button[name="opentabs"]::part(icon) {
|
fxview-category-button[name="opentabs"]::part(icon) {
|
||||||
background-image: url("chrome://mozapps/skin/extensions/category-discover.svg");
|
background-image: url("chrome://mozapps/skin/extensions/category-discover.svg");
|
||||||
}
|
}
|
||||||
fxview-category-button[name="recentlyclosed"]::part(icon) {
|
fxview-category-button[name="recently-closed"]::part(icon) {
|
||||||
background-image: url("chrome://mozapps/skin/extensions/category-discover.svg");
|
background-image: url("chrome://mozapps/skin/extensions/category-discover.svg");
|
||||||
}
|
}
|
||||||
fxview-category-button[name="synced-tabs"]::part(icon) {
|
fxview-category-button[name="synced-tabs"]::part(icon) {
|
||||||
@@ -89,10 +89,6 @@ fxview-category-button[name="history"]::part(icon) {
|
|||||||
background-image: url("chrome://mozapps/skin/extensions/category-discover.svg");
|
background-image: url("chrome://mozapps/skin/extensions/category-discover.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
fxview-tab-list.with-dismiss-button::part(secondary-button) {
|
|
||||||
background-image: url("chrome://global/skin/icons/close.svg");
|
|
||||||
}
|
|
||||||
|
|
||||||
fxview-tab-list.history::part(secondary-button) {
|
fxview-tab-list.history::part(secondary-button) {
|
||||||
background-image: url("chrome://global/skin/icons/more.svg");
|
background-image: url("chrome://global/skin/icons/more.svg");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,6 @@
|
|||||||
type="module"
|
type="module"
|
||||||
src="chrome://browser/content/firefoxview/opentabs.mjs"
|
src="chrome://browser/content/firefoxview/opentabs.mjs"
|
||||||
></script>
|
></script>
|
||||||
<script
|
|
||||||
type="module"
|
|
||||||
src="chrome://browser/content/firefoxview/recentlyclosed.mjs"
|
|
||||||
></script>
|
|
||||||
<script
|
<script
|
||||||
type="module"
|
type="module"
|
||||||
src="chrome://browser/content/firefoxview/fxview-category-navigation.mjs"
|
src="chrome://browser/content/firefoxview/fxview-category-navigation.mjs"
|
||||||
@@ -61,7 +57,7 @@
|
|||||||
<fxview-category-button
|
<fxview-category-button
|
||||||
class="category"
|
class="category"
|
||||||
slot="category-button"
|
slot="category-button"
|
||||||
name="recentlyclosed"
|
name="recently-closed"
|
||||||
data-l10n-id="firefoxview-recently-closed-nav"
|
data-l10n-id="firefoxview-recently-closed-nav"
|
||||||
>
|
>
|
||||||
</fxview-category-button>
|
</fxview-category-button>
|
||||||
@@ -86,13 +82,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<view-opentabs slot="opentabs"></view-opentabs>
|
<view-opentabs slot="opentabs"></view-opentabs>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<view-recentlyclosed slot="recentlyclosed"></view-recentlyclosed>
|
|
||||||
</div>
|
|
||||||
</view-overview>
|
</view-overview>
|
||||||
<view-history name="history"></view-history>
|
<view-history name="history"></view-history>
|
||||||
<view-opentabs name="opentabs"></view-opentabs>
|
<view-opentabs name="opentabs"></view-opentabs>
|
||||||
<view-recentlyclosed name="recentlyclosed"></view-recentlyclosed>
|
|
||||||
</named-deck>
|
</named-deck>
|
||||||
</main>
|
</main>
|
||||||
<script src="chrome://browser/content/firefoxview/firefoxview-next.mjs"></script>
|
<script src="chrome://browser/content/firefoxview/firefoxview-next.mjs"></script>
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ window.addEventListener(
|
|||||||
// Clear out the document so the disconnectedCallback will trigger
|
// Clear out the document so the disconnectedCallback will trigger
|
||||||
// properly and all of the custom elements can cleanup.
|
// properly and all of the custom elements can cleanup.
|
||||||
document.body.textContent = "";
|
document.body.textContent = "";
|
||||||
document.querySelector("view-recentlyclosed")?.cleanup();
|
|
||||||
},
|
},
|
||||||
{ once: true }
|
{ once: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ export default class FxviewTabList extends MozLitElement {
|
|||||||
role="listitem"
|
role="listitem"
|
||||||
.secondaryL10nId=${tabItem.secondaryL10nId}
|
.secondaryL10nId=${tabItem.secondaryL10nId}
|
||||||
.secondaryL10nArgs=${ifDefined(tabItem.secondaryL10nArgs)}
|
.secondaryL10nArgs=${ifDefined(tabItem.secondaryL10nArgs)}
|
||||||
.closedId=${ifDefined(tabItem.closedId || tabItem.closedId)}
|
.tabid=${ifDefined(tabItem.tabid || tabItem.closedId)}
|
||||||
.tabElement=${ifDefined(tabItem.tabElement)}
|
.tabElement=${ifDefined(tabItem.tabElement)}
|
||||||
.time=${(tabItem.time || tabItem.closedAt).toString().length ===
|
.time=${(tabItem.time || tabItem.closedAt).toString().length ===
|
||||||
16
|
16
|
||||||
@@ -258,7 +258,7 @@ customElements.define("fxview-tab-list", FxviewTabList);
|
|||||||
* @property {string} currentActiveElementId - ID of currently focused element within each tab item
|
* @property {string} currentActiveElementId - ID of currently focused element within each tab item
|
||||||
* @property {string} dateTimeFormat - Expected format for date and/or time
|
* @property {string} dateTimeFormat - Expected format for date and/or time
|
||||||
* @property {string} hasPopup - The aria-haspopup attribute for the secondary action, if required
|
* @property {string} hasPopup - The aria-haspopup attribute for the secondary action, if required
|
||||||
* @property {number} closedId - The tab ID for when the tab item was closed.
|
* @property {number} tabid - The tab ID for when the tab item.
|
||||||
* @property {string} favicon - The favicon for the tab item.
|
* @property {string} favicon - The favicon for the tab item.
|
||||||
* @property {string} primaryL10nId - The l10n id used for the primary action element
|
* @property {string} primaryL10nId - The l10n id used for the primary action element
|
||||||
* @property {string} primaryL10nArgs - The l10n args used for the primary action element
|
* @property {string} primaryL10nArgs - The l10n args used for the primary action element
|
||||||
@@ -288,7 +288,7 @@ export class FxviewTabRow extends MozLitElement {
|
|||||||
primaryL10nArgs: { type: String },
|
primaryL10nArgs: { type: String },
|
||||||
secondaryL10nId: { type: String },
|
secondaryL10nId: { type: String },
|
||||||
secondaryL10nArgs: { type: String },
|
secondaryL10nArgs: { type: String },
|
||||||
closedId: { type: Number },
|
tabid: { type: Number },
|
||||||
tabElement: { type: Object },
|
tabElement: { type: Object },
|
||||||
time: { type: Number },
|
time: { type: Number },
|
||||||
title: { type: String },
|
title: { type: String },
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ browser.jar:
|
|||||||
content/browser/firefoxview/tab-pickup-container.mjs
|
content/browser/firefoxview/tab-pickup-container.mjs
|
||||||
content/browser/firefoxview/tab-pickup-list.mjs
|
content/browser/firefoxview/tab-pickup-list.mjs
|
||||||
content/browser/firefoxview/recently-closed-tabs.mjs
|
content/browser/firefoxview/recently-closed-tabs.mjs
|
||||||
content/browser/firefoxview/recentlyclosed.mjs
|
|
||||||
content/browser/firefoxview/viewpage.mjs
|
content/browser/firefoxview/viewpage.mjs
|
||||||
content/browser/firefoxview/recently-closed-empty.svg (content/recently-closed-empty.svg)
|
content/browser/firefoxview/recently-closed-empty.svg (content/recently-closed-empty.svg)
|
||||||
content/browser/firefoxview/tab-pickup-empty.svg (content/tab-pickup-empty.svg)
|
content/browser/firefoxview/tab-pickup-empty.svg (content/tab-pickup-empty.svg)
|
||||||
|
|||||||
@@ -1,220 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
import { html } from "chrome://global/content/vendor/lit.all.mjs";
|
|
||||||
import { ViewPage } from "./viewpage.mjs";
|
|
||||||
// eslint-disable-next-line import/no-unassigned-import
|
|
||||||
import "chrome://browser/content/firefoxview/card-container.mjs";
|
|
||||||
// eslint-disable-next-line import/no-unassigned-import
|
|
||||||
import "chrome://browser/content/firefoxview/fxview-tab-list.mjs";
|
|
||||||
|
|
||||||
const lazy = {};
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
|
||||||
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
|
|
||||||
});
|
|
||||||
|
|
||||||
const SS_NOTIFY_CLOSED_OBJECTS_CHANGED = "sessionstore-closed-objects-changed";
|
|
||||||
const SS_NOTIFY_BROWSER_SHUTDOWN_FLUSH = "sessionstore-browser-shutdown-flush";
|
|
||||||
|
|
||||||
function getWindow() {
|
|
||||||
return window.browsingContext.embedderWindowGlobal.browsingContext.window;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RecentlyClosedTabsInView extends ViewPage {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.boundObserve = (...args) => this.observe(...args);
|
|
||||||
this.maxTabsLength = this.overview ? 5 : 25;
|
|
||||||
this.recentlyClosedTabs = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
static queries = {
|
|
||||||
cardEl: "card-container",
|
|
||||||
};
|
|
||||||
|
|
||||||
observe(subject, topic, data) {
|
|
||||||
if (
|
|
||||||
topic == SS_NOTIFY_CLOSED_OBJECTS_CHANGED ||
|
|
||||||
(topic == SS_NOTIFY_BROWSER_SHUTDOWN_FLUSH &&
|
|
||||||
subject.ownerGlobal == getWindow())
|
|
||||||
) {
|
|
||||||
this.updateRecentlyClosedTabs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
connectedCallback() {
|
|
||||||
super.connectedCallback();
|
|
||||||
this.updateRecentlyClosedTabs();
|
|
||||||
this.addObserversIfNeeded();
|
|
||||||
getWindow().gBrowser.tabContainer.addEventListener("TabSelect", this);
|
|
||||||
}
|
|
||||||
|
|
||||||
addObserversIfNeeded() {
|
|
||||||
if (!this.observerAdded) {
|
|
||||||
Services.obs.addObserver(
|
|
||||||
this.boundObserve,
|
|
||||||
SS_NOTIFY_CLOSED_OBJECTS_CHANGED
|
|
||||||
);
|
|
||||||
Services.obs.addObserver(
|
|
||||||
this.boundObserve,
|
|
||||||
SS_NOTIFY_BROWSER_SHUTDOWN_FLUSH
|
|
||||||
);
|
|
||||||
this.observerAdded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
removeObserversIfNeeded() {
|
|
||||||
if (this.observerAdded) {
|
|
||||||
Services.obs.removeObserver(
|
|
||||||
this.boundObserve,
|
|
||||||
SS_NOTIFY_CLOSED_OBJECTS_CHANGED
|
|
||||||
);
|
|
||||||
Services.obs.removeObserver(
|
|
||||||
this.boundObserve,
|
|
||||||
SS_NOTIFY_BROWSER_SHUTDOWN_FLUSH
|
|
||||||
);
|
|
||||||
this.observerAdded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup() {
|
|
||||||
getWindow().gBrowser.tabContainer.removeEventListener("TabSelect", this);
|
|
||||||
this.removeObserversIfNeeded();
|
|
||||||
}
|
|
||||||
|
|
||||||
// we observe when a tab closes but since this notification fires more frequently and on
|
|
||||||
// all windows, we remove the observer when another tab is selected; we check for changes
|
|
||||||
// to the session store once the user return to this tab.
|
|
||||||
handleObservers(contentDocument) {
|
|
||||||
if (contentDocument?.URL.split("#")[0] == "about:firefoxview-next") {
|
|
||||||
this.addObserversIfNeeded();
|
|
||||||
this.updateRecentlyClosedTabs();
|
|
||||||
} else {
|
|
||||||
this.removeObserversIfNeeded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleEvent(event) {
|
|
||||||
if (event.type == "TabSelect") {
|
|
||||||
this.handleObservers(event.target.linkedBrowser.contentDocument);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getTabStateValue(tab, key) {
|
|
||||||
let value = "";
|
|
||||||
const tabEntries = tab.state.entries;
|
|
||||||
const activeIndex = tab.state.index - 1;
|
|
||||||
|
|
||||||
if (activeIndex >= 0 && tabEntries[activeIndex]) {
|
|
||||||
value = tabEntries[activeIndex][key];
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateRecentlyClosedTabs() {
|
|
||||||
let recentlyClosedTabsData = lazy.SessionStore.getClosedTabDataForWindow(
|
|
||||||
getWindow()
|
|
||||||
);
|
|
||||||
this.recentlyClosedTabs = recentlyClosedTabsData.slice(
|
|
||||||
0,
|
|
||||||
this.maxTabsLength
|
|
||||||
);
|
|
||||||
this.normalizeRecentlyClosedData();
|
|
||||||
this.requestUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
normalizeRecentlyClosedData() {
|
|
||||||
// Normalize data for fxview-tabs-list
|
|
||||||
this.recentlyClosedTabs.forEach(recentlyClosedItem => {
|
|
||||||
const targetURI = this.getTabStateValue(recentlyClosedItem, "url");
|
|
||||||
recentlyClosedItem.time = recentlyClosedItem.closedAt;
|
|
||||||
recentlyClosedItem.icon = recentlyClosedItem.image;
|
|
||||||
recentlyClosedItem.primaryL10nId = "fxviewtabrow-tabs-list-tab";
|
|
||||||
recentlyClosedItem.primaryL10nArgs = JSON.stringify({
|
|
||||||
targetURI,
|
|
||||||
});
|
|
||||||
recentlyClosedItem.secondaryL10nId =
|
|
||||||
"firefoxview-closed-tabs-dismiss-tab";
|
|
||||||
recentlyClosedItem.secondaryL10nArgs = JSON.stringify({
|
|
||||||
tabTitle: recentlyClosedItem.title,
|
|
||||||
});
|
|
||||||
recentlyClosedItem.url = targetURI;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onReopenTab(e) {
|
|
||||||
const closedId = parseInt(e.originalTarget.closedId, 10);
|
|
||||||
lazy.SessionStore.undoCloseById(closedId);
|
|
||||||
}
|
|
||||||
|
|
||||||
onDismissTab(e) {
|
|
||||||
let recentlyClosedList = lazy.SessionStore.getClosedTabDataForWindow(
|
|
||||||
getWindow()
|
|
||||||
);
|
|
||||||
let closedTabIndex = recentlyClosedList.findIndex(closedTab => {
|
|
||||||
return closedTab.closedId === parseInt(e.originalTarget.closedId, 10);
|
|
||||||
});
|
|
||||||
if (closedTabIndex < 0) {
|
|
||||||
// Tab not found in recently closed list
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
lazy.SessionStore.forgetClosedTab(getWindow(), closedTabIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (!this.selectedTab && !this.overview) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return html`
|
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
href="chrome://browser/content/firefoxview/firefoxview-next.css"
|
|
||||||
/>
|
|
||||||
<div class="sticky-container bottom-fade" ?hidden=${!this.selectedTab}>
|
|
||||||
<h2
|
|
||||||
class="page-header"
|
|
||||||
data-l10n-id="firefoxview-recently-closed-header"
|
|
||||||
></h2>
|
|
||||||
</div>
|
|
||||||
<div class="cards-container">
|
|
||||||
<card-container
|
|
||||||
.viewAllPage=${this.overview && this.recentlyClosedTabs.length
|
|
||||||
? "recentlyclosed"
|
|
||||||
: null}
|
|
||||||
?preserveCollapseState=${this.overview ? true : null}
|
|
||||||
?hideHeader=${this.selectedTab}
|
|
||||||
>
|
|
||||||
<h2
|
|
||||||
slot="header"
|
|
||||||
data-l10n-id="firefoxview-recently-closed-header"
|
|
||||||
></h2>
|
|
||||||
<fxview-tab-list
|
|
||||||
class="with-dismiss-button"
|
|
||||||
?hidden=${!this.recentlyClosedTabs.length}
|
|
||||||
slot="main"
|
|
||||||
.maxTabsLength=${this.maxTabsLength}
|
|
||||||
.tabItems=${this.recentlyClosedTabs}
|
|
||||||
@fxview-tab-list-secondary-action=${this.onDismissTab}
|
|
||||||
@fxview-tab-list-primary-action=${this.onReopenTab}
|
|
||||||
></fxview-tab-list>
|
|
||||||
<div slot="main" ?hidden=${this.recentlyClosedTabs.length}>
|
|
||||||
<!-- TO-DO: Bug 1841795 - Add Recently Closed empty states -->
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
slot="footer"
|
|
||||||
name="history"
|
|
||||||
?hidden=${!this.selectedTab || !this.recentlyClosedTabs.length}
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="about:firefoxview-next#history"
|
|
||||||
data-l10n-id="firefoxview-view-more-browsing-history"
|
|
||||||
></a>
|
|
||||||
</div>
|
|
||||||
</card-container>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
customElements.define("view-recentlyclosed", RecentlyClosedTabsInView);
|
|
||||||
@@ -23,7 +23,6 @@ skip-if = true # Bug 1783684
|
|||||||
[browser_recently_closed_tabs.js]
|
[browser_recently_closed_tabs.js]
|
||||||
[browser_recently_closed_tabs_keyboard.js]
|
[browser_recently_closed_tabs_keyboard.js]
|
||||||
[browser_recently_closed_tabs_windows.js]
|
[browser_recently_closed_tabs_windows.js]
|
||||||
[browser_recentlyclosed_firefoxview_next.js]
|
|
||||||
[browser_reload_firefoxview.js]
|
[browser_reload_firefoxview.js]
|
||||||
[browser_setup_errors.js]
|
[browser_setup_errors.js]
|
||||||
[browser_setup_primary_password.js]
|
[browser_setup_primary_password.js]
|
||||||
|
|||||||
@@ -1,237 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(globalThis, {
|
|
||||||
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
|
|
||||||
});
|
|
||||||
|
|
||||||
const FXVIEW_NEXT_ENABLED_PREF = "browser.tabs.firefox-view-next";
|
|
||||||
|
|
||||||
function isElInViewport(element) {
|
|
||||||
const boundingRect = element.getBoundingClientRect();
|
|
||||||
return (
|
|
||||||
boundingRect.top >= 0 &&
|
|
||||||
boundingRect.left >= 0 &&
|
|
||||||
boundingRect.bottom <=
|
|
||||||
(window.innerHeight || document.documentElement.clientHeight) &&
|
|
||||||
boundingRect.right <=
|
|
||||||
(window.innerWidth || document.documentElement.clientWidth)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function openFirefoxView(win) {
|
|
||||||
await BrowserTestUtils.synthesizeMouseAtCenter(
|
|
||||||
"#firefox-view-button",
|
|
||||||
{ type: "mousedown" },
|
|
||||||
win.browsingContext
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function dismiss_tab(tab, content, document) {
|
|
||||||
// Make sure the firefoxview-next tab still has focus
|
|
||||||
is(
|
|
||||||
document.location.href,
|
|
||||||
"about:firefoxview-next#recentlyclosed",
|
|
||||||
"about:firefoxview-next is the selected tab and showing the Recently closed view page"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Scroll to the tab element to ensure dismiss button is visible
|
|
||||||
tab.scrollIntoView();
|
|
||||||
is(isElInViewport(tab), true, "Tab is visible in viewport");
|
|
||||||
|
|
||||||
info(`Dismissing tab ${tab.url}`);
|
|
||||||
const closedObjectsChanged = () =>
|
|
||||||
TestUtils.topicObserved("sessionstore-closed-objects-changed");
|
|
||||||
let dismissButton = tab.buttonEl;
|
|
||||||
EventUtils.synthesizeMouseAtCenter(dismissButton, {}, content);
|
|
||||||
await closedObjectsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
function navigateToRecentlyClosed(document) {
|
|
||||||
// Navigate to Recently closed tabs page/view
|
|
||||||
const navigation = document.querySelector("fxview-category-navigation");
|
|
||||||
let recentlyClosedNavButton = Array.from(navigation.categoryButtons).find(
|
|
||||||
categoryButton => {
|
|
||||||
return categoryButton.name === "recentlyclosed";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
recentlyClosedNavButton.buttonEl.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
add_setup(async () => {
|
|
||||||
await SpecialPowers.pushPrefEnv({ set: [[FXVIEW_NEXT_ENABLED_PREF, true]] });
|
|
||||||
registerCleanupFunction(async () => {
|
|
||||||
await SpecialPowers.popPrefEnv();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_list_ordering() {
|
|
||||||
Services.obs.notifyObservers(null, "browser:purge-session-history");
|
|
||||||
is(
|
|
||||||
SessionStore.getClosedTabCountForWindow(window),
|
|
||||||
0,
|
|
||||||
"Closed tab count after purging session history"
|
|
||||||
);
|
|
||||||
|
|
||||||
await open_then_close(URLs[0]);
|
|
||||||
await open_then_close(URLs[1]);
|
|
||||||
await open_then_close(URLs[2]);
|
|
||||||
await withFirefoxView({}, async browser => {
|
|
||||||
const { document } = browser.contentWindow;
|
|
||||||
is(document.location.href, "about:firefoxview-next");
|
|
||||||
|
|
||||||
navigateToRecentlyClosed(document);
|
|
||||||
|
|
||||||
let recentlyClosedComponent = document.querySelector(
|
|
||||||
"view-recentlyclosed:not([slot=recentlyclosed])"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check that tabs list is rendered
|
|
||||||
await TestUtils.waitForCondition(() => {
|
|
||||||
return recentlyClosedComponent.cardEl;
|
|
||||||
});
|
|
||||||
let cardContainer = recentlyClosedComponent.cardEl;
|
|
||||||
let cardMainSlotNode = Array.from(
|
|
||||||
cardContainer?.mainSlot?.assignedNodes()
|
|
||||||
)[0];
|
|
||||||
is(
|
|
||||||
cardMainSlotNode.tagName.toLowerCase(),
|
|
||||||
"fxview-tab-list",
|
|
||||||
"The tab list component is rendered."
|
|
||||||
);
|
|
||||||
|
|
||||||
let tabList = cardMainSlotNode.rowEls;
|
|
||||||
|
|
||||||
is(tabList.length, 3, "Three tabs are shown in the list.");
|
|
||||||
is(
|
|
||||||
tabList[0].url,
|
|
||||||
"https://example.net/",
|
|
||||||
"First list item in recentlyclosed is in the correct order"
|
|
||||||
);
|
|
||||||
is(
|
|
||||||
tabList[2].url,
|
|
||||||
"http://mochi.test:8888/browser/",
|
|
||||||
"Last list item in recentlyclosed is in the correct order"
|
|
||||||
);
|
|
||||||
|
|
||||||
let uri = tabList[0].url;
|
|
||||||
let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, uri);
|
|
||||||
tabList[0].mainEl.click();
|
|
||||||
await newTabPromise;
|
|
||||||
|
|
||||||
gBrowser.removeTab(gBrowser.selectedTab);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_list_updates() {
|
|
||||||
Services.obs.notifyObservers(null, "browser:purge-session-history");
|
|
||||||
is(
|
|
||||||
SessionStore.getClosedTabCountForWindow(window),
|
|
||||||
0,
|
|
||||||
"Closed tab count after purging session history"
|
|
||||||
);
|
|
||||||
|
|
||||||
await open_then_close(URLs[0]);
|
|
||||||
await open_then_close(URLs[1]);
|
|
||||||
await open_then_close(URLs[2]);
|
|
||||||
await withFirefoxView({}, async browser => {
|
|
||||||
const { document } = browser.contentWindow;
|
|
||||||
is(document.location.href, "about:firefoxview-next");
|
|
||||||
|
|
||||||
navigateToRecentlyClosed(document);
|
|
||||||
|
|
||||||
let recentlyClosedComponent = document.querySelector(
|
|
||||||
"view-recentlyclosed:not([slot=recentlyclosed])"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check that tabs list is rendered
|
|
||||||
await TestUtils.waitForCondition(() => {
|
|
||||||
return recentlyClosedComponent.cardEl;
|
|
||||||
});
|
|
||||||
let cardContainer = recentlyClosedComponent.cardEl;
|
|
||||||
let cardMainSlotNode = Array.from(
|
|
||||||
cardContainer?.mainSlot?.assignedNodes()
|
|
||||||
)[0];
|
|
||||||
is(
|
|
||||||
cardMainSlotNode.tagName.toLowerCase(),
|
|
||||||
"fxview-tab-list",
|
|
||||||
"The tab list component is rendered."
|
|
||||||
);
|
|
||||||
|
|
||||||
let tabList = cardMainSlotNode.rowEls;
|
|
||||||
|
|
||||||
is(tabList.length, 3, "Three tabs are shown in the list.");
|
|
||||||
const closedObjectsChanged = () =>
|
|
||||||
TestUtils.topicObserved("sessionstore-closed-objects-changed");
|
|
||||||
SessionStore.undoCloseById(tabList[0].closedId);
|
|
||||||
await closedObjectsChanged();
|
|
||||||
await openFirefoxView(window);
|
|
||||||
tabList = cardMainSlotNode.rowEls;
|
|
||||||
is(tabList.length, 2, "Two tabs are shown in the list.");
|
|
||||||
|
|
||||||
const closedObjectsChangedAgain = () =>
|
|
||||||
TestUtils.topicObserved("sessionstore-closed-objects-changed");
|
|
||||||
SessionStore.forgetClosedTab(window, 0);
|
|
||||||
await closedObjectsChangedAgain();
|
|
||||||
await openFirefoxView(window);
|
|
||||||
tabList = cardMainSlotNode.rowEls;
|
|
||||||
is(tabList.length, 1, "One tab is shown in the list.");
|
|
||||||
|
|
||||||
while (gBrowser.tabs.length > 1) {
|
|
||||||
gBrowser.removeTab(gBrowser.selectedTab);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Asserts that tabs that have been recently closed can be
|
|
||||||
* dismissed by clicking on their respective dismiss buttons.
|
|
||||||
*/
|
|
||||||
add_task(async function test_dismiss_tab() {
|
|
||||||
Services.obs.notifyObservers(null, "browser:purge-session-history");
|
|
||||||
is(
|
|
||||||
SessionStore.getClosedTabCountForWindow(window),
|
|
||||||
0,
|
|
||||||
"Closed tab count after purging session history"
|
|
||||||
);
|
|
||||||
|
|
||||||
await open_then_close(URLs[0]);
|
|
||||||
await open_then_close(URLs[1]);
|
|
||||||
await open_then_close(URLs[2]);
|
|
||||||
await withFirefoxView({}, async browser => {
|
|
||||||
const { document } = browser.contentWindow;
|
|
||||||
|
|
||||||
navigateToRecentlyClosed(document);
|
|
||||||
|
|
||||||
let recentlyClosedComponent = document.querySelector(
|
|
||||||
"view-recentlyclosed:not([slot=recentlyclosed])"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check that tabs list is rendered
|
|
||||||
await TestUtils.waitForCondition(() => {
|
|
||||||
return recentlyClosedComponent.cardEl;
|
|
||||||
});
|
|
||||||
let cardContainer = recentlyClosedComponent.cardEl;
|
|
||||||
let cardMainSlotNode = Array.from(
|
|
||||||
cardContainer?.mainSlot?.assignedNodes()
|
|
||||||
)[0];
|
|
||||||
let tabList = cardMainSlotNode.rowEls;
|
|
||||||
|
|
||||||
await dismiss_tab(tabList[0], content, document);
|
|
||||||
await recentlyClosedComponent.getUpdateComplete();
|
|
||||||
Assert.equal(SessionStore.getClosedTabCountForWindow(window), 2);
|
|
||||||
tabList = cardMainSlotNode.rowEls;
|
|
||||||
|
|
||||||
Assert.equal(
|
|
||||||
tabList[0].url,
|
|
||||||
URLs[1],
|
|
||||||
`First recently closed item should be ${URLs[1]}`
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.equal(
|
|
||||||
tabList.length,
|
|
||||||
2,
|
|
||||||
"recentlyclosed should have two list items"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -171,5 +171,3 @@ firefoxview-history-date-prev-month = { DATETIME($date, month: "long", year: "nu
|
|||||||
##
|
##
|
||||||
|
|
||||||
firefoxview-show-all-history = Show all history
|
firefoxview-show-all-history = Show all history
|
||||||
|
|
||||||
firefoxview-view-more-browsing-history = View more browsing history
|
|
||||||
|
|||||||
Reference in New Issue
Block a user