Backed out changeset 8e5aa4b063cc (bug 1901261) for causing py3 failures on make-schemas.py. CLOSED TREE

This commit is contained in:
Tamas Szentpeteri
2024-07-31 17:13:20 +03:00
parent 4e48dbd1eb
commit 03b8b4ec2d
20 changed files with 2 additions and 322 deletions

View File

@@ -4691,13 +4691,8 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) {
return; return;
} }
// fxms-bmb-button is a Firefox Messaging System Bookmarks bar button
let removable = !toolbarItem?.classList?.contains("fxms-bmb-button");
let movable = let movable =
toolbarItem?.id && toolbarItem?.id && CustomizableUI.isWidgetRemovable(toolbarItem);
removable &&
!toolbarItem?.classList?.contains("fxms-bmb-button") &&
CustomizableUI.isWidgetRemovable(toolbarItem);
if (movable) { if (movable) {
if (CustomizableUI.isSpecialWidget(toolbarItem.id)) { if (CustomizableUI.isSpecialWidget(toolbarItem.id)) {
moveToPanel.setAttribute("disabled", true); moveToPanel.setAttribute("disabled", true);
@@ -4706,10 +4701,8 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) {
} }
removeFromToolbar.removeAttribute("disabled"); removeFromToolbar.removeAttribute("disabled");
} else { } else {
if (removable) {
removeFromToolbar.setAttribute("disabled", true);
}
moveToPanel.setAttribute("disabled", true); moveToPanel.setAttribute("disabled", true);
removeFromToolbar.setAttribute("disabled", true);
} }
} }

View File

