mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1578831 - Link directly to breakage report subview when ETP is off. r=timhuang,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D47574 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
1b5e3a918d
commit
a13671e1aa
@ -1176,6 +1176,12 @@ var gProtectionsHandler = {
|
||||
"protections-popup-tp-switch-breakage-link"
|
||||
));
|
||||
},
|
||||
get _protectionsPopupTPSwitchBreakageFixedLink() {
|
||||
delete this._protectionsPopupTPSwitchBreakageFixedLink;
|
||||
return (this._protectionsPopupTPSwitchBreakageFixedLink = document.getElementById(
|
||||
"protections-popup-tp-switch-breakage-fixed-link"
|
||||
));
|
||||
},
|
||||
get _protectionsPopupTPSwitchSection() {
|
||||
delete this._protectionsPopupTPSwitchSection;
|
||||
return (this._protectionsPopupTPSwitchSection = document.getElementById(
|
||||
@ -2211,6 +2217,10 @@ var gProtectionsHandler = {
|
||||
ContentBlockingAllowList.includes(gBrowser.selectedBrowser) ||
|
||||
!this._protectionsPopup.hasAttribute("blocking") ||
|
||||
!this._protectionsPopupTPSwitch.hasAttribute("enabled");
|
||||
// The "Site Fixed?" link behaves similarly but for the opposite state.
|
||||
this._protectionsPopupTPSwitchBreakageFixedLink.hidden =
|
||||
!ContentBlockingAllowList.includes(gBrowser.selectedBrowser) ||
|
||||
this._protectionsPopupTPSwitch.hasAttribute("enabled");
|
||||
},
|
||||
|
||||
submitBreakageReport(uri) {
|
||||
@ -2271,6 +2281,7 @@ var gProtectionsHandler = {
|
||||
body += `${Cryptomining.PREF_ENABLED}: ${Services.prefs.getBoolPref(
|
||||
Cryptomining.PREF_ENABLED
|
||||
)}\n`;
|
||||
body += `\nhasException: ${this.hasException}\n`;
|
||||
|
||||
body += "\n**Comments**\n" + commentsTextarea.value;
|
||||
|
||||
@ -2283,9 +2294,7 @@ var gProtectionsHandler = {
|
||||
}
|
||||
}
|
||||
|
||||
if (activatedBlockers.length) {
|
||||
formData.set("labels", activatedBlockers.join(","));
|
||||
}
|
||||
formData.set("labels", activatedBlockers.join(","));
|
||||
|
||||
this._protectionsPopupSendReportButton.disabled = true;
|
||||
|
||||
|
@ -67,6 +67,50 @@ add_task(async function testToggleSwitch() {
|
||||
"The 'Site not working?' link should be visible."
|
||||
);
|
||||
|
||||
// The 'Site Fixed?' link should be hidden.
|
||||
ok(
|
||||
BrowserTestUtils.is_hidden(
|
||||
gProtectionsHandler._protectionsPopupTPSwitchBreakageFixedLink
|
||||
),
|
||||
"The 'Site Fixed?' link should be hidden."
|
||||
);
|
||||
|
||||
// Navigate through the 'Site Not Working?' flow and back to the main view,
|
||||
// checking for telemetry on the way.
|
||||
let siteNotWorkingView = document.getElementById(
|
||||
"protections-popup-siteNotWorkingView"
|
||||
);
|
||||
let viewShown = BrowserTestUtils.waitForEvent(
|
||||
siteNotWorkingView,
|
||||
"ViewShown"
|
||||
);
|
||||
gProtectionsHandler._protectionsPopupTPSwitchBreakageLink.click();
|
||||
await viewShown;
|
||||
|
||||
checkClickTelemetry("sitenotworking_link");
|
||||
|
||||
let sendReportButton = document.getElementById(
|
||||
"protections-popup-siteNotWorkingView-sendReport"
|
||||
);
|
||||
let sendReportView = document.getElementById(
|
||||
"protections-popup-sendReportView"
|
||||
);
|
||||
viewShown = BrowserTestUtils.waitForEvent(sendReportView, "ViewShown");
|
||||
sendReportButton.click();
|
||||
await viewShown;
|
||||
|
||||
checkClickTelemetry("send_report_link");
|
||||
|
||||
viewShown = BrowserTestUtils.waitForEvent(siteNotWorkingView, "ViewShown");
|
||||
sendReportView.querySelector(".subviewbutton-back").click();
|
||||
await viewShown;
|
||||
|
||||
let mainView = document.getElementById("protections-popup-mainView");
|
||||
|
||||
viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
|
||||
siteNotWorkingView.querySelector(".subviewbutton-back").click();
|
||||
await viewShown;
|
||||
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopupTPSwitch.hasAttribute("enabled"),
|
||||
"TP Switch should be enabled"
|
||||
@ -85,6 +129,13 @@ add_task(async function testToggleSwitch() {
|
||||
),
|
||||
"The 'Site not working?' link should be hidden after TP switch turns to off."
|
||||
);
|
||||
// Same for the 'Site Fixed?' link
|
||||
ok(
|
||||
BrowserTestUtils.is_hidden(
|
||||
gProtectionsHandler._protectionsPopupTPSwitchBreakageFixedLink
|
||||
),
|
||||
"The 'Site Fixed?' link should be hidden."
|
||||
);
|
||||
|
||||
await popuphiddenPromise;
|
||||
checkClickTelemetry("etp_toggle_off");
|
||||
@ -121,6 +172,25 @@ add_task(async function testToggleSwitch() {
|
||||
"The 'Site not working?' link should be hidden if TP is off."
|
||||
);
|
||||
|
||||
// The 'Site Fixed?' link should be shown if TP is off.
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(
|
||||
gProtectionsHandler._protectionsPopupTPSwitchBreakageFixedLink
|
||||
),
|
||||
"The 'Site Fixed?' link should be visible."
|
||||
);
|
||||
|
||||
// Check telemetry for 'Site Fixed?' link.
|
||||
viewShown = BrowserTestUtils.waitForEvent(sendReportView, "ViewShown");
|
||||
gProtectionsHandler._protectionsPopupTPSwitchBreakageFixedLink.click();
|
||||
await viewShown;
|
||||
|
||||
checkClickTelemetry("sitenotworking_link", "sitefixed");
|
||||
|
||||
viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
|
||||
sendReportView.querySelector(".subviewbutton-back").click();
|
||||
await viewShown;
|
||||
|
||||
// Click the TP switch again and check the visibility of the 'Site not
|
||||
// Working?'. It should be hidden after toggling the TP switch.
|
||||
browserLoadedPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
|
||||
@ -133,6 +203,12 @@ add_task(async function testToggleSwitch() {
|
||||
`The 'Site not working?' link should be still hidden after toggling TP
|
||||
switch to on from off.`
|
||||
);
|
||||
ok(
|
||||
BrowserTestUtils.is_hidden(
|
||||
gProtectionsHandler._protectionsPopupTPSwitchBreakageFixedLink
|
||||
),
|
||||
"The 'Site Fixed?' link should be hidden."
|
||||
);
|
||||
|
||||
await browserLoadedPromise;
|
||||
checkClickTelemetry("etp_toggle_on");
|
||||
|
@ -84,7 +84,7 @@ function checkClickTelemetry(objectName, value) {
|
||||
e[1] == "security.ui.protectionspopup" &&
|
||||
e[2] == "click" &&
|
||||
e[3] == objectName &&
|
||||
(!value || e[4] == value)
|
||||
e[4] === value
|
||||
);
|
||||
is(buttonEvents.length, 1, `recorded ${objectName} telemetry event`);
|
||||
}
|
||||
|
@ -111,6 +111,48 @@ add_task(async function testReportBreakageCancel() {
|
||||
Services.prefs.clearUserPref(TP_PREF);
|
||||
});
|
||||
|
||||
add_task(async function testReportBreakageSiteException() {
|
||||
Services.prefs.setBoolPref(TP_PREF, true);
|
||||
|
||||
let url = TRACKING_PAGE + "?a=b&1=abc&unicode=🦊";
|
||||
|
||||
await BrowserTestUtils.withNewTab(url, async browser => {
|
||||
let loaded = BrowserTestUtils.browserLoaded(browser, false);
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
await loaded;
|
||||
|
||||
await openProtectionsPopup();
|
||||
|
||||
let siteFixedButton = document.getElementById(
|
||||
"protections-popup-tp-switch-breakage-fixed-link"
|
||||
);
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(siteFixedButton),
|
||||
"site fixed button is visible"
|
||||
);
|
||||
let sendReportView = document.getElementById(
|
||||
"protections-popup-sendReportView"
|
||||
);
|
||||
let viewShown = BrowserTestUtils.waitForEvent(sendReportView, "ViewShown");
|
||||
siteFixedButton.click();
|
||||
await viewShown;
|
||||
|
||||
ok(true, "Report breakage view was shown");
|
||||
|
||||
await testReportBreakageSubmit(
|
||||
TRACKING_PAGE,
|
||||
"trackingprotection",
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
// Pass false for shouldReload - there's no need since the tab is going away.
|
||||
gProtectionsHandler.enableForCurrentPage(false);
|
||||
});
|
||||
|
||||
Services.prefs.clearUserPref(TP_PREF);
|
||||
});
|
||||
|
||||
add_task(async function testNoTracking() {
|
||||
await BrowserTestUtils.withNewTab(BENIGN_PAGE, async function() {
|
||||
await openProtectionsPopup();
|
||||
@ -130,7 +172,7 @@ add_task(async function testReportBreakageError() {
|
||||
// Make sure that we correctly strip the query.
|
||||
let url = TRACKING_PAGE + "?a=b&1=abc&unicode=🦊";
|
||||
await BrowserTestUtils.withNewTab(url, async function() {
|
||||
await testReportBreakage(TRACKING_PAGE, "trackingprotection", true);
|
||||
await openAndTestReportBreakage(TRACKING_PAGE, "trackingprotection", true);
|
||||
});
|
||||
|
||||
Services.prefs.clearUserPref(TP_PREF);
|
||||
@ -141,7 +183,7 @@ add_task(async function testTP() {
|
||||
// Make sure that we correctly strip the query.
|
||||
let url = TRACKING_PAGE + "?a=b&1=abc&unicode=🦊";
|
||||
await BrowserTestUtils.withNewTab(url, async function() {
|
||||
await testReportBreakage(TRACKING_PAGE, "trackingprotection");
|
||||
await openAndTestReportBreakage(TRACKING_PAGE, "trackingprotection");
|
||||
});
|
||||
|
||||
Services.prefs.clearUserPref(TP_PREF);
|
||||
@ -155,7 +197,7 @@ add_task(async function testCR() {
|
||||
// Make sure that we correctly strip the query.
|
||||
let url = COOKIE_PAGE + "?a=b&1=abc&unicode=🦊";
|
||||
await BrowserTestUtils.withNewTab(url, async function() {
|
||||
await testReportBreakage(COOKIE_PAGE, "cookierestrictions");
|
||||
await openAndTestReportBreakage(COOKIE_PAGE, "cookierestrictions");
|
||||
});
|
||||
|
||||
Services.prefs.clearUserPref(CB_PREF);
|
||||
@ -173,7 +215,7 @@ add_task(async function testFP() {
|
||||
});
|
||||
await promise;
|
||||
|
||||
await testReportBreakage(TRACKING_PAGE, "fingerprinting");
|
||||
await openAndTestReportBreakage(TRACKING_PAGE, "fingerprinting", true);
|
||||
});
|
||||
|
||||
Services.prefs.clearUserPref(FP_PREF);
|
||||
@ -192,26 +234,14 @@ add_task(async function testCM() {
|
||||
});
|
||||
await promise;
|
||||
|
||||
await testReportBreakage(TRACKING_PAGE, "cryptomining");
|
||||
await openAndTestReportBreakage(TRACKING_PAGE, "cryptomining", true);
|
||||
});
|
||||
|
||||
Services.prefs.clearUserPref(CM_PREF);
|
||||
Services.prefs.clearUserPref(CB_PREF);
|
||||
});
|
||||
|
||||
async function testReportBreakage(url, tags, error = false) {
|
||||
// Setup a mock server for receiving breakage reports.
|
||||
let server = new HttpServer();
|
||||
server.start(-1);
|
||||
let i = server.identity;
|
||||
let path =
|
||||
i.primaryScheme + "://" + i.primaryHost + ":" + i.primaryPort + "/";
|
||||
|
||||
Services.prefs.setStringPref(PREF_REPORT_BREAKAGE_URL, path);
|
||||
|
||||
await TestUtils.waitForCondition(() =>
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("blocking")
|
||||
);
|
||||
async function openAndTestReportBreakage(url, tags, error = false) {
|
||||
await openProtectionsPopup();
|
||||
|
||||
let siteNotWorkingButton = document.getElementById(
|
||||
@ -243,6 +273,20 @@ async function testReportBreakage(url, tags, error = false) {
|
||||
|
||||
ok(true, "Report breakage view was shown");
|
||||
|
||||
await testReportBreakageSubmit(url, tags, error, false);
|
||||
}
|
||||
|
||||
// This function assumes that the breakage report view is ready.
|
||||
async function testReportBreakageSubmit(url, tags, error, hasException) {
|
||||
// Setup a mock server for receiving breakage reports.
|
||||
let server = new HttpServer();
|
||||
server.start(-1);
|
||||
let i = server.identity;
|
||||
let path =
|
||||
i.primaryScheme + "://" + i.primaryHost + ":" + i.primaryPort + "/";
|
||||
|
||||
Services.prefs.setStringPref(PREF_REPORT_BREAKAGE_URL, path);
|
||||
|
||||
let comments = document.getElementById(
|
||||
"protections-popup-sendReportView-collection-comments"
|
||||
);
|
||||
@ -307,10 +351,11 @@ async function testReportBreakage(url, tags, error = false) {
|
||||
`userAgent: ${navigator.userAgent}\r\n\r\n` +
|
||||
"**Preferences**\r\n" +
|
||||
`${prefsBody}\r\n` +
|
||||
`hasException: ${hasException}\r\n\r\n` +
|
||||
"**Comments**\r\n" +
|
||||
"This is a comment\r\n",
|
||||
'Content-Disposition: form-data; name="labels"\r\n\r\n' +
|
||||
`${tags}\r\n`,
|
||||
`${hasException ? "" : tags}\r\n`,
|
||||
"",
|
||||
],
|
||||
"Should send the correct form data"
|
||||
|
@ -49,6 +49,10 @@
|
||||
<label id="protections-popup-tp-switch-breakage-link"
|
||||
class="text-link"
|
||||
onclick="gProtectionsHandler.showSiteNotWorkingView(); gProtectionsHandler.recordClick('sitenotworking_link');">&protections.siteNotWorking.label;</label>
|
||||
<label id="protections-popup-tp-switch-breakage-fixed-link"
|
||||
class="text-link"
|
||||
onclick="gProtectionsHandler.showSendReportView(); gProtectionsHandler.recordClick('sitenotworking_link', 'sitefixed');"
|
||||
data-l10n-id="protections-panel-sitefixedsendreport-label"></label>
|
||||
</vbox>
|
||||
<vbox class="protections-popup-tp-switch-box">
|
||||
<toolbarbutton id="protections-popup-tp-switch"
|
||||
|
@ -3,3 +3,6 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
protections-panel-sendreportview-error = There was an error sending the report. Please try again later.
|
||||
|
||||
# A link shown when ETP is disabled for a site. Opens the breakage report subview when clicked.
|
||||
protections-panel-sitefixedsendreport-label = Site fixed? Send report
|
||||
|
@ -942,7 +942,8 @@ description#identity-popup-content-verifier,
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#protections-popup-tp-switch-breakage-link {
|
||||
#protections-popup-tp-switch-breakage-link,
|
||||
#protections-popup-tp-switch-breakage-fixed-link {
|
||||
margin-top: calc(0.5 * var(--vertical-section-padding)) !important;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user