Bug 1594025 - move 'this site is not deceptive' string into markup to allow help hamburger menu to copy it, r=flod,fluent-reviewers
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 05 Nov 2019 17:40:47 +0000
changeset 500631 489afa3eb121ff1ab70f405880acd757502d1e38
parent 500630 ab19234907a0e553676b1c1bd45d37c8627f85e9
child 500632 67f2b416b27017704978b551e172fe10e415bf0d
push id36768
push usershindli@mozilla.com
push dateTue, 05 Nov 2019 22:07:34 +0000
treeherdermozilla-central@e96c1ca93d25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflod, fluent-reviewers
bugs1594025
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1594025 - move 'this site is not deceptive' string into markup to allow help hamburger menu to copy it, r=flod,fluent-reviewers The help view copies strings from the main menubar. When we moved the original DTD string to ftl, there were performance implications for using it in browser.xhtml, so it was only added once needed. The help view copies attributes from the items in the main menubar's help menu, and so didn't copy the label for this item, resulting in the broken behaviour. To fix this, it's enough to have the string in the markup. As we've moved the other strings into menubar.ftl, I'm taking the opportunity to move this string there, too, next to its sibling string to report deceptive sites. Differential Revision: https://phabricator.services.mozilla.com/D51850
browser/base/content/browser-menubar.inc
browser/base/content/browser-safebrowsing.js
browser/locales/en-US/browser/menubar.ftl
python/l10n/fluent_migrations/bug_1594025_not_deceptive.py
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -468,16 +468,17 @@
                           disabled="true"
                           oncommand="openUILink(gSafeBrowsing.getReportURL('Phish'), event, {triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({})});"
                           onclick="checkForMiddleClick(this, event);"
                           hidden="true" data-l10n-id="menu-help-report-deceptive-site"/>
                 <menuitem id="menu_HelpPopup_reportPhishingErrortoolmenu"
                           disabled="true"
                           oncommand="ReportFalseDeceptiveSite();"
                           onclick="checkForMiddleClick(this, event);"
+                          data-l10n-id="menu-help-not-deceptive"
                           hidden="true"/>
                 <menuseparator id="helpPolicySeparator"
                           hidden="true"/>
                 <menuitem id="helpPolicySupport"
                           hidden="true"
                           oncommand="openUILinkIn(Services.policies.getSupportMenu().URL.href, 'tab', {triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({})});"
                           onclick="checkForMiddleClick(this, event);"/>
                 <menuseparator id="aboutSeparator"/>
--- a/browser/base/content/browser-safebrowsing.js
+++ b/browser/base/content/browser-safebrowsing.js
@@ -20,20 +20,16 @@ var gSafeBrowsing = {
     const reportMenu = document.getElementById(
       "menu_HelpPopup_reportPhishingtoolmenu"
     );
     reportMenu.hidden = isPhishingPage;
     const reportErrorMenu = document.getElementById(
       "menu_HelpPopup_reportPhishingErrortoolmenu"
     );
     reportErrorMenu.hidden = !isPhishingPage;
-    if (isPhishingPage && !reportErrorMenu.hasAttribute("data-l10n-id")) {
-      MozXULElement.insertFTLIfNeeded("browser/safebrowsing/blockedSite.ftl");
-      document.l10n.setAttributes(reportErrorMenu, "safeb-palm-notdeceptive");
-    }
 
     // Now look at the currentURI to learn which page we were trying
     // to browse to.
     const uri = gBrowser.currentURI;
     const isReportablePage =
       uri && (uri.schemeIs("http") || uri.schemeIs("https"));
 
     const disabledByPolicy = !Services.policies.isAllowed("feedbackCommands");
--- a/browser/locales/en-US/browser/menubar.ftl
+++ b/browser/locales/en-US/browser/menubar.ftl
@@ -273,13 +273,15 @@ menu-help-feedback-page =
     .accesskey = S
 menu-help-safe-mode-without-addons =
     .label = Restart with Add-ons Disabled…
     .accesskey = R
 menu-help-safe-mode-with-addons =
     .label = Restart with Add-ons Enabled
     .accesskey = R
 # Label of the Help menu item. Either this or
-# safeb.palm.notdeceptive.label from
-# phishing-afterload-warning-message.dtd is shown.
+# menu-help-notdeceptive is shown.
 menu-help-report-deceptive-site =
     .label = Report Deceptive Site…
     .accesskey = D
+menu-help-not-deceptive =
+    .label = This isn’t a deceptive site…
+    .accesskey = d
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1594025_not_deceptive.py
@@ -0,0 +1,24 @@
+# coding=utf8
+
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+from __future__ import absolute_import
+import fluent.syntax.ast as FTL
+from fluent.migrate.helpers import transforms_from
+from fluent.migrate import COPY_PATTERN
+
+
+def migrate(ctx):
+    """Bug 1594025 - move 'This isn't a deceptive site' string to menubar.ftl, part {index}."""
+
+    ctx.add_transforms(
+        'browser/browser/menubar.ftl',
+        'browser/browser/menubar.ftl',
+        transforms_from(
+"""
+menu-help-not-deceptive =
+    .label = {COPY_PATTERN(from_path, "safeb-palm-notdeceptive.label")}
+    .accesskey = {COPY_PATTERN(from_path, "safeb-palm-notdeceptive.accesskey")}
+""", from_path="browser/browser/safebrowsing/blockedSite.ftl")
+    )