@@ -94,10 +94,6 @@ async function getMessageValidators(skipValidation) {
); );
const messageValidators = { const messageValidators = {
bookmarks_bar_button: await getValidator(
"./content-src/templates/OnboardingMessage/BookmarksBarButton.schema.json",
{ common: true }
),
cfr_doorhanger: await getValidator( cfr_doorhanger: await getValidator(
"./content-src/templates/CFR/templates/ExtensionDoorhanger.schema.json", "./content-src/templates/CFR/templates/ExtensionDoorhanger.schema.json",
{ common: true } { common: true }

View File

@@ -1131,7 +1131,6 @@
"type": "string", "type": "string",
"description": "Which messaging template this message is using.", "description": "Which messaging template this message is using.",
"enum": [ "enum": [
"bookmarks_bar_button",
"cfr_urlbar_chiclet", "cfr_urlbar_chiclet",
"cfr_doorhanger", "cfr_doorhanger",
"milestone_message", "milestone_message",

View File

@@ -63,9 +63,6 @@ SCHEMAS = [
schema_id="chrome://browser/content/asrouter/schemas/MessagingExperiment.schema.json", schema_id="chrome://browser/content/asrouter/schemas/MessagingExperiment.schema.json",
schema_path=Path("MessagingExperiment.schema.json"), schema_path=Path("MessagingExperiment.schema.json"),
message_types={ message_types={
"BookmarksBarButton": (
SCHEMA_DIR / "OnboardingMessage" / "BookmarksBarButton.schema.json"
),
"CFRUrlbarChiclet": ( "CFRUrlbarChiclet": (
SCHEMA_DIR / "CFR" / "templates" / "CFRUrlbarChiclet.schema.json" SCHEMA_DIR / "CFR" / "templates" / "CFRUrlbarChiclet.schema.json"
), ),

View File

@@ -1,40 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "file:///BookmarksBarButton.schema.json",
"title": "BookmarksBarButton",
"description": "A template with a label and a special message action (currently only supports OPEN_URL)",
"allOf": [
{
"$ref": "file:///FxMSCommon.schema.json#/$defs/Message"
}
],
"type": "object",
"properties": {
"template": {
"type": "string",
"const": "bookmarks_bar_button"
},
"content": {
"type": "object",
"properties": {
"action": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "Action dispatched by the button."
},
"data": {
"type": "object"
}
},
"required": ["type"],
"additionalProperties": true
}
},
"additionalProperties": true
}
},
"additionalProperties": true,
"required": ["targeting"]
}

View File

@@ -35,7 +35,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
ASRouterTriggerListeners: ASRouterTriggerListeners:
"resource:///modules/asrouter/ASRouterTriggerListeners.sys.mjs", "resource:///modules/asrouter/ASRouterTriggerListeners.sys.mjs",
AttributionCode: "resource:///modules/AttributionCode.sys.mjs", AttributionCode: "resource:///modules/AttributionCode.sys.mjs",
BookmarksBarButton: "resource:///modules/asrouter/BookmarksBarButton.sys.mjs",
Downloader: "resource://services-settings/Attachments.sys.mjs", Downloader: "resource://services-settings/Attachments.sys.mjs",
ExperimentAPI: "resource://nimbus/ExperimentAPI.sys.mjs", ExperimentAPI: "resource://nimbus/ExperimentAPI.sys.mjs",
FeatureCalloutBroker: FeatureCalloutBroker:
@@ -1478,9 +1477,6 @@ export class _ASRouter {
this.dispatchCFRAction this.dispatchCFRAction
); );
break; break;
case "bookmarks_bar_button":
lazy.BookmarksBarButton.showBookmarksBarButton(browser, message);
break;
} }
return { message }; return { message };

View File

@@ -1,70 +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/. */
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
CustomizableUI: "resource:///modules/CustomizableUI.sys.mjs",
SpecialMessageActions:
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs",
ASRouter: "resource:///modules/asrouter/ASRouter.sys.mjs",
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.sys.mjs",
});
export const BookmarksBarButton = {
async showBookmarksBarButton(browser, message) {
const { label, action } = message.content;
let { gBrowser } = browser.ownerGlobal;
const surfaceName = "fxms-bmb-button";
const widgetId = message.id;
const fxmsBookmarksBarBtn = {
id: widgetId,
l10nId: label?.string_id,
label: label?.raw,
tooltiptext: label?.tooltiptext,
defaultArea: lazy.CustomizableUI.AREA_BOOKMARKS,
type: "button",
onCreated(aNode) {
aNode.className = `bookmark-item chromeclass-toolbar-additional ${surfaceName}`;
lazy.BrowserUsageTelemetry.recordWidgetChange(
widgetId,
lazy.CustomizableUI.AREA_BOOKMARKS,
"create"
);
lazy.ASRouter.addImpression(message);
},
onCommand() {
// Currently only supports OPEN_URL action
if (action.type === "OPEN_URL") {
// Click telemetry is handled in BrowserUsageTelemetry, see
// _recordCommand()
lazy.SpecialMessageActions.handleAction(action, gBrowser);
}
if (action.navigate || action.dismiss) {
lazy.CustomizableUI.destroyWidget(widgetId);
}
},
onWidgetRemoved() {
lazy.CustomizableUI.destroyWidget(widgetId);
},
onDestroyed() {
lazy.CustomizableUI.removeListener(this);
lazy.BrowserUsageTelemetry.recordWidgetChange(
widgetId,
null,
"destroy"
);
},
};
lazy.CustomizableUI.addListener(fxmsBookmarksBarBtn);
lazy.CustomizableUI.createWidget(fxmsBookmarksBarBtn);
},
};

View File

@@ -38,5 +38,4 @@ export const MESSAGING_EXPERIMENTS_DEFAULT_FEATURES = [
"pbNewtab", "pbNewtab",
"spotlight", "spotlight",
"featureCallout", "featureCallout",
"bookmarksBarButton",
]; ];

View File

