Upstream mozilla-firefox/firefox state of the touched files before eb0738e2cb
This commit is contained in:
commit
8a12eaac21
3 files changed
+2157
No files matched your search
@@ -0,0 +1,456 @@
|
|||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
const lazy = {};
|
||||||
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
||||||
|
SyncedTabsController: "resource:///modules/SyncedTabsController.sys.mjs",
|
||||||
|
});
|
||||||
|
|
||||||
|
const { TabsSetupFlowManager } = ChromeUtils.importESModule(
|
||||||
|
"resource:///modules/firefox-view-tabs-setup-manager.sys.mjs"
|
||||||
|
);
|
||||||
|
|
||||||
|
import {
|
||||||
|
html,
|
||||||
|
ifDefined,
|
||||||
|
when,
|
||||||
|
} from "chrome://global/content/vendor/lit.all.mjs";
|
||||||
|
import { ViewPage } from "./viewpage.mjs";
|
||||||
|
import {
|
||||||
|
escapeHtmlEntities,
|
||||||
|
MAX_TABS_FOR_RECENT_BROWSING,
|
||||||
|
navigateToLink,
|
||||||
|
} from "./helpers.mjs";
|
||||||
|
// eslint-disable-next-line import/no-unassigned-import
|
||||||
|
import "chrome://browser/content/firefoxview/syncedtabs-tab-list.mjs";
|
||||||
|
// eslint-disable-next-line import/no-unassigned-import
|
||||||
|
import "chrome://global/content/elements/moz-button.mjs";
|
||||||
|
|
||||||
|
const UI_OPEN_STATE = "browser.tabs.firefox-view.ui-state.tab-pickup.open";
|
||||||
|
|
||||||
|
class SyncedTabsInView extends ViewPage {
|
||||||
|
controller = new lazy.SyncedTabsController(this, {
|
||||||
|
contextMenu: true,
|
||||||
|
pairDeviceCallback: () =>
|
||||||
|
Glean.firefoxviewNext.fxaMobileSync.record({
|
||||||
|
has_devices: TabsSetupFlowManager.secondaryDeviceConnected,
|
||||||
|
}),
|
||||||
|
signupCallback: () => Glean.firefoxviewNext.fxaContinueSync.record(),
|
||||||
|
});
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this._started = false;
|
||||||
|
this._id = Math.floor(Math.random() * 10e6);
|
||||||
|
if (this.recentBrowsing) {
|
||||||
|
this.maxTabsLength = MAX_TABS_FOR_RECENT_BROWSING;
|
||||||
|
} else {
|
||||||
|
// Setting maxTabsLength to -1 for no max
|
||||||
|
this.maxTabsLength = -1;
|
||||||
|
}
|
||||||
|
this.fullyUpdated = false;
|
||||||
|
this.showAll = false;
|
||||||
|
this.cumulativeSearches = 0;
|
||||||
|
this.onSearchQuery = this.onSearchQuery.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
static properties = {
|
||||||
|
...ViewPage.properties,
|
||||||
|
showAll: { type: Boolean },
|
||||||
|
cumulativeSearches: { type: Number },
|
||||||
|
};
|
||||||
|
|
||||||
|
static queries = {
|
||||||
|
cardEls: { all: "card-container" },
|
||||||
|
emptyState: "fxview-empty-state",
|
||||||
|
searchTextbox: "moz-input-search",
|
||||||
|
tabLists: { all: "syncedtabs-tab-list" },
|
||||||
|
};
|
||||||
|
|
||||||
|
start() {
|
||||||
|
if (this._started) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._started = true;
|
||||||
|
this.controller.addSyncObservers();
|
||||||
|
this.controller.updateStates();
|
||||||
|
this.onVisibilityChange();
|
||||||
|
|
||||||
|
if (this.recentBrowsing) {
|
||||||
|
this.recentBrowsingElement.addEventListener(
|
||||||
|
"MozInputSearch:search",
|
||||||
|
this.onSearchQuery
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
if (!this._started) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._started = false;
|
||||||
|
TabsSetupFlowManager.updateViewVisibility(this._id, "unloaded");
|
||||||
|
this.onVisibilityChange();
|
||||||
|
this.controller.removeSyncObservers();
|
||||||
|
|
||||||
|
if (this.recentBrowsing) {
|
||||||
|
this.recentBrowsingElement.removeEventListener(
|
||||||
|
"MozInputSearch:search",
|
||||||
|
this.onSearchQuery
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
viewVisibleCallback() {
|
||||||
|
this.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
viewHiddenCallback() {
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
onVisibilityChange() {
|
||||||
|
const isOpen = this.open;
|
||||||
|
const isVisible = this.isVisible;
|
||||||
|
if (isVisible && isOpen) {
|
||||||
|
this.update();
|
||||||
|
TabsSetupFlowManager.updateViewVisibility(this._id, "visible");
|
||||||
|
} else {
|
||||||
|
TabsSetupFlowManager.updateViewVisibility(
|
||||||
|
this._id,
|
||||||
|
isVisible ? "closed" : "hidden"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.toggleVisibilityInCardContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
generateMessageCard({
|
||||||
|
action,
|
||||||
|
buttonLabel,
|
||||||
|
descriptionArray,
|
||||||
|
descriptionLink,
|
||||||
|
header,
|
||||||
|
mainImageUrl,
|
||||||
|
}) {
|
||||||
|
return html`
|
||||||
|
<fxview-empty-state
|
||||||
|
headerLabel=${header}
|
||||||
|
.descriptionLabels=${descriptionArray}
|
||||||
|
.descriptionLink=${ifDefined(descriptionLink)}
|
||||||
|
class="empty-state synced-tabs error"
|
||||||
|
?isSelectedTab=${this.selectedTab}
|
||||||
|
?isInnerCard=${this.recentBrowsing}
|
||||||
|
mainImageUrl=${ifDefined(mainImageUrl)}
|
||||||
|
id="empty-container"
|
||||||
|
>
|
||||||
|
<moz-button
|
||||||
|
class="primary"
|
||||||
|
type="primary"
|
||||||
|
slot="primary-action"
|
||||||
|
?hidden=${!buttonLabel}
|
||||||
|
data-l10n-id=${ifDefined(buttonLabel)}
|
||||||
|
data-action=${action}
|
||||||
|
@click=${e => this.controller.handleEvent(e)}
|
||||||
|
></moz-button>
|
||||||
|
</fxview-empty-state>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
onOpenLink(event) {
|
||||||
|
navigateToLink(event);
|
||||||
|
|
||||||
|
Glean.firefoxviewNext.syncedTabsTabs.record({
|
||||||
|
page: this.recentBrowsing ? "recentbrowsing" : "syncedtabs",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.controller.searchQuery) {
|
||||||
|
Glean.firefoxview.cumulativeSearches[
|
||||||
|
this.recentBrowsing ? "recentbrowsing" : "syncedtabs"
|
||||||
|
].accumulateSingleSample(this.cumulativeSearches);
|
||||||
|
this.cumulativeSearches = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onContextMenu(e) {
|
||||||
|
this.triggerNode = e.originalTarget;
|
||||||
|
e.target.querySelector("panel-list").toggle(e.detail.originalEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCloseTab(e) {
|
||||||
|
const { url, fxaDeviceId, tertiaryActionClass } = e.originalTarget;
|
||||||
|
if (tertiaryActionClass === "dismiss-button") {
|
||||||
|
// Set new pending close tab
|
||||||
|
this.controller.requestCloseRemoteTab(fxaDeviceId, url);
|
||||||
|
} else if (tertiaryActionClass === "undo-button") {
|
||||||
|
// User wants to undo
|
||||||
|
this.controller.removePendingTabToClose(fxaDeviceId, url);
|
||||||
|
}
|
||||||
|
this.requestUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
panelListTemplate() {
|
||||||
|
return html`
|
||||||
|
<panel-list slot="menu" data-tab-type="syncedtabs">
|
||||||
|
<panel-item
|
||||||
|
@click=${this.openInNewWindow}
|
||||||
|
data-l10n-id="fxviewtabrow-open-in-window"
|
||||||
|
data-l10n-attrs="accesskey"
|
||||||
|
></panel-item>
|
||||||
|
<panel-item
|
||||||
|
@click=${this.openInNewPrivateWindow}
|
||||||
|
data-l10n-id="fxviewtabrow-open-in-private-window"
|
||||||
|
data-l10n-attrs="accesskey"
|
||||||
|
?hidden=${!lazy.PrivateBrowsingUtils.enabled}
|
||||||
|
></panel-item>
|
||||||
|
<hr />
|
||||||
|
<panel-item
|
||||||
|
@click=${this.copyLink}
|
||||||
|
data-l10n-id="fxviewtabrow-copy-link"
|
||||||
|
data-l10n-attrs="accesskey"
|
||||||
|
></panel-item>
|
||||||
|
</panel-list>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
noDeviceTabsTemplate(deviceName, deviceType, isSearchResultsEmpty = false) {
|
||||||
|
const template = html`<h3
|
||||||
|
slot=${ifDefined(this.recentBrowsing ? null : "header")}
|
||||||
|
class="device-header"
|
||||||
|
>
|
||||||
|
<span class="icon ${deviceType}" role="presentation"></span>
|
||||||
|
${deviceName}
|
||||||
|
</h3>
|
||||||
|
${when(
|
||||||
|
isSearchResultsEmpty,
|
||||||
|
() => html`
|
||||||
|
<div
|
||||||
|
slot=${ifDefined(this.recentBrowsing ? null : "main")}
|
||||||
|
class="blackbox notabs search-results-empty"
|
||||||
|
data-l10n-id="firefoxview-search-results-empty"
|
||||||
|
data-l10n-args=${JSON.stringify({
|
||||||
|
query: escapeHtmlEntities(this.controller.searchQuery),
|
||||||
|
})}
|
||||||
|
></div>
|
||||||
|
`,
|
||||||
|
() => html`
|
||||||
|
<div
|
||||||
|
slot=${ifDefined(this.recentBrowsing ? null : "main")}
|
||||||
|
class="blackbox notabs"
|
||||||
|
data-l10n-id="firefoxview-syncedtabs-device-notabs"
|
||||||
|
></div>
|
||||||
|
`
|
||||||
|
)}`;
|
||||||
|
return this.recentBrowsing
|
||||||
|
? template
|
||||||
|
: html`<card-container
|
||||||
|
shortPageName=${this.recentBrowsing ? "syncedtabs" : null}
|
||||||
|
>${template}</card-container
|
||||||
|
>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSearchQuery(e) {
|
||||||
|
if (!this.recentBrowsing) {
|
||||||
|
Glean.firefoxviewNext.searchInitiatedSearch.record({
|
||||||
|
page: "syncedtabs",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.controller.searchQuery = e.detail.query;
|
||||||
|
this.cumulativeSearches = e.detail.query ? this.cumulativeSearches + 1 : 0;
|
||||||
|
this.showAll = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceTemplate(deviceName, deviceType, tabItems) {
|
||||||
|
return html`<h3
|
||||||
|
slot=${!this.recentBrowsing ? "header" : null}
|
||||||
|
class="device-header"
|
||||||
|
>
|
||||||
|
<span class="icon ${deviceType}" role="presentation"></span>
|
||||||
|
${deviceName}
|
||||||
|
</h3>
|
||||||
|
<syncedtabs-tab-list
|
||||||
|
slot="main"
|
||||||
|
.hasPopup=${"menu"}
|
||||||
|
.tabItems=${ifDefined(tabItems)}
|
||||||
|
.searchQuery=${this.controller.searchQuery}
|
||||||
|
.maxTabsLength=${this.showAll ? -1 : this.maxTabsLength}
|
||||||
|
@fxview-tab-list-primary-action=${this.onOpenLink}
|
||||||
|
@fxview-tab-list-secondary-action=${this.onContextMenu}
|
||||||
|
@fxview-tab-list-tertiary-action=${this.onCloseTab}
|
||||||
|
secondaryActionClass="options-button"
|
||||||
|
>
|
||||||
|
${this.panelListTemplate()}
|
||||||
|
</syncedtabs-tab-list>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
generateTabList() {
|
||||||
|
let renderArray = [];
|
||||||
|
let renderInfo = this.controller.getRenderInfo();
|
||||||
|
for (let id in renderInfo) {
|
||||||
|
let tabItems = renderInfo[id].tabItems;
|
||||||
|
if (tabItems.length) {
|
||||||
|
const template = this.recentBrowsing
|
||||||
|
? this.deviceTemplate(
|
||||||
|
renderInfo[id].name,
|
||||||
|
renderInfo[id].deviceType,
|
||||||
|
tabItems
|
||||||
|
)
|
||||||
|
: html`<card-container
|
||||||
|
shortPageName=${this.recentBrowsing ? "syncedtabs" : null}
|
||||||
|
>${this.deviceTemplate(
|
||||||
|
renderInfo[id].name,
|
||||||
|
renderInfo[id].deviceType,
|
||||||
|
tabItems
|
||||||
|
)}
|
||||||
|
</card-container>`;
|
||||||
|
renderArray.push(template);
|
||||||
|
if (this.isShowAllLinkVisible(tabItems)) {
|
||||||
|
renderArray.push(
|
||||||
|
html` <div class="show-all-link-container">
|
||||||
|
<div
|
||||||
|
class="show-all-link"
|
||||||
|
@click=${this.enableShowAll}
|
||||||
|
@keydown=${this.enableShowAll}
|
||||||
|
data-l10n-id="firefoxview-show-all"
|
||||||
|
tabindex="0"
|
||||||
|
role="link"
|
||||||
|
></div>
|
||||||
|
</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Check renderInfo[id].tabs.length to determine whether to display an
|
||||||
|
// empty tab list message or empty search results message.
|
||||||
|
// If there are no synced tabs, we always display the empty tab list
|
||||||
|
// message, even if there is an active search query.
|
||||||
|
renderArray.push(
|
||||||
|
this.noDeviceTabsTemplate(
|
||||||
|
renderInfo[id].name,
|
||||||
|
renderInfo[id].deviceType,
|
||||||
|
Boolean(renderInfo[id].tabs.length)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return renderArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
isShowAllLinkVisible(tabItems) {
|
||||||
|
return (
|
||||||
|
this.recentBrowsing &&
|
||||||
|
this.controller.searchQuery &&
|
||||||
|
tabItems.length > this.maxTabsLength &&
|
||||||
|
!this.showAll
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
enableShowAll(event) {
|
||||||
|
if (
|
||||||
|
event.type == "click" ||
|
||||||
|
(event.type == "keydown" && event.code == "Enter") ||
|
||||||
|
(event.type == "keydown" && event.code == "Space")
|
||||||
|
) {
|
||||||
|
event.preventDefault();
|
||||||
|
this.showAll = true;
|
||||||
|
Glean.firefoxviewNext.searchShowAllShowallbutton.record({
|
||||||
|
section: "syncedtabs",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
generateCardContent() {
|
||||||
|
const cardProperties = this.controller.getMessageCard();
|
||||||
|
return cardProperties
|
||||||
|
? this.generateMessageCard(cardProperties)
|
||||||
|
: this.generateTabList();
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
this.open =
|
||||||
|
!TabsSetupFlowManager.isTabSyncSetupComplete ||
|
||||||
|
Services.prefs.getBoolPref(UI_OPEN_STATE, true);
|
||||||
|
|
||||||
|
let renderArray = [];
|
||||||
|
renderArray.push(
|
||||||
|
html` <link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="chrome://browser/content/firefoxview/view-syncedtabs.css"
|
||||||
|
/>`
|
||||||
|
);
|
||||||
|
renderArray.push(
|
||||||
|
html` <link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="chrome://browser/content/firefoxview/firefoxview.css"
|
||||||
|
/>`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!this.recentBrowsing) {
|
||||||
|
renderArray.push(
|
||||||
|
html`<div class="sticky-container bottom-fade">
|
||||||
|
<h2
|
||||||
|
class="page-header"
|
||||||
|
data-l10n-id="firefoxview-synced-tabs-header"
|
||||||
|
></h2>
|
||||||
|
<div class="syncedtabs-header">
|
||||||
|
<div>
|
||||||
|
<moz-input-search
|
||||||
|
data-l10n-id="firefoxview-search-text-box-tabs"
|
||||||
|
data-l10n-attrs="placeholder"
|
||||||
|
@MozInputSearch:search=${this.onSearchQuery}
|
||||||
|
></moz-input-search>
|
||||||
|
</div>
|
||||||
|
${when(
|
||||||
|
this.controller.currentSetupStateIndex === 4,
|
||||||
|
() => html`
|
||||||
|
<moz-button
|
||||||
|
iconSrc="chrome://global/skin/icons/plus.svg"
|
||||||
|
data-l10n-id="firefoxview-syncedtabs-connect-another-device"
|
||||||
|
data-action="add-device"
|
||||||
|
@click=${e => this.controller.handleEvent(e)}
|
||||||
|
></moz-button>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.recentBrowsing) {
|
||||||
|
renderArray.push(
|
||||||
|
html`<card-container
|
||||||
|
preserveCollapseState
|
||||||
|
shortPageName="syncedtabs"
|
||||||
|
?showViewAll=${this.controller.currentSetupStateIndex == 4 &&
|
||||||
|
this.controller.currentSyncedTabs.length}
|
||||||
|
?isEmptyState=${!this.controller.currentSyncedTabs.length}
|
||||||
|
>
|
||||||
|
>
|
||||||
|
<h3
|
||||||
|
slot="header"
|
||||||
|
data-l10n-id="firefoxview-synced-tabs-header"
|
||||||
|
class="recentbrowsing-header"
|
||||||
|
></h3>
|
||||||
|
<div slot="main">${this.generateCardContent()}</div>
|
||||||
|
</card-container>`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
renderArray.push(
|
||||||
|
html`<div class="cards-container">${this.generateCardContent()}</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return renderArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
updated() {
|
||||||
|
this.fullyUpdated = true;
|
||||||
|
this.toggleVisibilityInCardContainer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
customElements.define("view-syncedtabs", SyncedTabsInView);
|
||||||
@@ -0,0 +1,610 @@
|
|||||||
|
let gInitialTab;
|
||||||
|
let gInitialTabURL;
|
||||||
|
|
||||||
|
const NUMBER_OF_TABS = 6;
|
||||||
|
|
||||||
|
const syncedTabsData = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: "This Device",
|
||||||
|
isCurrentDevice: true,
|
||||||
|
type: "desktop",
|
||||||
|
tabs: Array(NUMBER_OF_TABS)
|
||||||
|
.fill({
|
||||||
|
type: "tab",
|
||||||
|
title: "Internet for people, not profits - Mozilla",
|
||||||
|
icon: "https://www.mozilla.org/media/img/favicons/mozilla/favicon.d25d81d39065.ico",
|
||||||
|
client: 1,
|
||||||
|
})
|
||||||
|
.map((tab, i) => ({ ...tab, url: URLs[i] })),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const cleanUp = () => {
|
||||||
|
while (gBrowser.tabs.length > 1) {
|
||||||
|
BrowserTestUtils.removeTab(gBrowser.tabs.at(-1));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
add_setup(async () => {
|
||||||
|
gInitialTab = gBrowser.selectedTab;
|
||||||
|
gInitialTabURL = gBrowser.selectedBrowser.currentURI.spec;
|
||||||
|
registerCleanupFunction(async () => {
|
||||||
|
clearHistory();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_search_initiated_telemetry() {
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
|
||||||
|
is(document.location.hash, "", "Searching within recent browsing.");
|
||||||
|
const recentBrowsing = document.querySelector("view-recentbrowsing");
|
||||||
|
info("Input a search query");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
recentBrowsing.searchTextbox,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
EventUtils.sendString("example.com", content);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => Glean.firefoxviewNext.searchInitiatedSearch.testGetValue(),
|
||||||
|
"Awaiting search to be reported."
|
||||||
|
);
|
||||||
|
let searchEvents =
|
||||||
|
Glean.firefoxviewNext.searchInitiatedSearch.testGetValue();
|
||||||
|
Assert.equal(1, searchEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ page: "recentbrowsing" }, searchEvents[0].extra);
|
||||||
|
|
||||||
|
await navigateToViewAndWait(document, "opentabs");
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
is(document.location.hash, "#opentabs", "Searching within open tabs.");
|
||||||
|
const openTabs = document.querySelector("named-deck > view-opentabs");
|
||||||
|
info("Input a search query");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(openTabs.searchTextbox, {}, content);
|
||||||
|
EventUtils.sendString("example.com", content);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => Glean.firefoxviewNext.searchInitiatedSearch.testGetValue(),
|
||||||
|
"Awaiting search to be reported."
|
||||||
|
);
|
||||||
|
searchEvents = Glean.firefoxviewNext.searchInitiatedSearch.testGetValue();
|
||||||
|
Assert.equal(1, searchEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ page: "opentabs" }, searchEvents[0].extra);
|
||||||
|
|
||||||
|
await navigateToViewAndWait(document, "recentlyclosed");
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
is(
|
||||||
|
document.location.hash,
|
||||||
|
"#recentlyclosed",
|
||||||
|
"Searching within recently closed."
|
||||||
|
);
|
||||||
|
const recentlyClosed = document.querySelector(
|
||||||
|
"named-deck > view-recentlyclosed"
|
||||||
|
);
|
||||||
|
info("Input a search query");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
recentlyClosed.searchTextbox,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
EventUtils.sendString("example.com", content);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => Glean.firefoxviewNext.searchInitiatedSearch.testGetValue(),
|
||||||
|
"Awaiting search to be reported."
|
||||||
|
);
|
||||||
|
searchEvents = Glean.firefoxviewNext.searchInitiatedSearch.testGetValue();
|
||||||
|
Assert.equal(1, searchEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ page: "recentlyclosed" }, searchEvents[0].extra);
|
||||||
|
|
||||||
|
await navigateToViewAndWait(document, "syncedtabs");
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
is(document.location.hash, "#syncedtabs", "Searching within synced tabs.");
|
||||||
|
const syncedTabs = document.querySelector("named-deck > view-syncedtabs");
|
||||||
|
info("Input a search query");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(syncedTabs.searchTextbox, {}, content);
|
||||||
|
EventUtils.sendString("example.com", content);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => Glean.firefoxviewNext.searchInitiatedSearch.testGetValue(),
|
||||||
|
"Awaiting search to be reported."
|
||||||
|
);
|
||||||
|
searchEvents = Glean.firefoxviewNext.searchInitiatedSearch.testGetValue();
|
||||||
|
Assert.equal(1, searchEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ page: "syncedtabs" }, searchEvents[0].extra);
|
||||||
|
|
||||||
|
await navigateToViewAndWait(document, "history");
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
is(document.location.hash, "#history", "Searching within history.");
|
||||||
|
const history = document.querySelector("named-deck > view-history");
|
||||||
|
info("Input a search query");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(history.searchTextbox, {}, content);
|
||||||
|
EventUtils.sendString("example.com", content);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => Glean.firefoxviewNext.searchInitiatedSearch.testGetValue(),
|
||||||
|
"Awaiting search to be reported."
|
||||||
|
);
|
||||||
|
searchEvents = Glean.firefoxviewNext.searchInitiatedSearch.testGetValue();
|
||||||
|
Assert.equal(1, searchEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ page: "history" }, searchEvents[0].extra);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_show_all_recentlyclosed_telemetry() {
|
||||||
|
for (let i = 0; i < NUMBER_OF_TABS; i++) {
|
||||||
|
await open_then_close(URLs[1]);
|
||||||
|
}
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
const recentBrowsing = document.querySelector("view-recentbrowsing");
|
||||||
|
|
||||||
|
info("Input a search query.");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
recentBrowsing.searchTextbox,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
EventUtils.sendString("example.com", content);
|
||||||
|
const recentlyclosedSlot = recentBrowsing.querySelector(
|
||||||
|
"[slot='recentlyclosed']"
|
||||||
|
);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() =>
|
||||||
|
recentlyclosedSlot.tabList.rowEls.length === 5 &&
|
||||||
|
recentlyclosedSlot.shadowRoot.querySelector(
|
||||||
|
"[data-l10n-id='firefoxview-show-all']"
|
||||||
|
),
|
||||||
|
"Expected search results are not shown yet."
|
||||||
|
);
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
|
||||||
|
info("Click the Show All link.");
|
||||||
|
const showAllButton = recentlyclosedSlot.shadowRoot.querySelector(
|
||||||
|
"[data-l10n-id='firefoxview-show-all']"
|
||||||
|
);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => !showAllButton.hidden,
|
||||||
|
"Waiting for the show all button to be visible"
|
||||||
|
);
|
||||||
|
ok(!showAllButton.hidden, "Show all button is visible");
|
||||||
|
await TestUtils.waitForCondition(() => {
|
||||||
|
EventUtils.synthesizeMouseAtCenter(showAllButton, {}, content);
|
||||||
|
if (recentlyclosedSlot.tabList.rowEls.length === NUMBER_OF_TABS) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, "All search results are not shown.");
|
||||||
|
|
||||||
|
const searchEvents =
|
||||||
|
Glean.firefoxviewNext.searchShowAllShowallbutton.testGetValue();
|
||||||
|
Assert.equal(1, searchEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ section: "recentlyclosed" }, searchEvents[0].extra);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_show_all_opentabs_telemetry() {
|
||||||
|
for (let i = 0; i < NUMBER_OF_TABS; i++) {
|
||||||
|
await BrowserTestUtils.openNewForegroundTab(gBrowser, URLs[1]);
|
||||||
|
}
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
const recentBrowsing = document.querySelector("view-recentbrowsing");
|
||||||
|
|
||||||
|
info("Input a search query.");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
recentBrowsing.searchTextbox,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
EventUtils.sendString(URLs[1], content);
|
||||||
|
const opentabsSlot = recentBrowsing.querySelector("[slot='opentabs']");
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => opentabsSlot.viewCards[0].tabList.rowEls.length === 5,
|
||||||
|
"Expected search results are not shown yet."
|
||||||
|
);
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
|
||||||
|
info("Click the Show All link.");
|
||||||
|
const showAllButton = opentabsSlot.viewCards[0].shadowRoot.querySelector(
|
||||||
|
"[data-l10n-id='firefoxview-show-all']"
|
||||||
|
);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => !showAllButton.hidden,
|
||||||
|
"Waiting for the show all button to be visible"
|
||||||
|
);
|
||||||
|
ok(!showAllButton.hidden, "Show all button is visible");
|
||||||
|
await TestUtils.waitForCondition(() => {
|
||||||
|
EventUtils.synthesizeMouseAtCenter(showAllButton, {}, content);
|
||||||
|
if (opentabsSlot.viewCards[0].tabList.rowEls.length === NUMBER_OF_TABS) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, "All search results are not shown.");
|
||||||
|
|
||||||
|
const searchEvents =
|
||||||
|
Glean.firefoxviewNext.searchInitiatedSearch.testGetValue();
|
||||||
|
Assert.equal(1, searchEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ page: "recentbrowsing" }, searchEvents[0].extra);
|
||||||
|
const showAllEvents =
|
||||||
|
Glean.firefoxviewNext.searchShowAllShowallbutton.testGetValue();
|
||||||
|
Assert.equal(1, showAllEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ section: "opentabs" }, showAllEvents[0].extra);
|
||||||
|
});
|
||||||
|
|
||||||
|
await SimpleTest.promiseFocus(window);
|
||||||
|
await promiseAllButPrimaryWindowClosed();
|
||||||
|
await BrowserTestUtils.switchTab(gBrowser, gInitialTab);
|
||||||
|
await closeFirefoxViewTab(window);
|
||||||
|
|
||||||
|
cleanUp();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_show_all_syncedtabs_telemetry() {
|
||||||
|
TabsSetupFlowManager.resetInternalState();
|
||||||
|
|
||||||
|
const sandbox = setupRecentDeviceListMocks();
|
||||||
|
const syncedTabsMock = sandbox.stub(SyncedTabs, "getRecentTabs");
|
||||||
|
let mockTabs1 = getMockTabData(syncedTabsData);
|
||||||
|
let getRecentTabsResult = mockTabs1;
|
||||||
|
syncedTabsMock.callsFake(() => {
|
||||||
|
info(
|
||||||
|
`Stubbed SyncedTabs.getRecentTabs returning a promise that resolves to ${getRecentTabsResult.length} tabs\n`
|
||||||
|
);
|
||||||
|
return Promise.resolve(getRecentTabsResult);
|
||||||
|
});
|
||||||
|
sandbox.stub(SyncedTabs, "getTabClients").callsFake(() => {
|
||||||
|
return Promise.resolve(syncedTabsData);
|
||||||
|
});
|
||||||
|
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
Services.obs.notifyObservers(null, UIState.ON_UPDATE);
|
||||||
|
const recentBrowsing = document.querySelector("view-recentbrowsing");
|
||||||
|
|
||||||
|
info("Input a search query.");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
recentBrowsing.searchTextbox,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
EventUtils.sendString("mozilla", content);
|
||||||
|
const syncedtabsSlot = recentBrowsing.querySelector("[slot='syncedtabs']");
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() =>
|
||||||
|
syncedtabsSlot.fullyUpdated &&
|
||||||
|
syncedtabsSlot.tabLists.length === 1 &&
|
||||||
|
Promise.all(
|
||||||
|
Array.from(syncedtabsSlot.tabLists).map(
|
||||||
|
tabList => tabList.updateComplete
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Synced Tabs component is done updating."
|
||||||
|
);
|
||||||
|
syncedtabsSlot.tabLists[0].scrollIntoView();
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => syncedtabsSlot.tabLists[0].rowEls.length === 5,
|
||||||
|
"Expected search results are not shown yet."
|
||||||
|
);
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
|
||||||
|
const showAllButton = await TestUtils.waitForCondition(
|
||||||
|
() =>
|
||||||
|
syncedtabsSlot.shadowRoot.querySelector(
|
||||||
|
"[data-l10n-id='firefoxview-show-all']"
|
||||||
|
),
|
||||||
|
"Waiting for the show all button to be available in the synced tabs slot"
|
||||||
|
);
|
||||||
|
info("Scroll show all button into view.");
|
||||||
|
showAllButton.scrollIntoView();
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => !showAllButton.hidden,
|
||||||
|
"Waiting for the show all button to be visible"
|
||||||
|
);
|
||||||
|
ok(!showAllButton.hidden, "Show all button is visible");
|
||||||
|
info("Click the Show All link.");
|
||||||
|
await TestUtils.waitForCondition(() => {
|
||||||
|
EventUtils.synthesizeMouseAtCenter(showAllButton, {}, content);
|
||||||
|
if (syncedtabsSlot.tabLists[0].rowEls.length === NUMBER_OF_TABS) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, "All search results are not shown.");
|
||||||
|
|
||||||
|
const searchEvents =
|
||||||
|
Glean.firefoxviewNext.searchInitiatedSearch.testGetValue();
|
||||||
|
Assert.equal(1, searchEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ page: "recentbrowsing" }, searchEvents[0].extra);
|
||||||
|
const showAllEvents =
|
||||||
|
Glean.firefoxviewNext.searchShowAllShowallbutton.testGetValue();
|
||||||
|
Assert.equal(1, showAllEvents.length, "Expected one search event.");
|
||||||
|
Assert.deepEqual({ section: "syncedtabs" }, showAllEvents[0].extra);
|
||||||
|
});
|
||||||
|
|
||||||
|
await tearDown(sandbox);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_sort_history_search_telemetry() {
|
||||||
|
for (let i = 0; i < NUMBER_OF_TABS; i++) {
|
||||||
|
await open_then_close(URLs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
await navigateToViewAndWait(document, "history");
|
||||||
|
const historyComponent = document.querySelector("view-history");
|
||||||
|
|
||||||
|
const searchTextbox = await TestUtils.waitForCondition(
|
||||||
|
() => historyComponent.searchTextbox,
|
||||||
|
"The search textbox is displayed."
|
||||||
|
);
|
||||||
|
|
||||||
|
info("Input a search query.");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(searchTextbox, {}, content);
|
||||||
|
EventUtils.sendString("example.com", content);
|
||||||
|
await TestUtils.waitForCondition(() => {
|
||||||
|
const { rowEls } = historyComponent.lists[0];
|
||||||
|
return rowEls.length === 1;
|
||||||
|
}, "There is one matching search result.");
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
// Select sort by site option
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
historyComponent.sortInputs[1],
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => historyComponent.fullyUpdated,
|
||||||
|
"Waiting for the history component to be fully updated"
|
||||||
|
);
|
||||||
|
let historyEvents = Glean.firefoxviewNext.sortHistoryTabs.testGetValue();
|
||||||
|
Assert.equal(1, historyEvents.length, "Expected one history event.");
|
||||||
|
Assert.deepEqual(
|
||||||
|
{ sort_type: "site", search_start: "true" },
|
||||||
|
historyEvents[0].extra
|
||||||
|
);
|
||||||
|
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
|
||||||
|
// Select sort by date option
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
historyComponent.sortInputs[0],
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => historyComponent.fullyUpdated,
|
||||||
|
"Waiting for the history component to be fully updated"
|
||||||
|
);
|
||||||
|
historyEvents = Glean.firefoxviewNext.sortHistoryTabs.testGetValue();
|
||||||
|
Assert.equal(1, historyEvents.length, "Expected one history event.");
|
||||||
|
Assert.deepEqual(
|
||||||
|
{ sort_type: "date", search_start: "true" },
|
||||||
|
historyEvents[0].extra
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_cumulative_searches_recent_browsing_telemetry() {
|
||||||
|
await PlacesUtils.history.clear();
|
||||||
|
await open_then_close(URLs[0]);
|
||||||
|
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
|
||||||
|
is(document.location.hash, "", "Searching within recent browsing.");
|
||||||
|
const recentBrowsing = document.querySelector("view-recentbrowsing");
|
||||||
|
info("Input a search query");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
recentBrowsing.searchTextbox,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
EventUtils.sendString(URLs[0], content);
|
||||||
|
const recentlyclosedSlot = recentBrowsing.querySelector(
|
||||||
|
"[slot='recentlyclosed']"
|
||||||
|
);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() =>
|
||||||
|
recentlyclosedSlot?.tabList?.rowEls?.length &&
|
||||||
|
recentlyclosedSlot?.searchQuery,
|
||||||
|
"Expected search results are not shown yet."
|
||||||
|
);
|
||||||
|
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
recentlyclosedSlot.tabList.rowEls[0].mainEl,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
1,
|
||||||
|
Glean.firefoxview.cumulativeSearches.testGetValue().recentbrowsing.sum
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
cleanUp();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_cumulative_searches_recently_closed_telemetry() {
|
||||||
|
await PlacesUtils.history.clear();
|
||||||
|
await open_then_close(URLs[0]);
|
||||||
|
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
|
||||||
|
await navigateToViewAndWait(document, "recentlyclosed");
|
||||||
|
is(
|
||||||
|
document.location.hash,
|
||||||
|
"#recentlyclosed",
|
||||||
|
"Searching within recently closed."
|
||||||
|
);
|
||||||
|
const recentlyClosed = document.querySelector(
|
||||||
|
"named-deck > view-recentlyclosed"
|
||||||
|
);
|
||||||
|
const searchTextbox = await TestUtils.waitForCondition(() => {
|
||||||
|
return recentlyClosed.searchTextbox;
|
||||||
|
}, "Waiting for the recently closed search textbox to be available");
|
||||||
|
info("Input a search query");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(searchTextbox, {}, content);
|
||||||
|
EventUtils.sendString(URLs[0], content);
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const [recentlyclosedSlot, tabList] =
|
||||||
|
await waitForRecentlyClosedTabsList(document);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => recentlyclosedSlot?.searchQuery,
|
||||||
|
"Waiting for the recently closed slot to have a search query"
|
||||||
|
);
|
||||||
|
|
||||||
|
await click_recently_closed_tab_item(tabList[0]);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
1,
|
||||||
|
Glean.firefoxview.cumulativeSearches.testGetValue().recentlyclosed.sum
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
cleanUp();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_cumulative_searches_open_tabs_telemetry() {
|
||||||
|
await PlacesUtils.history.clear();
|
||||||
|
await BrowserTestUtils.openNewForegroundTab(gBrowser, URLs[0]);
|
||||||
|
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
|
||||||
|
await navigateToViewAndWait(document, "opentabs");
|
||||||
|
is(document.location.hash, "#opentabs", "Searching within open tabs.");
|
||||||
|
const openTabs = document.querySelector("named-deck > view-opentabs");
|
||||||
|
|
||||||
|
info("Input a search query");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(openTabs.searchTextbox, {}, content);
|
||||||
|
EventUtils.sendString(URLs[0], content);
|
||||||
|
let cards;
|
||||||
|
await TestUtils.waitForCondition(() => {
|
||||||
|
cards = getOpenTabsCards(openTabs);
|
||||||
|
return cards.length == 1;
|
||||||
|
}, "There is one open tab card");
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() => cards[0].tabList.rowEls.length === 1 && openTabs?.searchQuery,
|
||||||
|
"Expected search results are not shown yet."
|
||||||
|
);
|
||||||
|
|
||||||
|
info("Click a search result tab");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
cards[0].tabList.rowEls[0].mainEl,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
1,
|
||||||
|
Glean.firefoxview.cumulativeSearches.testGetValue().opentabs.sum
|
||||||
|
);
|
||||||
|
|
||||||
|
cleanUp();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_cumulative_searches_history_telemetry() {
|
||||||
|
await PlacesUtils.history.clear();
|
||||||
|
await open_then_close(URLs[0]);
|
||||||
|
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
|
||||||
|
await navigateToViewAndWait(document, "history");
|
||||||
|
is(document.location.hash, "#history", "Searching within history.");
|
||||||
|
const history = document.querySelector("named-deck > view-history");
|
||||||
|
const searchTextbox = await TestUtils.waitForCondition(() => {
|
||||||
|
return history.searchTextbox;
|
||||||
|
});
|
||||||
|
|
||||||
|
info("Input a search query");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(searchTextbox, {}, content);
|
||||||
|
EventUtils.sendString(URLs[0], content);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() =>
|
||||||
|
history.fullyUpdated &&
|
||||||
|
history?.lists[0].rowEls?.length === 1 &&
|
||||||
|
history?.controller?.searchQuery,
|
||||||
|
"Expected search results are not shown yet."
|
||||||
|
);
|
||||||
|
|
||||||
|
info("Click a search result tab");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
history.lists[0].rowEls[0].mainEl,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
1,
|
||||||
|
Glean.firefoxview.cumulativeSearches.testGetValue().history.sum
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
cleanUp();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_cumulative_searches_syncedtabs_telemetry() {
|
||||||
|
await PlacesUtils.history.clear();
|
||||||
|
TabsSetupFlowManager.resetInternalState();
|
||||||
|
|
||||||
|
const sandbox = setupRecentDeviceListMocks();
|
||||||
|
const syncedTabsMock = sandbox.stub(SyncedTabs, "getRecentTabs");
|
||||||
|
let mockTabs1 = getMockTabData(syncedTabsData);
|
||||||
|
let getRecentTabsResult = mockTabs1;
|
||||||
|
syncedTabsMock.callsFake(() => {
|
||||||
|
info(
|
||||||
|
`Stubbed SyncedTabs.getRecentTabs returning a promise that resolves to ${getRecentTabsResult.length} tabs\n`
|
||||||
|
);
|
||||||
|
return Promise.resolve(getRecentTabsResult);
|
||||||
|
});
|
||||||
|
sandbox.stub(SyncedTabs, "getTabClients").callsFake(() => {
|
||||||
|
return Promise.resolve(syncedTabsData);
|
||||||
|
});
|
||||||
|
|
||||||
|
await withFirefoxView({}, async browser => {
|
||||||
|
const { document } = browser.contentWindow;
|
||||||
|
Services.obs.notifyObservers(null, UIState.ON_UPDATE);
|
||||||
|
|
||||||
|
await navigateToViewAndWait(document, "syncedtabs");
|
||||||
|
is(document.location.hash, "#syncedtabs", "Searching within synced tabs.");
|
||||||
|
let syncedTabs = document.querySelector(
|
||||||
|
"view-syncedtabs:not([slot=syncedtabs])"
|
||||||
|
);
|
||||||
|
|
||||||
|
info("Input a search query.");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(syncedTabs.searchTextbox, {}, content);
|
||||||
|
EventUtils.sendString(URLs[0], content);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() =>
|
||||||
|
syncedTabs.fullyUpdated &&
|
||||||
|
syncedTabs.tabLists.length === 1 &&
|
||||||
|
Promise.all(
|
||||||
|
Array.from(syncedTabs.tabLists).map(tabList => tabList.updateComplete)
|
||||||
|
),
|
||||||
|
"Synced Tabs component is done updating."
|
||||||
|
);
|
||||||
|
await TestUtils.waitForCondition(
|
||||||
|
() =>
|
||||||
|
syncedTabs.tabLists[0].rowEls.length === 1 &&
|
||||||
|
syncedTabs.controller.searchQuery,
|
||||||
|
"Expected search results are not shown yet."
|
||||||
|
);
|
||||||
|
|
||||||
|
info("Click a search result tab");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(
|
||||||
|
syncedTabs.tabLists[0].rowEls[0].mainEl,
|
||||||
|
{},
|
||||||
|
content
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
1,
|
||||||
|
Glean.firefoxview.cumulativeSearches.testGetValue().syncedtabs.sum
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
cleanUp();
|
||||||
|
await tearDown(sandbox);
|
||||||
|
});
|
||||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user