mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Bug 1582751 - Show an error message when content blocking breakage reporting fails. r=nhnt11,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D51382 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c9f3ddcbdb
commit
be50883421
@ -1227,6 +1227,12 @@ var gProtectionsHandler = {
|
|||||||
"protections-popup-siteNotWorking-tp-switch"
|
"protections-popup-siteNotWorking-tp-switch"
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
get _protectionsPopupSiteNotWorkingReportError() {
|
||||||
|
delete this._protectionsPopupSiteNotWorkingReportError;
|
||||||
|
return (this._protectionsPopupSiteNotWorkingReportError = document.getElementById(
|
||||||
|
"protections-popup-sendReportView-report-error"
|
||||||
|
));
|
||||||
|
},
|
||||||
get _protectionsPopupSendReportLearnMore() {
|
get _protectionsPopupSendReportLearnMore() {
|
||||||
delete this._protectionsPopupSendReportLearnMore;
|
delete this._protectionsPopupSendReportLearnMore;
|
||||||
return (this._protectionsPopupSendReportLearnMore = document.getElementById(
|
return (this._protectionsPopupSendReportLearnMore = document.getElementById(
|
||||||
@ -1239,6 +1245,12 @@ var gProtectionsHandler = {
|
|||||||
"protections-popup-sendReportView-collection-url"
|
"protections-popup-sendReportView-collection-url"
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
get _protectionsPopupSendReportButton() {
|
||||||
|
delete this._protectionsPopupSendReportButton;
|
||||||
|
return (this._protectionsPopupSendReportButton = document.getElementById(
|
||||||
|
"protections-popup-sendReportView-submit"
|
||||||
|
));
|
||||||
|
},
|
||||||
get _trackingProtectionIconTooltipLabel() {
|
get _trackingProtectionIconTooltipLabel() {
|
||||||
delete this._trackingProtectionIconTooltipLabel;
|
delete this._trackingProtectionIconTooltipLabel;
|
||||||
return (this._trackingProtectionIconTooltipLabel = document.getElementById(
|
return (this._trackingProtectionIconTooltipLabel = document.getElementById(
|
||||||
@ -2159,7 +2171,12 @@ var gProtectionsHandler = {
|
|||||||
"?" + this.reportURI.query,
|
"?" + this.reportURI.query,
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
|
let commentsTextarea = document.getElementById(
|
||||||
|
"protections-popup-sendReportView-collection-comments"
|
||||||
|
);
|
||||||
|
commentsTextarea.value = "";
|
||||||
this._protectionsPopupSendReportURL.value = urlWithoutQuery;
|
this._protectionsPopupSendReportURL.value = urlWithoutQuery;
|
||||||
|
this._protectionsPopupSiteNotWorkingReportError.hidden = true;
|
||||||
this._protectionsPopupMultiView.showSubView(
|
this._protectionsPopupMultiView.showSubView(
|
||||||
"protections-popup-sendReportView"
|
"protections-popup-sendReportView"
|
||||||
);
|
);
|
||||||
@ -2255,28 +2272,30 @@ var gProtectionsHandler = {
|
|||||||
formData.set("labels", activatedBlockers.join(","));
|
formData.set("labels", activatedBlockers.join(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._protectionsPopupSendReportButton.disabled = true;
|
||||||
|
|
||||||
fetch(reportEndpoint, {
|
fetch(reportEndpoint, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "omit",
|
credentials: "omit",
|
||||||
body: formData,
|
body: formData,
|
||||||
})
|
})
|
||||||
.then(function(response) {
|
.then(response => {
|
||||||
|
this._protectionsPopupSendReportButton.disabled = false;
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
Cu.reportError(
|
Cu.reportError(
|
||||||
`Content Blocking report to ${reportEndpoint} failed with status ${
|
`Content Blocking report to ${reportEndpoint} failed with status ${
|
||||||
response.status
|
response.status
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
|
this._protectionsPopupSiteNotWorkingReportError.hidden = false;
|
||||||
} else {
|
} else {
|
||||||
// Clear the textarea value when the report is submitted
|
this._protectionsPopup.hidePopup();
|
||||||
commentsTextarea.value = "";
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(Cu.reportError);
|
.catch(Cu.reportError);
|
||||||
},
|
},
|
||||||
|
|
||||||
onSendReportClicked() {
|
onSendReportClicked() {
|
||||||
this._protectionsPopup.hidePopup();
|
|
||||||
this.submitBreakageReport(this.reportURI);
|
this.submitBreakageReport(this.reportURI);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
<html:link rel="localization" href="browser/branding/sync-brand.ftl"/>
|
<html:link rel="localization" href="browser/branding/sync-brand.ftl"/>
|
||||||
<html:link rel="localization" href="browser/browser.ftl"/>
|
<html:link rel="localization" href="browser/browser.ftl"/>
|
||||||
<html:link rel="localization" href="browser/menubar.ftl"/>
|
<html:link rel="localization" href="browser/menubar.ftl"/>
|
||||||
|
<html:link rel="localization" href="browser/protectionsPanel.ftl"/>
|
||||||
<html:link rel="localization" href="browser/appmenu.ftl"/>
|
<html:link rel="localization" href="browser/appmenu.ftl"/>
|
||||||
<html:link rel="localization" href="browser/readerView.ftl"/>
|
<html:link rel="localization" href="browser/readerView.ftl"/>
|
||||||
</linkset>
|
</linkset>
|
||||||
|
@ -122,6 +122,17 @@ add_task(async function testNoTracking() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
add_task(async function testReportBreakageError() {
|
||||||
|
Services.prefs.setBoolPref(TP_PREF, true);
|
||||||
|
// 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);
|
||||||
|
});
|
||||||
|
|
||||||
|
Services.prefs.clearUserPref(TP_PREF);
|
||||||
|
});
|
||||||
|
|
||||||
add_task(async function testTP() {
|
add_task(async function testTP() {
|
||||||
Services.prefs.setBoolPref(TP_PREF, true);
|
Services.prefs.setBoolPref(TP_PREF, true);
|
||||||
// Make sure that we correctly strip the query.
|
// Make sure that we correctly strip the query.
|
||||||
@ -185,7 +196,7 @@ add_task(async function testCM() {
|
|||||||
Services.prefs.clearUserPref(CB_PREF);
|
Services.prefs.clearUserPref(CB_PREF);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function testReportBreakage(url, tags) {
|
async function testReportBreakage(url, tags, error = false) {
|
||||||
// Setup a mock server for receiving breakage reports.
|
// Setup a mock server for receiving breakage reports.
|
||||||
let server = new HttpServer();
|
let server = new HttpServer();
|
||||||
server.start(-1);
|
server.start(-1);
|
||||||
@ -299,6 +310,12 @@ async function testReportBreakage(url, tags) {
|
|||||||
"Should send the correct form data"
|
"Should send the correct form data"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
response.setStatusLine(request.httpVersion, 500, "Request failed");
|
||||||
|
} else {
|
||||||
|
response.setStatusLine(request.httpVersion, 201, "Entry created");
|
||||||
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -306,6 +323,23 @@ async function testReportBreakage(url, tags) {
|
|||||||
submitButton.click();
|
submitButton.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let errorMessage = document.getElementById(
|
||||||
|
"protections-popup-sendReportView-report-error"
|
||||||
|
);
|
||||||
|
if (error) {
|
||||||
|
await BrowserTestUtils.waitForCondition(() =>
|
||||||
|
BrowserTestUtils.is_visible(errorMessage)
|
||||||
|
);
|
||||||
|
is(
|
||||||
|
comments.value,
|
||||||
|
"This is a comment",
|
||||||
|
"Comment not cleared in case of an error"
|
||||||
|
);
|
||||||
|
gProtectionsHandler._protectionsPopup.hidePopup();
|
||||||
|
} else {
|
||||||
|
ok(BrowserTestUtils.is_hidden(errorMessage), "Error message not shown");
|
||||||
|
}
|
||||||
|
|
||||||
await popuphidden;
|
await popuphidden;
|
||||||
|
|
||||||
// Stop the server.
|
// Stop the server.
|
||||||
|
@ -310,6 +310,9 @@
|
|||||||
<label control="protections-popup-sendReportView-collection-comments">&contentBlocking.breakageReportView2.collection.comments.label;</label>
|
<label control="protections-popup-sendReportView-collection-comments">&contentBlocking.breakageReportView2.collection.comments.label;</label>
|
||||||
<html:textarea id="protections-popup-sendReportView-collection-comments" aria-label="&contentBlocking.breakageReportView2.collection.comments.label;"/>
|
<html:textarea id="protections-popup-sendReportView-collection-comments" aria-label="&contentBlocking.breakageReportView2.collection.comments.label;"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
<label id="protections-popup-sendReportView-report-error"
|
||||||
|
data-l10n-id="protections-panel-sendreportview-error"
|
||||||
|
hidden="true" role="alert"></label>
|
||||||
</vbox>
|
</vbox>
|
||||||
<vbox id="protections-popup-sendReportView-footer"
|
<vbox id="protections-popup-sendReportView-footer"
|
||||||
class="panel-footer">
|
class="panel-footer">
|
||||||
|
5
browser/locales/en-US/browser/protectionsPanel.ftl
Normal file
5
browser/locales/en-US/browser/protectionsPanel.ftl
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# 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/.
|
||||||
|
|
||||||
|
protections-panel-sendreportview-error = There was an error sending the report. Please try again later.
|
@ -479,6 +479,11 @@ description#identity-popup-content-verifier,
|
|||||||
margin-inline-start: 0;
|
margin-inline-start: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#protections-popup-sendReportView-report-error {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
color: #d74345;
|
||||||
|
}
|
||||||
|
|
||||||
.protections-popup-category {
|
.protections-popup-category {
|
||||||
/* Overwrite toolbarbutton styles */
|
/* Overwrite toolbarbutton styles */
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
|
Loading…
Reference in New Issue
Block a user