Bug 1690573 - Migrate the report-site-issue UI access point to the Help menu. r=denschub,mixedpuppy,fluent-reviewers,webcompat-reviewers,flod

We're not 100% certain if Help is the right spot for this, but we're going
to give it a shot and see. If it turns out it _is_ the right spot, we'll
probably do something a little more self-contained, and less hacky.

I'm leaving the old .properties file just in case we change our mind here.
Yes, we'll want to port to Fluent anyways, but our ultimate choice of where
we put this thing is probably going to dictate where the string lives.

Differential Revision: https://phabricator.services.mozilla.com/D104832
This commit is contained in:
Mike Conley 2021-02-23 00:11:05 +00:00
parent 0ff7359c48
commit d4da30ccf4
12 changed files with 175 additions and 8 deletions

View File

@ -484,6 +484,11 @@
onclick="checkForMiddleClick(this, event);"
data-l10n-id="menu-help-taskmanager"
appmenu-data-l10n-id="appmenu-help-taskmanager"/>
<menuitem id="help_reportSiteIssue"
oncommand="ReportSiteIssue();"
data-l10n-id="menu-help-report-site-issue"
appmenu-data-l10n-id="appmenu-help-report-site-issue"
hidden="true"/>
<menuitem id="menu_HelpPopup_reportPhishingtoolmenu"
disabled="true"
oncommand="openUILink(gSafeBrowsing.getReportURL('Phish'), event, {triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({})});"

View File

@ -8132,6 +8132,22 @@ function ReportFalseDeceptiveSite() {
}
}
/**
* This is a temporary hack to connect a Help menu item for reporting
* site issues to the WebCompat team's Site Compatability Reporter
* WebExtension, which ships by default and is enabled on pre-release
* channels.
*
* Once we determine if Help is the right place for it, we'll do something
* slightly better than this.
*
* See bug 1690573.
*/
function ReportSiteIssue() {
let subject = { wrappedJSObject: gBrowser.selectedTab };
Services.obs.notifyObservers(subject, "report-site-issue");
}
/**
* Format a URL
* eg:

View File

@ -1099,6 +1099,30 @@ function buildHelpMenu() {
if (typeof gSafeBrowsing != "undefined") {
gSafeBrowsing.setReportPhishingMenu();
}
// We're testing to see if the WebCompat team's "Report Site Issue"
// access point makes sense in the Help menu. Normally checking this
// pref wouldn't be enough, since there's also the case that the
// add-on has somehow been disabled by the user or third-party software
// without flipping the pref. Since this add-on is only used on pre-release
// channels, and since the jury is still out on whether or not the Help menu
// is the right place for this item, we're going to do a least-effort
// approach here and assume that the pref is enough to determine whether the
// menuitem should appear.
//
// See bug 1690573 for further details.
let reportSiteIssueEnabled = Services.prefs.getBoolPref(
"extensions.webcompat-reporter.enabled",
false
);
let reportSiteIssue = document.getElementById("help_reportSiteIssue");
reportSiteIssue.hidden = !reportSiteIssueEnabled;
if (reportSiteIssueEnabled) {
let uri = gBrowser.currentURI;
let isReportablePage =
uri && (uri.schemeIs("http") || uri.schemeIs("https"));
reportSiteIssue.disabled = !isReportablePage;
}
}
function isElementVisible(aElement) {

View File

@ -19,7 +19,7 @@ const FRAMEWORK_KEYS = ["hasFastClick", "hasMobify", "hasMarfeel"];
browser.pageActionExtras.setLabelForHistogram("webcompat");
browser.pageAction.onClicked.addListener(tab => {
browser.helpMenu.onHelpMenuCommand.addListener(tab => {
return getWebCompatInfoForTab(tab).then(
info => {
return openWebCompatTab(info);

View File

@ -0,0 +1,50 @@
/* 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/. */
"use strict";
/* global ExtensionAPI */
ChromeUtils.defineModuleGetter(
this,
"Services",
"resource://gre/modules/Services.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"ExtensionCommon",
"resource://gre/modules/ExtensionCommon.jsm"
);
const TOPIC = "report-site-issue";
this.helpMenu = class extends ExtensionAPI {
getAPI(context) {
const { tabManager } = context.extension;
let EventManager = ExtensionCommon.EventManager;
return {
helpMenu: {
onHelpMenuCommand: new EventManager({
context,
name: "helpMenu",
register: fire => {
let observer = (subject, topic, data) => {
let nativeTab = subject.wrappedJSObject;
let tab = tabManager.convert(nativeTab);
fire.async(tab);
};
Services.obs.addObserver(observer, TOPIC);
return () => {
Services.obs.removeObserver(observer, TOPIC);
};
},
}).api(),
},
};
}
};