@@ -94,28 +94,6 @@ const MESSAGES = () => [
patterns: ["*://*/*.pdf"], patterns: ["*://*/*.pdf"],
}, },
}, },
{
id: "TEST_BMB_BUTTON",
groups: [],
template: "bookmarks_bar_button",
content: {
label: {
raw: "Getting Started",
tooltiptext: "Getting started with Firefox",
},
action: {
type: "OPEN_URL",
data: {
args: "https://www.mozilla.org",
where: "tab",
},
navigate: true,
},
},
frequency: { lifetime: 100 },
trigger: { id: "defaultBrowserCheck" },
targeting: "true",
},
{ {
id: "MULTISTAGE_SPOTLIGHT_MESSAGE", id: "MULTISTAGE_SPOTLIGHT_MESSAGE",
groups: ["panel-test-provider"], groups: ["panel-test-provider"],

View File

@@ -23,7 +23,6 @@ EXTRA_JS_MODULES.asrouter += [
"modules/ASRouterPreferences.sys.mjs", "modules/ASRouterPreferences.sys.mjs",
"modules/ASRouterTargeting.sys.mjs", "modules/ASRouterTargeting.sys.mjs",
"modules/ASRouterTriggerListeners.sys.mjs", "modules/ASRouterTriggerListeners.sys.mjs",
"modules/BookmarksBarButton.sys.mjs",
"modules/CFRMessageProvider.sys.mjs", "modules/CFRMessageProvider.sys.mjs",
"modules/CFRPageActions.sys.mjs", "modules/CFRPageActions.sys.mjs",
"modules/FeatureCallout.sys.mjs", "modules/FeatureCallout.sys.mjs",
@@ -54,7 +53,6 @@ TESTING_JS_MODULES += [
"content-src/templates/CFR/templates/CFRUrlbarChiclet.schema.json", "content-src/templates/CFR/templates/CFRUrlbarChiclet.schema.json",
"content-src/templates/CFR/templates/ExtensionDoorhanger.schema.json", "content-src/templates/CFR/templates/ExtensionDoorhanger.schema.json",
"content-src/templates/CFR/templates/InfoBar.schema.json", "content-src/templates/CFR/templates/InfoBar.schema.json",
"content-src/templates/OnboardingMessage/BookmarksBarButton.schema.json",
"content-src/templates/OnboardingMessage/Spotlight.schema.json", "content-src/templates/OnboardingMessage/Spotlight.schema.json",
"content-src/templates/OnboardingMessage/ToolbarBadgeMessage.schema.json", "content-src/templates/OnboardingMessage/ToolbarBadgeMessage.schema.json",
"content-src/templates/OnboardingMessage/UpdateAction.schema.json", "content-src/templates/OnboardingMessage/UpdateAction.schema.json",

View File

@@ -38,8 +38,6 @@ tags = "remote-settings"
tags = "remote-settings" tags = "remote-settings"
skip-if = ["a11y_checks"] # Bug 1854515 and 1858041 to investigate intermittent a11y_checks results (fails on Autoland, passes on Try) skip-if = ["a11y_checks"] # Bug 1854515 and 1858041 to investigate intermittent a11y_checks results (fails on Autoland, passes on Try)
["browser_bookmarks_bar_button.js"]
["browser_feature_callout_in_chrome.js"] ["browser_feature_callout_in_chrome.js"]
skip-if = [ skip-if = [
"os == 'mac' && debug", # Bug 1804349 "os == 'mac' && debug", # Bug 1804349

View File

@@ -1,132 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { BookmarksBarButton } = ChromeUtils.importESModule(
"resource:///modules/asrouter/BookmarksBarButton.sys.mjs"
);
const { SpecialMessageActions } = ChromeUtils.importESModule(
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs"
);
const surfaceName = "fxms-bmb-button";
function getTestMessage() {
return {
id: "TEST_BMB_BAR_BUTTON",
groups: [],
template: "bookmarks_bar_button",
content: {
label: {
raw: "Getting Started",
tooltiptext: "Getting started with Firefox",
},
action: {
type: "OPEN_URL",
data: {
args: "https://www.mozilla.org",
where: "tab",
},
navigate: true,
},
},
trigger: { id: "defaultBrowserCheck" },
frequency: {
lifetime: 100,
},
targeting: "true",
};
}
async function assertTelemetryScalars(expectedScalars) {
let processScalars =
Services.telemetry.getSnapshotForKeyedScalars("main", true)?.parent ?? {};
let expectedKeys = Object.keys(expectedScalars);
//key is something like "browser.ui.customized_widgets"
for (const key of expectedKeys) {
const expectedEvents = expectedScalars[key];
const actualEvents = processScalars[key];
for (const eventKey of Object.keys(expectedEvents)) {
Assert.equal(
expectedEvents[eventKey],
actualEvents[eventKey],
`Expected to see the correct value for scalar ${eventKey}, got ${actualEvents[eventKey]}`
);
}
}
}
add_task(async function showButton() {
const message = getTestMessage();
const ID = message.id;
const sandbox = sinon.createSandbox();
const win = await BrowserTestUtils.openNewBrowserWindow();
const browser = win.gBrowser.selectedBrowser;
const doc = win.document;
await BookmarksBarButton.showBookmarksBarButton(browser, message);
info("WAITING TO SHOW BOOKMARKS BAR BUTTON");
ok(doc.querySelector(".fxms-bmb-button"), "Bookmarks Bar Button exists");
// Check Keyed Scalars for Telemetry
const expectedScalars = {
"TEST-BMB-BAR-BUTTON_add_na_bookmarks-bar_create": 1,
"TEST-BMB-BAR-BUTTON_remove_bookmarks-bar_na_destroy": 1,
};
assertTelemetryScalars(expectedScalars);
CustomizableUI.destroyWidget(ID);
await CustomizableUI.reset();
await BrowserTestUtils.closeWindow(win);
sandbox.restore();
});
add_task(async function clickButton() {
const message = getTestMessage();
const Id2 = "TEST_BMB_BAR_BUTTON_2";
message.id = Id2;
const sandbox = sinon.createSandbox();
const win = await BrowserTestUtils.openNewBrowserWindow();
const browser = win.gBrowser.selectedBrowser;
const doc = win.document;
const handleActionStub = sandbox.stub(SpecialMessageActions, "handleAction");
await BookmarksBarButton.showBookmarksBarButton(browser, message);
info("WAITING TO SHOW BOOKMARKS BAR BUTTON");
ok(doc.querySelector(".fxms-bmb-button"), "Bookmarks Bar Button exists");
win.document.querySelector(".fxms-bmb-button").click();
ok(
handleActionStub.calledWith(message.content.action),
"handleAction should be called with correct Args"
);
ok(!doc.querySelector(".fxms-bmb-button"), "button should be removed");
// Check Keyed Scalars for Telemetry
const expectedClickScalars = {
"browser.ui.customized_widgets": {
"TEST-BMB-BAR-BUTTON-2_remove_bookmarks-bar_na_destroy": 1,
"TEST-BMB-BAR-BUTTON-2_add_na_bookmarks-bar_create": 1,
},
"browser.ui.interaction.bookmarks_bar": {
"TEST-BMB-BAR-BUTTON-2": 1,
},
};
assertTelemetryScalars(expectedClickScalars);
CustomizableUI.destroyWidget(Id2);
await CustomizableUI.reset();
await BrowserTestUtils.closeWindow(win);
sandbox.restore();
});

View File

@@ -49,10 +49,6 @@ async function makeValidators() {
); );
const messageValidators = { const messageValidators = {
bookmarks_bar_button: await schemaValidatorFor(
"resource://testing-common/BookmarksBarButton.schema.json",
{ common: true }
),
cfr_doorhanger: await schemaValidatorFor( cfr_doorhanger: await schemaValidatorFor(
"resource://testing-common/ExtensionDoorhanger.schema.json", "resource://testing-common/ExtensionDoorhanger.schema.json",
{ common: true } { common: true }

View File

@@ -26,7 +26,6 @@ add_task(async function test_PanelTestProvider() {
feature_callout: 2, feature_callout: 2,
pb_newtab: 2, pb_newtab: 2,
toast_notification: 3, toast_notification: 3,
bookmarks_bar_button: 1,
}; };
const EXPECTED_TOTAL_MESSAGE_COUNT = Object.values( const EXPECTED_TOTAL_MESSAGE_COUNT = Object.values(

View File

@@ -9,7 +9,6 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
AddonManager: "resource://gre/modules/AddonManager.sys.mjs", AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
BookmarksBarButton: "resource:///modules/asrouter/BookmarksBarButton.sys.mjs",
CFRPageActions: "resource:///modules/asrouter/CFRPageActions.sys.mjs", CFRPageActions: "resource:///modules/asrouter/CFRPageActions.sys.mjs",
FeatureCalloutBroker: FeatureCalloutBroker:
"resource:///modules/asrouter/FeatureCalloutBroker.sys.mjs", "resource:///modules/asrouter/FeatureCalloutBroker.sys.mjs",
@@ -57,10 +56,6 @@ export class AboutMessagePreviewParent extends JSWindowActorParent {
lazy.Spotlight.showSpotlightDialog(browser, message, () => {}); lazy.Spotlight.showSpotlightDialog(browser, message, () => {});
} }
showBookmarksBarButton(message, browser) {
lazy.BookmarksBarButton.showBookmarksBarButton(message, browser);
}
showCFR(message, browser) { showCFR(message, browser) {
lazy.CFRPageActions.forceRecommendation( lazy.CFRPageActions.forceRecommendation(
browser, browser,
@@ -144,9 +139,6 @@ export class AboutMessagePreviewParent extends JSWindowActorParent {
case "feature_callout": case "feature_callout":
this.showFeatureCallout(message, browser); this.showFeatureCallout(message, browser);
return; return;
case "bookmarks_bar_button":
this.showBookmarksBarButton(message, browser);
return;
default: default:
console.error(`Unsupported message template ${message.template}`); console.error(`Unsupported message template ${message.template}`);
} }

View File

@@ -458,7 +458,6 @@ body {
} }
toolbarpaletteitem > #personal-bookmarks > #PlacesToolbar, toolbarpaletteitem > #personal-bookmarks > #PlacesToolbar,
toolbarpaletteitem:has(> toolbarbutton.fxms-bmb-button),
#personal-bookmarks:is([overflowedItem=true], [cui-areatype="panel"]) > #PlacesToolbar { #personal-bookmarks:is([overflowedItem=true], [cui-areatype="panel"]) > #PlacesToolbar {
display: none; display: none;
} }

View File

@@ -300,7 +300,3 @@
stroke: var(--toolbarbutton-icon-fill); stroke: var(--toolbarbutton-icon-fill);
list-style-image: url("chrome://global/skin/icons/content-analysis.svg"); list-style-image: url("chrome://global/skin/icons/content-analysis.svg");
} }
.fxms-bmb-button {
list-style-image: url("chrome://branding/content/about-logo.png");
}

View File

@@ -531,7 +531,6 @@ toolbar:not(#TabsToolbar) > #personal-bookmarks {
#PlacesToolbarItems > .bookmark-item > .toolbarbutton-icon[label]:not([label=""]), #PlacesToolbarItems > .bookmark-item > .toolbarbutton-icon[label]:not([label=""]),
#PersonalToolbar #import-button > .toolbarbutton-icon, #PersonalToolbar #import-button > .toolbarbutton-icon,
#PersonalToolbar #aboutwelcome-button > .toolbarbutton-icon, #PersonalToolbar #aboutwelcome-button > .toolbarbutton-icon,
#PersonalToolbar .fxms-bmb-button > .toolbarbutton-icon,
#OtherBookmarks.bookmark-item[container] > .toolbarbutton-icon { #OtherBookmarks.bookmark-item[container] > .toolbarbutton-icon {
margin-inline-end: 4px; margin-inline-end: 4px;
} }

View File

@@ -3452,15 +3452,3 @@ crlite:
pref: security.pki.crlite_mode pref: security.pki.crlite_mode
description: >- description: >-
How CRLite results will be interpreted. How CRLite results will be interpreted.
fxms_bmb_button:
description: A feature for the Firefox Messaging System Bookmarks Bar button surface
owner: omc@mozilla.com
hasExposure: true
exposureDescription: >-
Exposure is sent if the message is about to be shown after trigger and
targeting conditions on the message matched.
schema:
uri: chrome://browser/content/asrouter/schemas/MessagingExperiment.schema.json
path: browser/components/asrouter/content-src/schemas/MessagingExperiment.schema.json
variables: {}

View File

@@ -1505,7 +1505,6 @@ messaging_experiments:
"infobar", "infobar",
"spotlight", "spotlight",
"featureCallout", "featureCallout",
"fxms_bmb_button",
"fxms_message_1", "fxms_message_1",
"fxms_message_2", "fxms_message_2",
"fxms_message_3", "fxms_message_3",