mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1859791 - Replace in-product abuse report flow with AMO web form. r=willdurand
Differential Revision: https://phabricator.services.mozilla.com/D192004
This commit is contained in:
parent
35f00ac61e
commit
864cf8865c
@ -1846,6 +1846,9 @@ pref("extensions.abuseReport.enabled", true);
|
||||
pref("extensions.abuseReport.amWebAPI.enabled", true);
|
||||
pref("extensions.abuseReport.url", "https://services.addons.mozilla.org/api/v4/abuse/report/addon/");
|
||||
pref("extensions.abuseReport.amoDetailsURL", "https://services.addons.mozilla.org/api/v4/addons/addon/");
|
||||
// Whether Firefox integrated abuse reporting feature should be opening the new abuse report form hosted on AMO.
|
||||
pref("extensions.abuseReport.amoFormEnabled", false);
|
||||
pref("extensions.abuseReport.amoFormURL", "https://addons.mozilla.org/%LOCALE%/%APP%/feedback/addon/%addonID%/");
|
||||
|
||||
// Blocklist preferences
|
||||
pref("extensions.blocklist.enabled", true);
|
||||
|
@ -5,6 +5,7 @@
|
||||
/* eslint max-len: ["error", 80] */
|
||||
/* import-globals-from aboutaddonsCommon.js */
|
||||
/* exported openAbuseReport */
|
||||
/* global windowRoot */
|
||||
|
||||
/**
|
||||
* This script is part of the HTML about:addons page and it provides some
|
||||
@ -15,6 +16,16 @@ const { AbuseReporter } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/AbuseReporter.sys.mjs"
|
||||
);
|
||||
|
||||
// Whether the abuse report feature should open a form hosted on
|
||||
// addons.mozilla.org or use the abuse report panel integrated
|
||||
// in Firefox.
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"ABUSE_REPORT_AMO_FORM_ENABLED",
|
||||
"extensions.abuseReport.amoFormEnabled",
|
||||
true
|
||||
);
|
||||
|
||||
// Message Bars definitions.
|
||||
const ABUSE_REPORT_MESSAGE_BARS = {
|
||||
// Idle message-bar (used while the submission is still ongoing).
|
||||
@ -180,7 +191,24 @@ async function openAbuseReport({ addonId, reportEntryPoint }) {
|
||||
}
|
||||
}
|
||||
|
||||
window.openAbuseReport = openAbuseReport;
|
||||
// Unlike the openAbuseReport function, technically this method wouldn't need
|
||||
// to be async, but it is so that both the implementations will be providing
|
||||
// the same type signatures (returning a promise) to the callers, independently
|
||||
// from which abuse reporting feature is enabled.
|
||||
async function openAbuseReportAMOForm({ addonId, reportEntryPoint }) {
|
||||
const amoUrl = Services.urlFormatter
|
||||
.formatURLPref("extensions.abuseReport.amoFormURL")
|
||||
.replace(/%addonID%/g, addonId);
|
||||
windowRoot.ownerGlobal.openTrustedLinkIn(amoUrl, "tab", {
|
||||
// Make sure the newly open tab is going to be focused, independently
|
||||
// from general user prefs.
|
||||
forceForeground: true,
|
||||
});
|
||||
}
|
||||
|
||||
window.openAbuseReport = ABUSE_REPORT_AMO_FORM_ENABLED
|
||||
? openAbuseReportAMOForm
|
||||
: openAbuseReport;
|
||||
|
||||
// Helper function used to create abuse report message bars in the
|
||||
// HTML about:addons page.
|
||||
|
@ -59,6 +59,8 @@ prefs = [
|
||||
["browser_addon_list_reordering.js"]
|
||||
fail-if = ["a11y_checks"] # Bug 1854646 clicked h1.header-name may not be focusable
|
||||
|
||||
["browser_amo_abuse_report.js"]
|
||||
|
||||
["browser_bug572561.js"]
|
||||
|
||||
["browser_checkAddonCompatibility.js"]
|
||||
|
@ -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/. */
|
||||
/* eslint max-len: ["error", 80] */
|
||||
|
||||
loadTestSubscript("head_abuse_report.js");
|
||||
|
||||
add_task(async function test_opens_amo_form_in_a_tab() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.abuseReport.amoFormEnabled", true],
|
||||
[
|
||||
"extensions.abuseReport.amoFormURL",
|
||||
"https://example.org/%LOCALE%/%APP%/feedback/addon/%addonID%/",
|
||||
],
|
||||
],
|
||||
});
|
||||
|
||||
await openAboutAddons();
|
||||
|
||||
Assert.equal(
|
||||
gManagerWindow.ABUSE_REPORT_AMO_FORM_ENABLED,
|
||||
true,
|
||||
"Expect AMO abuse report form to be enabled by default"
|
||||
);
|
||||
|
||||
const ADDON_ID = "test-ext@mochitest";
|
||||
const expectedUrl = Services.urlFormatter
|
||||
.formatURLPref("extensions.abuseReport.amoFormURL")
|
||||
.replace("%addonID%", ADDON_ID);
|
||||
|
||||
const promiseWaitForAMOFormTab = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
expectedUrl
|
||||
);
|
||||
info("Call about:addons openAbuseReport helper function");
|
||||
gManagerWindow.openAbuseReport({ addonId: ADDON_ID });
|
||||
info(`Wait for the AMO form url ${expectedUrl} to be opened in a new tab`);
|
||||
const tab = await promiseWaitForAMOFormTab;
|
||||
Assert.equal(
|
||||
tab.linkedBrowser.currentURI.spec,
|
||||
expectedUrl,
|
||||
"The newly opened tab has the expected url"
|
||||
);
|
||||
Assert.equal(gBrowser.selectedTab, tab, "The newly opened tab is selected");
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
await closeAboutAddons();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
@ -6,6 +6,13 @@
|
||||
loadTestSubscript("head_abuse_report.js");
|
||||
|
||||
add_setup(async function () {
|
||||
// Make sure the integrated abuse report panel is the one enabled
|
||||
// while this test file runs (instead of the AMO hosted form).
|
||||
// NOTE: behaviors expected when amoFormEnabled is true are tested
|
||||
// in the separate browser_amo_abuse_report.js test file.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.abuseReport.amoFormEnabled", false]],
|
||||
});
|
||||
await AbuseReportTestUtils.setup();
|
||||
});
|
||||
|
||||
|
@ -6,6 +6,13 @@
|
||||
loadTestSubscript("head_abuse_report.js");
|
||||
|
||||
add_setup(async function () {
|
||||
// Make sure the integrated abuse report panel is the one enabled
|
||||
// while this test file runs (instead of the AMO hosted form).
|
||||
// NOTE: behaviors expected when amoFormEnabled is true are tested
|
||||
// in the separate browser_amo_abuse_report.js test file.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.abuseReport.amoFormEnabled", false]],
|
||||
});
|
||||
await AbuseReportTestUtils.setup();
|
||||
});
|
||||
|
||||
|
@ -67,6 +67,11 @@ add_setup(async function () {
|
||||
set: [
|
||||
["extensions.webapi.testing", true],
|
||||
["extensions.abuseReport.amWebAPI.enabled", true],
|
||||
// Make sure the integrated abuse report panel is the one enabled
|
||||
// while this test file runs (instead of the AMO hosted form).
|
||||
// NOTE: behaviors expected when amoFormEnabled is true are tested
|
||||
// in the separate browser_amo_abuse_report.js test file.
|
||||
["extensions.abuseReport.amoFormEnabled", false],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user