View File

@ -0,0 +1,28 @@
[
{
"namespace": "helpMenu",
"events": [
{
"name": "onHelpMenuCommand",
"type": "function",
"async": "callback",
"description": "Fired when the command event for the Report Site Issue menuitem in Help is fired.",
"parameters": [
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [
{
"name": "tab",
"$ref": "tabs.Tab",
"optional": true,
"description": "Details about the selected tab in the window where the menuitem command fired."
}
]
}
]
}
]
}
]

View File

@ -27,6 +27,14 @@
"paths": [["browserInfo"]]
}
},
"helpMenu": {
"schema": "experimentalAPIs/helpMenu.json",
"parent": {
"scopes": ["addon_parent"],
"script": "experimentalAPIs/helpMenu.js",
"paths": [["helpMenu"]]
}
},
"l10n": {
"schema": "experimentalAPIs/l10n.json",
"parent": {
@ -67,12 +75,5 @@
"scripts": [
"background.js"
]
},
"page_action": {
"browser_style": true,
"default_icon": "icons/lightbulb.svg",
"default_title": "Report Site Issue…",
"pinned": false,
"show_matches": ["http://*/*", "https://*/*"]
}
}

View File

@ -19,6 +19,8 @@ FINAL_TARGET_FILES.features["webcompat-reporter@mozilla.org"].experimentalAPIs +
"experimentalAPIs/aboutConfigPrefs.json",
"experimentalAPIs/browserInfo.js",
"experimentalAPIs/browserInfo.json",
"experimentalAPIs/helpMenu.js",
"experimentalAPIs/helpMenu.json",
"experimentalAPIs/l10n.js",
"experimentalAPIs/l10n.json",
"experimentalAPIs/pageActionExtras.js",

View File

@ -7,5 +7,8 @@ support-files =
webcompat.html
[browser_disabled_cleanup.js]
skip-if = true # Disabled until bug 1693119 is landed
[browser_button_state.js]
skip-if = true # Disabled until bug 1693119 is landed
[browser_report_site_issue.js]
skip-if = true # Disabled until bug 1693119 is landed

View File

@ -132,6 +132,8 @@ appmenu-help-troubleshooting-info =
.accesskey = T
appmenu-help-taskmanager =
.label = Task Manager
appmenu-help-report-site-issue =
.label = Report Site Issue…
appmenu-help-feedback-page =
.label = Submit Feedback…
.accesskey = S

View File

@ -307,6 +307,8 @@ menu-help-troubleshooting-info =
.accesskey = T
menu-help-taskmanager =
.label = Task Manager
menu-help-report-site-issue =
.label = Report Site Issue…
menu-help-feedback-page =
.label = Submit Feedback…
.accesskey = S

View File

@ -0,0 +1,34 @@
# coding=utf8
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
from __future__ import absolute_import
from fluent.migrate.helpers import transforms_from
def migrate(ctx):
"""Bug 1690573 - Port Report Site Issue WebExtension strings to Fluent, part {index}."""
ctx.add_transforms(
"browser/browser/menubar.ftl",
"browser/browser/menubar.ftl",
transforms_from(
"""
menu-help-report-site-issue =
.label = { COPY(from_path, "wc-reporter.label2") }
""",
from_path="browser/extensions/report-site-issue/webcompat.properties",
),
)
ctx.add_transforms(
"browser/browser/appmenu.ftl",
"browser/browser/appmenu.ftl",
transforms_from(
"""
appmenu-help-report-site-issue =
.label = { COPY(from_path, "wc-reporter.label2") }
""",
from_path="browser/extensions/report-site-issue/webcompat.properties",
),
)