Bug 1833228 - Update naming for new TabList reusable component files to be domain-specific r=mstriemer,fluent-reviewers,fxview-reviewers,flod,sclements

Differential Revision: https://phabricator.services.mozilla.com/D178191
This commit is contained in:
Kelly Cochrane 2023-05-17 14:35:53 +00:00
Родитель 0e4002d83c
Коммит 7e0b29e0b9
11 изменённых файлов: 310 добавлений и 260 удалений

Просмотреть файл

@ -306,11 +306,11 @@ var whitelist = [
// Bug 1824826 - Implement a view of history in Firefox View
{ file: "resource://gre/modules/PlacesQuery.sys.mjs" },
// Should be removed in bug 1824826 when moz-tab-list is used in Firefox View
{ file: "resource://app/localization/en-US/browser/mozTabList.ftl" },
{ file: "chrome://browser/content/firefoxview/moz-tab-list.css" },
{ file: "chrome://browser/content/firefoxview/moz-tab-list.mjs" },
{ file: "chrome://browser/content/firefoxview/moz-tab-row.css" },
// Should be removed in bug 1824826 when fxview-tab-list is used in Firefox View
{ file: "resource://app/localization/en-US/browser/fxviewTabList.ftl" },
{ file: "chrome://browser/content/firefoxview/fxview-tab-list.css" },
{ file: "chrome://browser/content/firefoxview/fxview-tab-list.mjs" },
{ file: "chrome://browser/content/firefoxview/fxview-tab-row.css" },
];
if (AppConstants.NIGHTLY_BUILD && AppConstants.platform != "win") {

Просмотреть файл

@ -2,7 +2,7 @@
* 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/. */
.moz-tab-list {
.fxview-tab-list {
display: grid;
grid-template-columns: min-content 3fr 2fr 1fr 1fr min-content;
gap: 8px;

Просмотреть файл

@ -37,13 +37,13 @@ if (!window.IS_STORYBOOK) {
* @property {number} maxTabsLength - The max number of tabs for the list
* @property {Array} tabItems - Items to show in the tab list
*/
export default class MozTabList extends MozLitElement {
export default class FxviewTabList extends MozLitElement {
constructor() {
super();
window.MozXULElement.insertFTLIfNeeded("toolkit/branding/brandings.ftl");
window.MozXULElement.insertFTLIfNeeded("browser/mozTabList.ftl");
window.MozXULElement.insertFTLIfNeeded("browser/fxviewTabList.ftl");
this.activeIndex = 0;
this.currentActiveElementId = "moz-tab-row-main";
this.currentActiveElementId = "fxview-tab-row-main";
this.hasPopup = null;
this.dateTimeFormat = "relative";
this.maxTabsLength = 25;
@ -61,7 +61,7 @@ export default class MozTabList extends MozLitElement {
};
static queries = {
rowEls: { all: "moz-tab-row" },
rowEls: { all: "fxview-tab-row" },
};
willUpdate(changes) {
@ -127,15 +127,17 @@ export default class MozTabList extends MozLitElement {
onIntervalUpdate() {
this.requestUpdate();
Array.from(this.rowEls).forEach(mozTabRow => mozTabRow.requestUpdate());
Array.from(this.rowEls).forEach(fxviewTabRow =>
fxviewTabRow.requestUpdate()
);
}
/**
* Focuses the expected element (either the link or button) within moz-tab-row
* Focuses the expected element (either the link or button) within fxview-tab-row
* The currently focused/active element ID within a row is stored in this.currentActiveElementId
*/
handleFocusElementInRow(e) {
let mozTabRow = e.target;
let fxviewTabRow = e.target;
if (e.code == "ArrowUp") {
// Focus either the link or button of the previous row based on this.currentActiveElementId
e.preventDefault();
@ -149,18 +151,18 @@ export default class MozTabList extends MozLitElement {
// set this.currentActiveElementId to that element's ID
e.preventDefault();
if (document.dir == "rtl") {
this.currentActiveElementId = mozTabRow.focusLink();
this.currentActiveElementId = fxviewTabRow.focusLink();
} else {
this.currentActiveElementId = mozTabRow.focusButton();
this.currentActiveElementId = fxviewTabRow.focusButton();
}
} else if (e.code == "ArrowLeft") {
// Focus either the link or the button in the current row and
// set this.currentActiveElementId to that element's ID
e.preventDefault();
if (document.dir == "rtl") {
this.currentActiveElementId = mozTabRow.focusButton();
this.currentActiveElementId = fxviewTabRow.focusButton();
} else {
this.currentActiveElementId = mozTabRow.focusLink();
this.currentActiveElementId = fxviewTabRow.focusLink();
}
}
}
@ -185,8 +187,8 @@ export default class MozTabList extends MozLitElement {
// Use a relative URL in storybook to get faster reloads on style changes.
static stylesheetUrl = window.IS_STORYBOOK
? "./moz-tab-list.css"
: "chrome://browser/content/firefoxview/moz-tab-list.css";
? "./fxview-tab-list.css"
: "chrome://browser/content/firefoxview/fxview-tab-list.css";
render() {
this.tabItems = this.tabItems.slice(0, this.maxTabsLength);
@ -200,15 +202,15 @@ export default class MozTabList extends MozLitElement {
return html`
<link rel="stylesheet" href=${this.constructor.stylesheetUrl} />
<div
id="moz-tab-list"
class="moz-tab-list"
id="fxview-tab-list"
class="fxview-tab-list"
role="list"
@keydown=${this.handleFocusElementInRow}
>
${tabItems.map(
(tabItem, i) =>
html`
<moz-tab-row
<fxview-tab-row
exportparts="secondary-button"
?active=${i == activeIndex}
.hasPopup=${hasPopup}
@ -229,7 +231,7 @@ export default class MozTabList extends MozLitElement {
.title=${tabItem.title}
.url=${tabItem.url}
>
</moz-tab-row>
</fxview-tab-row>
`
)}
</div>
@ -237,7 +239,7 @@ export default class MozTabList extends MozLitElement {
`;
}
}
customElements.define("moz-tab-list", MozTabList);
customElements.define("fxview-tab-list", FxviewTabList);
/**
* A tab item that displays favicon, title, url, and time of last access
@ -257,11 +259,11 @@ customElements.define("moz-tab-list", MozTabList);
* @property {string} url - The url for the tab item.
* @property {number} timeMsPref - The frequency in milliseconds of updates to relative time
*/
export class MozTabRow extends MozLitElement {
export class FxviewTabRow extends MozLitElement {
constructor() {
super();
this.active = false;
this.currentActiveElementId = "moz-tab-row-main";
this.currentActiveElementId = "fxview-tab-row-main";
}
static properties = {
@ -282,8 +284,8 @@ export class MozTabRow extends MozLitElement {
};
static queries = {
mainEl: ".moz-tab-row-main",
buttonEl: ".moz-tab-row-button:not([hidden])",
mainEl: ".fxview-tab-row-main",
buttonEl: ".fxview-tab-row-button:not([hidden])",
};
get currentFocusable() {
@ -310,8 +312,8 @@ export class MozTabRow extends MozLitElement {
// Use a relative URL in storybook to get faster reloads on style changes.
static stylesheetUrl = window.IS_STORYBOOK
? "./moz-tab-row.css"
: "chrome://browser/content/firefoxview/moz-tab-row.css";
? "./fxview-tab-row.css"
: "chrome://browser/content/firefoxview/fxview-tab-row.css";
dateFluentArgs(timestamp, dateTimeFormat) {
if (dateTimeFormat === "date" || dateTimeFormat === "dateTime") {
@ -328,11 +330,11 @@ export class MozTabRow extends MozLitElement {
const elapsed = Date.now() - timestamp;
if (elapsed <= _nowThresholdMs || !lazy.relativeTimeFormat) {
// Use a different string for very recent timestamps
return "mztabrow-just-now-timestamp";
return "fxviewtabrow-just-now-timestamp";
}
return null;
} else if (dateTimeFormat === "date" || dateTimeFormat === "dateTime") {
return "mztabrow-date";
return "fxviewtabrow-date";
}
return null;
}
@ -349,7 +351,7 @@ export class MozTabRow extends MozLitElement {
timeFluentId(dateTimeFormat) {
if (dateTimeFormat === "time" || dateTimeFormat === "dateTime") {
return "mztabrow-time";
return "fxviewtabrow-time";
}
return null;
}
@ -378,7 +380,7 @@ export class MozTabRow extends MozLitElement {
event.preventDefault();
if (!window.IS_STORYBOOK) {
this.dispatchEvent(
new CustomEvent("moz-tab-list-primary-action", {
new CustomEvent("fxview-tab-list-primary-action", {
bubbles: true,
composed: true,
detail: { originalEvent: event, item: this },
@ -396,7 +398,7 @@ export class MozTabRow extends MozLitElement {
) {
event.preventDefault();
this.dispatchEvent(
new CustomEvent("moz-tab-list-secondary-action", {
new CustomEvent("fxview-tab-list-secondary-action", {
bubbles: true,
composed: true,
detail: { originalEvent: event, item: this },
@ -429,10 +431,10 @@ export class MozTabRow extends MozLitElement {
<link rel="stylesheet" href=${this.constructor.stylesheetUrl} />
<a
href=${this.url}
class="moz-tab-row-main"
id="moz-tab-row-main"
class="fxview-tab-row-main"
id="fxview-tab-row-main"
tabindex=${this.active &&
this.currentActiveElementId === "moz-tab-row-main"
this.currentActiveElementId === "fxview-tab-row-main"
? "0"
: "-1"}
data-l10n-id=${this.primaryL10nId}
@ -441,19 +443,19 @@ export class MozTabRow extends MozLitElement {
@keydown=${this.primaryActionHandler}
>
<span
class="moz-tab-row-favicon icon"
id="moz-tab-row-favicon"
class="fxview-tab-row-favicon icon"
id="fxview-tab-row-favicon"
style=${styleMap({
backgroundImage: `url(${this.getImageUrl(this.favicon, this.url)})`,
})}
></span>
<span class="moz-tab-row-title" id="moz-tab-row-title">
<span class="fxview-tab-row-title" id="fxview-tab-row-title">
${title}
</span>
<span class="moz-tab-row-url" id="moz-tab-row-url">
<span class="fxview-tab-row-url" id="fxview-tab-row-url">
${this.formatURIForDisplay(this.url)}
</span>
<span class="moz-tab-row-date" id="moz-tab-row-date">
<span class="fxview-tab-row-date" id="fxview-tab-row-date">
<span
?hidden=${relativeString || !dateString}
data-l10n-id=${ifDefined(dateString)}
@ -462,8 +464,8 @@ export class MozTabRow extends MozLitElement {
<span ?hidden=${!relativeString}>${relativeString}</span>
</span>
<span
class="moz-tab-row-time"
id="moz-tab-row-time"
class="fxview-tab-row-time"
id="fxview-tab-row-time"
?hidden=${!timeString}
data-timestamp=${this.time}
data-l10n-id=${ifDefined(timeString)}
@ -472,15 +474,15 @@ export class MozTabRow extends MozLitElement {
</span>
</a>
<button
class="moz-tab-row-button ghost-button icon-button semi-transparent"
id="moz-tab-row-secondary-button"
class="fxview-tab-row-button ghost-button icon-button semi-transparent"
id="fxview-tab-row-secondary-button"
part="secondary-button"
data-l10n-id=${this.secondaryL10nId}
data-l10n-args=${ifDefined(this.secondaryL10nArgs)}
aria-haspopup=${ifDefined(this.hasPopup)}
@click=${this.secondaryActionHandler}
tabindex="${this.active &&
this.currentActiveElementId === "moz-tab-row-secondary-button"
this.currentActiveElementId === "fxview-tab-row-secondary-button"
? "0"
: "-1"}"
></button>
@ -488,4 +490,4 @@ export class MozTabRow extends MozLitElement {
}
}
customElements.define("moz-tab-row", MozTabRow);
customElements.define("fxview-tab-row", FxviewTabRow);

Просмотреть файл

@ -0,0 +1,115 @@
/* 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/. */
:host {
--fxviewtabrow-text-secondary-color: color-mix(in srgb, currentColor 70%, transparent);
--fxviewtabrow-background-color: var(--newtab-background-color, var(--in-content-page-background));
--fxviewtabrow-element-background-hover: color-mix(in srgb, var(--fxviewtabrow-background-color) 90%, currentColor);
--fxviewtabrow-element-background-active: color-mix(in srgb, var(--fxviewtabrow-background-color) 80%, currentColor);
display: grid;
grid-template-columns: subgrid;
grid-column: span 6;
align-items: stretch;
border-radius: 4px;
}
@media (prefers-contrast) {
:host {
--fxviewtabrow-element-background-hover: ButtonText;
--fxviewtabrow-element-background-active: ButtonText;
--fxviewtabrow-text-color-hover: ButtonFace;
--fxviewtabrow-text-secondary-color: currentColor;
}
}
.fxview-tab-row-main {
display: grid;
grid-template-columns: subgrid;
grid-column: span 5;
gap: 16px;
border-radius: 4px;
align-items: center;
padding: 4px 8px;
user-select: none;
cursor: pointer;
text-decoration: none;
}
.fxview-tab-row-main,
.fxview-tab-row-main:visited,
.fxview-tab-row-main:hover:active,
.fxview-tab-row-button {
color: inherit;
}
.fxview-tab-row-main:hover,
.fxview-tab-row-button.ghost-button.icon-button:enabled:hover {
background-color: var(--fxviewtabrow-element-background-hover);
color: var(--fxviewtabrow-text-color-hover);
}
.fxview-tab-row-main:hover:active,
.fxview-tab-row-button.ghost-button.icon-button:enabled:hover:active {
background-color: var(--fxviewtabrow-element-background-active);
}
@media (prefers-contrast) {
.fxview-tab-row-main,
.fxview-tab-row-main:hover,
.fxview-tab-row-main:active {
background-color: transparent;
border: 1px solid LinkText;
color: LinkText;
}
.fxview-tab-row-main:visited .fxview-tab-row-main:visited:hover {
border: 1px solid VisitedText;
color: VisitedText;
}
}
.fxview-tab-row-favicon {
background-size: cover;
-moz-context-properties: fill;
fill: currentColor;
display: inline-block;
min-height: 16px;
min-width: 16px;
position: relative;
}
.fxview-tab-row-title {
text-overflow: ellipsis;
white-space: nowrap;
}
.fxview-tab-row-main:hover .fxview-tab-row-title {
text-decoration-line: underline;
}
.fxview-tab-row-url {
color: var(--fxviewtabrow-text-secondary-color);
word-break: break-word;
text-decoration-line: underline;
}
.fxview-tab-row-title,
.fxview-tab-row-url {
overflow: hidden;
}
.fxview-tab-row-date,
.fxview-tab-row-time {
color: var(--fxviewtabrow-text-secondary-color);
white-space: nowrap;
}
.fxview-tab-row-url,
.fxview-tab-row-time {
font-weight: 400;
}
.fxview-tab-row-button {
margin: 0;
}

Просмотреть файл

@ -13,9 +13,9 @@ browser.jar:
content/browser/firefoxview/firefoxview.css
content/browser/firefoxview/firefoxview-next.css
content/browser/firefoxview/helpers.mjs
content/browser/firefoxview/moz-tab-list.css
content/browser/firefoxview/moz-tab-list.mjs
content/browser/firefoxview/moz-tab-row.css
content/browser/firefoxview/fxview-tab-list.css
content/browser/firefoxview/fxview-tab-list.mjs
content/browser/firefoxview/fxview-tab-row.css
content/browser/firefoxview/tab-pickup-container.mjs
content/browser/firefoxview/tab-pickup-list.mjs
content/browser/firefoxview/recently-closed-tabs.mjs

Просмотреть файл

@ -1,115 +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/. */
:host {
--mztabrow-text-secondary-color: color-mix(in srgb, currentColor 70%, transparent);
--mztabrow-background-color: var(--newtab-background-color, var(--in-content-page-background));
--mztabrow-element-background-hover: color-mix(in srgb, var(--mztabrow-background-color) 90%, currentColor);
--mztabrow-element-background-active: color-mix(in srgb, var(--mztabrow-background-color) 80%, currentColor);
display: grid;
grid-template-columns: subgrid;
grid-column: span 6;
align-items: stretch;
border-radius: 4px;
}
@media (prefers-contrast) {
:host {
--mztabrow-element-background-hover: ButtonText;
--mztabrow-element-background-active: ButtonText;
--mztabrow-text-color-hover: ButtonFace;
--mztabrow-text-secondary-color: currentColor;
}
}
.moz-tab-row-main {
display: grid;
grid-template-columns: subgrid;
grid-column: span 5;
gap: 16px;
border-radius: 4px;
align-items: center;
padding: 4px 8px;
user-select: none;
cursor: pointer;
text-decoration: none;
}
.moz-tab-row-main,
.moz-tab-row-main:visited,
.moz-tab-row-main:hover:active,
.moz-tab-row-button {
color: inherit;
}
.moz-tab-row-main:hover,
.moz-tab-row-button.ghost-button.icon-button:enabled:hover {
background-color: var(--mztabrow-element-background-hover);
color: var(--mztabrow-text-color-hover);
}
.moz-tab-row-main:hover:active,
.moz-tab-row-button.ghost-button.icon-button:enabled:hover:active {
background-color: var(--mztabrow-element-background-active);
}
@media (prefers-contrast) {
.moz-tab-row-main,
.moz-tab-row-main:hover,
.moz-tab-row-main:active {
background-color: transparent;
border: 1px solid LinkText;
color: LinkText;
}
.moz-tab-row-main:visited .moz-tab-row-main:visited:hover {
border: 1px solid VisitedText;
color: VisitedText;
}
}
.moz-tab-row-favicon {
background-size: cover;
-moz-context-properties: fill;
fill: currentColor;
display: inline-block;
min-height: 16px;
min-width: 16px;
position: relative;
}
.moz-tab-row-title {
text-overflow: ellipsis;
white-space: nowrap;
}
.moz-tab-row-main:hover .moz-tab-row-title {
text-decoration-line: underline;
}
.moz-tab-row-url {
color: var(--mztabrow-text-secondary-color);
word-break: break-word;
text-decoration-line: underline;
}
.moz-tab-row-title,
.moz-tab-row-url {
overflow: hidden;
}
.moz-tab-row-date,
.moz-tab-row-time {
color: var(--mztabrow-text-secondary-color);
white-space: nowrap;
}
.moz-tab-row-url,
.moz-tab-row-time {
font-weight: 400;
}
.moz-tab-row-button {
margin: 0;
}

Просмотреть файл

@ -1,3 +1,3 @@
[DEFAULT]
[test_moz_tab_list.html]
[test_fxview_tab_list.html]

Просмотреть файл

@ -2,35 +2,35 @@
<html>
<head>
<meta charset="utf-8">
<title>MozTabList Tests</title>
<title>FxviewTabList Tests</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<link rel="localization" href="browser/places.ftl">
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<link rel="stylesheet" href="chrome://global/skin/in-content/common.css">
<script type="module" src="chrome://browser/content/firefoxview/moz-tab-list.mjs"></script>
<script type="module" src="chrome://browser/content/firefoxview/fxview-tab-list.mjs"></script>
</head>
<body>
<style>
moz-tab-list.history::part(secondary-button) {
fxview-tab-list.history::part(secondary-button) {
background-image: url("chrome://global/skin/icons/more.svg");
}
</style>
<p id="display"></p>
<div id="content" style="max-width: 750px">
<moz-tab-list class="history" .dateTimeFormat="relative" .hasPopup="menu">
<fxview-tab-list class="history" .dateTimeFormat="relative" .hasPopup="menu">
<panel-list slot="menu">
<panel-item data-l10n-id="mztabrow-delete"></panel-item>
<panel-item data-l10n-id="mztabrow-forget-about-this-site"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-delete"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-forget-about-this-site"></panel-item>
<hr />
<panel-item data-l10n-id="mztabrow-open-in-window"></panel-item>
<panel-item data-l10n-id="mztabrow-open-in-private-window"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-open-in-window"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-open-in-private-window"></panel-item>
<hr />
<panel-item data-l10n-id="mztabrow-add-bookmark"></panel-item>
<panel-item data-l10n-id="mztabrow-save-to-pocket"></panel-item>
<panel-item data-l10n-id="mztabrow-copy-link"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-add-bookmark"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-save-to-pocket"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-copy-link"></panel-item>
</panel-list>
</moz-tab-list>
</fxview-tab-list>
</div>
<pre id="test">
<script class="testbody" type="application/javascript">
@ -61,7 +61,7 @@
"resource://testing-common/TestUtils.jsm"
);
const mozTabList = document.querySelector("moz-tab-list");
const fxviewTabList = document.querySelector("fxview-tab-list");
let tabItems = [];
const placesQuery = new PlacesQuery();
@ -118,31 +118,31 @@
await historyUpdated.promise;
let normalized = normalizeHistoryData(history);
mozTabList.tabItems = normalized;
fxviewTabList.tabItems = normalized;
await mozTabList.getUpdateComplete();
tabItems = Array.from(mozTabList.rowEls);
await fxviewTabList.getUpdateComplete();
tabItems = Array.from(fxviewTabList.rowEls);
}
function normalizeHistoryData(history) {
history.forEach(historyItem => {
historyItem.time = historyItem.date.getTime();
historyItem.icon = `page-icon:${historyItem.url}`;
historyItem.primaryL10nId = "mztabrow-tabs-list-tab";
historyItem.primaryL10nId = "fxviewtabrow-tabs-list-tab";
historyItem.primaryL10nArgs = JSON.stringify({ targetURI: historyItem.url });
historyItem.secondaryL10nId = "mztabrow-open-menu-button";
historyItem.secondaryL10nId = "fxviewtabrow-open-menu-button";
});
return history;
}
function getCurrentDisplayDate() {
let lastItemMainEl = tabItems[tabItems.length - 1].mainEl;
return lastItemMainEl.querySelector("#moz-tab-row-date span:not([hidden])")?.textContent.trim() ?? "";
return lastItemMainEl.querySelector("#fxview-tab-row-date span:not([hidden])")?.textContent.trim() ?? "";
}
function getCurrentDisplayTime() {
let lastItemMainEl = tabItems[tabItems.length - 1].mainEl;
return lastItemMainEl.querySelector("#moz-tab-row-time")?.textContent.trim() ?? "";
return lastItemMainEl.querySelector("#fxview-tab-row-time")?.textContent.trim() ?? "";
}
function isActiveElement(expectedLinkEl) {
@ -159,8 +159,8 @@
}
add_setup(function setup() {
mozTabList.addEventListener("moz-tab-list-primary-action", onPrimaryAction);
mozTabList.addEventListener("moz-tab-list-secondary-action", onSecondaryAction);
fxviewTabList.addEventListener("fxview-tab-list-primary-action", onPrimaryAction);
fxviewTabList.addEventListener("fxview-tab-list-secondary-action", onSecondaryAction);
});
/**
@ -177,12 +177,12 @@
// Check ordering
ok(
tabItems[0].title === "Example Domain 4",
"First history item in moz-tab-list is in the correct order."
"First history item in fxview-tab-list is in the correct order."
)
ok(
tabItems[3].title === "Example Domain 1",
"Last history item in moz-tab-list is in the correct order."
"Last history item in fxview-tab-list is in the correct order."
)
});
@ -206,19 +206,19 @@
});
/**
* Tests that a max tabs length value can be given to moz-tab-list
* Tests that a max tabs length value can be given to fxview-tab-list
*/
add_task(async function test_max_list_items() {
const mockMaxTabsLength = 3;
// override this value for testing purposes
mozTabList.maxTabsLength = mockMaxTabsLength;
fxviewTabList.maxTabsLength = mockMaxTabsLength;
await addHistoryItems();
is(
tabItems.length,
mockMaxTabsLength,
`moz-tabs-list should have ${mockMaxTabsLength} list items`
`fxview-tabs-list should have ${mockMaxTabsLength} list items`
);
// Add new history items
@ -242,48 +242,48 @@
"Five total history items after inserting another node"
);
// Update moz-tab-list component with latest history data
// Update fxview-tab-list component with latest history data
let normalized = normalizeHistoryData(history);
mozTabList.tabItems = normalized;
await mozTabList.getUpdateComplete();
tabItems = Array.from(mozTabList.rowEls);
fxviewTabList.tabItems = normalized;
await fxviewTabList.getUpdateComplete();
tabItems = Array.from(fxviewTabList.rowEls);
is(
tabItems.length,
mockMaxTabsLength,
`moz-tabs-list should have ${mockMaxTabsLength} list items`
`fxview-tabs-list should have ${mockMaxTabsLength} list items`
);
ok(
tabItems[0].title === "Internet for people, not profits - Mozilla",
"History list has been updated with the expected maxTabsLength."
)
mozTabList.maxTabsLength = 25;
fxviewTabList.maxTabsLength = 25;
});
/**
* Tests keyboard navigation of the moz-tab-list component
* Tests keyboard navigation of the fxview-tab-list component
*/
add_task(async function test_keyboard_navigation() {
const arrowDown = async () => {
info("Arrow down");
synthesizeKey("KEY_ArrowDown", {});
await mozTabList.getUpdateComplete();
await fxviewTabList.getUpdateComplete();
};
const arrowUp = async () => {
info("Arrow up");
synthesizeKey("KEY_ArrowUp", {});
await mozTabList.getUpdateComplete();
await fxviewTabList.getUpdateComplete();
};
const arrowRight = async () => {
info("Arrow right");
synthesizeKey("KEY_ArrowRight", {});
await mozTabList.getUpdateComplete();
await fxviewTabList.getUpdateComplete();
};
const arrowLeft = async () => {
info("Arrow left");
synthesizeKey("KEY_ArrowLeft", {});
await mozTabList.getUpdateComplete();
await fxviewTabList.getUpdateComplete();
};
await addHistoryItems();
@ -347,7 +347,7 @@
});
/**
* Tests relative time format for the moz-tab-list component
* Tests relative time format for the fxview-tab-list component
*/
add_task(async function test_relative_format() {
await addHistoryItems();
@ -362,14 +362,14 @@
});
/**
* Tests date only format for the moz-tab-list component
* Tests date only format for the fxview-tab-list component
*/
add_task(async function test_date_only_format() {
await addHistoryItems();
// Check date only format
mozTabList.dateTimeFormat = "date";
await mozTabList.getUpdateComplete();
fxviewTabList.dateTimeFormat = "date";
await fxviewTabList.getUpdateComplete();
await BrowserTestUtils.waitForCondition(() => {
return getCurrentDisplayDate().includes("/");
});
@ -384,14 +384,14 @@
});
/**
* Tests time only format for the moz-tab-list component
* Tests time only format for the fxview-tab-list component
*/
add_task(async function test_time_only_format() {
await addHistoryItems();
// Check time only format
mozTabList.dateTimeFormat = "time";
await mozTabList.getUpdateComplete();
fxviewTabList.dateTimeFormat = "time";
await fxviewTabList.getUpdateComplete();
await BrowserTestUtils.waitForCondition(() => {
return getCurrentDisplayTime().includes("AM") || getCurrentDisplayTime().includes("PM");
});
@ -406,14 +406,14 @@
});
/**
* Tests date and time format for the moz-tab-list component
* Tests date and time format for the fxview-tab-list component
*/
add_task(async function test_date_and_time_format() {
await addHistoryItems();
// Check date and time format
mozTabList.dateTimeFormat = "dateTime";
await mozTabList.getUpdateComplete();
fxviewTabList.dateTimeFormat = "dateTime";
await fxviewTabList.getUpdateComplete();
await BrowserTestUtils.waitForCondition(() => {
return getCurrentDisplayDate().includes("/") &&
(getCurrentDisplayTime().includes("AM") || getCurrentDisplayTime().includes("PM"));
@ -428,12 +428,12 @@
);
// Reset dateTimeFormat to relative before next test
mozTabList.dateTimeFormat = "relative";
await mozTabList.getUpdateComplete();
fxviewTabList.dateTimeFormat = "relative";
await fxviewTabList.getUpdateComplete();
});
/**
* Tests that relative time updates properly for the moz-tab-list component
* Tests that relative time updates properly for the fxview-tab-list component
*/
add_task(async function test_relative_time_updates() {
await addHistoryItems();

Просмотреть файл

@ -4,7 +4,7 @@
import { html } from "lit.all.mjs";
// eslint-disable-next-line import/no-unassigned-import
import "browser/components/firefoxview/moz-tab-list.mjs";
import "browser/components/firefoxview/fxview-tab-list.mjs";
const DATE_TIME_FORMATS = {
relative: "relative",
@ -14,8 +14,8 @@ const DATE_TIME_FORMATS = {
};
export default {
title: "Domain-specific UI Widgets/Tab List",
component: "moz-tab-list",
title: "Domain-specific UI Widgets/Firefox View/Tab List",
component: "fxview-tab-list",
argTypes: {
dateTimeFormat: {
options: Object.keys(DATE_TIME_FORMATS),
@ -38,10 +38,10 @@ const Template = ({
main {
max-width: 750px;
}
moz-tab-list.menu::part(secondary-button) {
fxview-tab-list.menu::part(secondary-button) {
background-image: url("chrome://global/skin/icons/more.svg");
}
moz-tab-list.dismiss::part(secondary-button) {
fxview-tab-list.dismiss::part(secondary-button) {
background-image: url("chrome://global/skin/icons/close.svg");
}
:host panel-item::part(button) {
@ -50,27 +50,31 @@ const Template = ({
}
</style>
<main>
<moz-tab-list
<fxview-tab-list
class=${listClass}
.hasPopup=${hasPopup}
.dateTimeFormat=${dateTimeFormat}
.maxTabsLength=${maxTabsLength}
.tabItems=${tabItems}
@moz-tab-list-secondary-action=${secondaryAction}
@moz-tab-list-primary-action=${primaryAction}
@fxview-tab-list-secondary-action=${secondaryAction}
@fxview-tab-list-primary-action=${primaryAction}
>
<panel-list slot="menu">
<panel-item data-l10n-id="mztabrow-delete"></panel-item>
<panel-item data-l10n-id="mztabrow-forget-about-this-site"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-delete"></panel-item>
<panel-item
data-l10n-id="fxviewtabrow-forget-about-this-site"
></panel-item>
<hr />
<panel-item data-l10n-id="mztabrow-open-in-window"></panel-item>
<panel-item data-l10n-id="mztabrow-open-in-private-window"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-open-in-window"></panel-item>
<panel-item
data-l10n-id="fxviewtabrow-open-in-private-window"
></panel-item>
<hr />
<panel-item data-l10n-id="mztabrow-add-bookmark"></panel-item>
<panel-item data-l10n-id="mztabrow-save-to-pocket"></panel-item>
<panel-item data-l10n-id="mztabrow-copy-link"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-add-bookmark"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-save-to-pocket"></panel-item>
<panel-item data-l10n-id="fxviewtabrow-copy-link"></panel-item>
</panel-list>
</moz-tab-list>
</fxview-tab-list>
</main>
`;
@ -90,27 +94,27 @@ const tabItems = [
title: "Example Domain",
url: "example.net",
time: 1678141738136,
primaryL10nId: "mztabrow-tabs-list-tab",
primaryL10nId: "fxviewtabrow-tabs-list-tab",
primaryL10nArgs: JSON.stringify({ targetURI: "example.net" }),
secondaryL10nId: "mztabrow-open-menu-button",
secondaryL10nId: "fxviewtabrow-open-menu-button",
},
{
icon: "chrome://global/skin/icons/defaultFavicon.svg",
title: "Example Domain",
url: "example.org",
time: 1678141738136,
primaryL10nId: "mztabrow-tabs-list-tab",
primaryL10nId: "fxviewtabrow-tabs-list-tab",
primaryL10nArgs: JSON.stringify({ targetURI: "example.org" }),
secondaryL10nId: "mztabrow-open-menu-button",
secondaryL10nId: "fxviewtabrow-open-menu-button",
},
{
icon: "chrome://global/skin/icons/defaultFavicon.svg",
title: "Example Domain",
url: "example.com",
time: 1678141738136,
primaryL10nId: "mztabrow-tabs-list-tab",
primaryL10nId: "fxviewtabrow-tabs-list-tab",
primaryL10nArgs: JSON.stringify({ targetURI: "example.com" }),
secondaryL10nId: "mztabrow-open-menu-button",
secondaryL10nId: "fxviewtabrow-open-menu-button",
},
];
const recentlyClosedItems = [
@ -120,9 +124,9 @@ const recentlyClosedItems = [
url: "example.net",
tabid: 1,
time: 1678141738136,
primaryL10nId: "mztabrow-tabs-list-tab",
primaryL10nId: "fxviewtabrow-tabs-list-tab",
primaryL10nArgs: JSON.stringify({ targetURI: "example.net" }),
secondaryL10nId: "mztabrow-dismiss-tab-button",
secondaryL10nId: "fxviewtabrow-dismiss-tab-button",
secondaryL10nArgs: JSON.stringify({
tabTitle: "Example Domain",
}),
@ -133,9 +137,9 @@ const recentlyClosedItems = [
url: "example.org",
tabid: 2,
time: 1678141738136,
primaryL10nId: "mztabrow-tabs-list-tab",
primaryL10nId: "fxviewtabrow-tabs-list-tab",
primaryL10nArgs: JSON.stringify({ targetURI: "example.net" }),
secondaryL10nId: "mztabrow-dismiss-tab-button",
secondaryL10nId: "fxviewtabrow-dismiss-tab-button",
secondaryL10nArgs: JSON.stringify({
tabTitle: "Example Domain",
}),
@ -146,9 +150,9 @@ const recentlyClosedItems = [
url: "example.com",
tabid: 3,
time: 1678141738136,
primaryL10nId: "mztabrow-tabs-list-tab",
primaryL10nId: "fxviewtabrow-tabs-list-tab",
primaryL10nArgs: JSON.stringify({ targetURI: "example.net" }),
secondaryL10nId: "mztabrow-dismiss-tab-button",
secondaryL10nId: "fxviewtabrow-dismiss-tab-button",
secondaryL10nArgs: JSON.stringify({
tabTitle: "Example Domain",
}),

Просмотреть файл

@ -2,45 +2,45 @@
# 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/.
mztabrow-open-menu-button =
fxviewtabrow-open-menu-button =
.title = Open menu
# Variables:
# $date (string) - Date to be formatted based on locale
mztabrow-date = { DATETIME($date, dateStyle: "short") }
fxviewtabrow-date = { DATETIME($date, dateStyle: "short") }
# Variables:
# $time (string) - Time to be formatted based on locale
mztabrow-time = { DATETIME($time, timeStyle: "short") }
fxviewtabrow-time = { DATETIME($time, timeStyle: "short") }
# Variables:
# $targetURI (string) - URL of tab that will be opened in the new tab
mztabrow-tabs-list-tab =
fxviewtabrow-tabs-list-tab =
.title = Open { $targetURI } in a new tab
# Variables:
# $tabTitle (string) - Title of tab being dismissed
mztabrow-dismiss-tab-button =
fxviewtabrow-dismiss-tab-button =
.title = Dismiss { $tabTitle }
# Used instead of the localized relative time when a timestamp is within a minute or so of now
mztabrow-just-now-timestamp = Just now
fxviewtabrow-just-now-timestamp = Just now
# Strings below are used for context menu options within panel-list.
# For developers, this duplicates command because the label attribute is required.
mztabrow-delete = Delete
fxviewtabrow-delete = Delete
.accesskey = D
mztabrow-forget-about-this-site = Forget About This Site…
fxviewtabrow-forget-about-this-site = Forget About This Site…
.accesskey = F
mztabrow-open-in-window = Open in New Window
fxviewtabrow-open-in-window = Open in New Window
.accesskey = N
mztabrow-open-in-private-window = Open in New Private Window
fxviewtabrow-open-in-private-window = Open in New Private Window
.accesskey = P
# “Bookmark” is a verb, as in "Bookmark this page" (add to bookmarks).
mztabrow-add-bookmark = Bookmark…
fxviewtabrow-add-bookmark = Bookmark…
.accesskey = B
mztabrow-save-to-pocket = Save to { -pocket-brand-name }
fxviewtabrow-save-to-pocket = Save to { -pocket-brand-name }
.accesskey = o
mztabrow-copy-link = Copy Link
fxviewtabrow-copy-link = Copy Link
.accesskey = L

Просмотреть файл

@ -0,0 +1,44 @@
# coding=utf8
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
from fluent.migrate.helpers import transforms_from
from fluent.migrate import COPY
def migrate(ctx):
"""Bug 1833228 - Remove "moz-" from moz-tab-list component and associated .ftl, .css files, part {index}."""
ctx.add_transforms(
"browser/browser/fxviewTabList.ftl",
"browser/browser/fxviewTabList.ftl",
transforms_from(
"""
fxviewtabrow-open-menu-button =
.title = {COPY_PATTERN(from_path, "mztabrow-open-menu-button.title")}
fxviewtabrow-date = {COPY_PATTERN(from_path, "mztabrow-date")}
fxviewtabrow-time = {COPY_PATTERN(from_path, "mztabrow-time")}
fxviewtabrow-tabs-list-tab =
.title = {COPY_PATTERN(from_path, "mztabrow-tabs-list-tab.title")}
fxviewtabrow-dismiss-tab-button =
.title = {COPY_PATTERN(from_path, "mztabrow-dismiss-tab-button.title")}
fxviewtabrow-just-now-timestamp = {COPY_PATTERN(from_path, "mztabrow-just-now-timestamp")}
fxviewtabrow-delete = {COPY_PATTERN(from_path, "mztabrow-delete")}
.accesskey = {COPY_PATTERN(from_path, "mztabrow-delete.accesskey")}
fxviewtabrow-forget-about-this-site = {COPY_PATTERN(from_path, "mztabrow-forget-about-this-site")}
.accesskey = {COPY_PATTERN(from_path, "mztabrow-forget-about-this-site.accesskey")}
fxviewtabrow-open-in-window = {COPY_PATTERN(from_path, "mztabrow-open-in-window")}
.accesskey = {COPY_PATTERN(from_path, "mztabrow-open-in-window.accesskey")}
fxviewtabrow-open-in-private-window = {COPY_PATTERN(from_path, "mztabrow-open-in-private-window")}
.accesskey = {COPY_PATTERN(from_path, "mztabrow-open-in-private-window.accesskey")}
fxviewtabrow-add-bookmark = {COPY_PATTERN(from_path, "mztabrow-add-bookmark")}
.accesskey = {COPY_PATTERN(from_path, "mztabrow-add-bookmark.accesskey")}
fxviewtabrow-save-to-pocket = {COPY_PATTERN(from_path, "mztabrow-save-to-pocket")}
.accesskey = {COPY_PATTERN(from_path, "mztabrow-save-to-pocket.accesskey")}
fxviewtabrow-copy-link = {COPY_PATTERN(from_path, "mztabrow-copy-link")}
.accesskey = {COPY_PATTERN(from_path, "mztabrow-copy-link.accesskey")}
""",
from_path="browser/browser/mozTabList.ftl",
),
)