[tbb-commits] [Git][tpo/applications/tor-browser][base-browser-115.11.0esr-13.5-1] 2 commits: fixup! Bug 40925: Implemented the Security Level component

ma1 (@ma1) git at gitlab.torproject.org
Thu May 16 14:13:39 UTC 2024



ma1 pushed to branch base-browser-115.11.0esr-13.5-1 at The Tor Project / Applications / Tor Browser


Commits:
b6dc6774 by Henry Wilkes at 2024-05-16T16:13:07+02:00
fixup! Bug 40925: Implemented the Security Level component

Bug 42583: Use moz-support-link for the security level "Learn more"
links. These take you to the tor project web link in base browser.

- - - - -
cb6a91ea by Henry Wilkes at 2024-05-16T16:13:08+02:00
Bug 42583: Modify moz-support-link for Base Browser.

- - - - -


4 changed files:

- browser/components/securitylevel/content/securityLevel.js
- browser/components/securitylevel/content/securityLevelPanel.inc.xhtml
- browser/components/securitylevel/content/securityLevelPreferences.inc.xhtml
- toolkit/content/widgets/moz-support-link/moz-support-link.mjs


Changes:

=====================================
browser/components/securitylevel/content/securityLevel.js
=====================================
@@ -157,6 +157,9 @@ var SecurityLevelPanel = {
   _populated: false,
 
   _populateXUL() {
+    // TODO: Used for #securityLevel-learnMore. Remove with esr 128.
+    window.ensureCustomElements("moz-support-link");
+
     this._elements = {
       panel: document.getElementById("securityLevel-panel"),
       background: document.getElementById("securityLevel-background"),
@@ -171,9 +174,7 @@ var SecurityLevelPanel = {
 
     const learnMoreEl = document.getElementById("securityLevel-learnMore");
     learnMoreEl.addEventListener("click", event => {
-      window.openTrustedLinkIn(learnMoreEl.href, "tab");
       this.hide();
-      event.preventDefault();
     });
 
     this._elements.restoreDefaultsButton.addEventListener("command", () => {


=====================================
browser/components/securitylevel/content/securityLevelPanel.inc.xhtml
=====================================
@@ -23,9 +23,10 @@
     </html:p>
     <html:p id="securityLevel-summary"></html:p>
     <html:a
+      is="moz-support-link"
       id="securityLevel-learnMore"
+      tor-manual-page="security-settings"
       data-l10n-id="security-level-panel-learn-more-link"
-      href="about:manual#security-settings"
     ></html:a>
   </vbox>
   <hbox class="panel-footer">


=====================================
browser/components/securitylevel/content/securityLevelPreferences.inc.xhtml
=====================================
@@ -12,14 +12,11 @@
         class="tail-with-learn-more"
         data-l10n-id="security-level-preferences-overview"
       ></html:span>
-      <label
-        id="securityLevel-learnMore"
-        class="learnMore text-link"
-        is="text-link"
+      <html:a
+        is="moz-support-link"
+        tor-manual-page="security-settings"
         data-l10n-id="security-level-preferences-learn-more-link"
-        href="about:manual#security-settings"
-        useoriginprincipal="true"
-      />
+      ></html:a>
     </description>
     <hbox
       id="securityLevel-customNotification"


=====================================
toolkit/content/widgets/moz-support-link/moz-support-link.mjs
=====================================
@@ -17,7 +17,9 @@ MozXULElement.insertFTLIfNeeded("browser/components/mozSupportLink.ftl");
 export default class MozSupportLink extends HTMLAnchorElement {
   static SUPPORT_URL = "https://www.mozilla.org/";
   static get observedAttributes() {
-    return ["support-page", "utm-content"];
+    // We add tor-manual-page for pages hosted at tor project. Also shared with
+    // base-browser/mullvad-browser. See tor-browser#42583.
+    return ["support-page", "utm-content", "tor-manual-page"];
   }
 
   /**
@@ -96,12 +98,33 @@ export default class MozSupportLink extends HTMLAnchorElement {
   }
 
   attributeChangedCallback(attrName, oldVal, newVal) {
-    if (attrName === "support-page" || attrName === "utm-content") {
+    if (
+      attrName === "support-page" ||
+      attrName === "utm-content" ||
+      attrName === "tor-manual-page"
+    ) {
       this.#setHref();
     }
   }
 
   #setHref() {
+    let torManualPage = this.getAttribute("tor-manual-page");
+    if (torManualPage) {
+      const [page, anchor] = torManualPage.split("_", 2);
+
+      let locale = Services.locale.appLocaleAsBCP47;
+      if (locale === "ja-JP-macos") {
+        // Convert quirk-locale to the locale used for tor project.
+        locale = "ja";
+      }
+
+      let href = `https://tb-manual.torproject.org/${locale}/${page}/`;
+      if (anchor) {
+        href = `${href}#${anchor}`;
+      }
+      this.href = href;
+      return;
+    }
     let supportPage = this.getAttribute("support-page") ?? "";
     let base = MozSupportLink.SUPPORT_URL + supportPage;
     this.href = this.hasAttribute("utm-content")
@@ -122,21 +145,7 @@ customElements.define("moz-support-link", MozSupportLink, { extends: "a" });
  *          Otherwise the url in unmodified form.
  */
 export function formatUTMParams(contentAttribute, url) {
-  if (!contentAttribute) {
-    return url;
-  }
-  let parsedUrl = new URL(url);
-  let domain = `.${parsedUrl.hostname}`;
-  if (
-    !domain.endsWith(".mozilla.org") &&
-    // For testing: addons-dev.allizom.org and addons.allizom.org
-    !domain.endsWith(".allizom.org")
-  ) {
-    return url;
-  }
-
-  parsedUrl.searchParams.set("utm_source", "firefox-browser");
-  parsedUrl.searchParams.set("utm_medium", "firefox-browser");
-  parsedUrl.searchParams.set("utm_content", contentAttribute);
-  return parsedUrl.href;
+  // Do not add utm parameters. See tor-browser#42583.
+  // NOTE: This method is also present in about:addons.
+  return url;
 }



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/4384bb33aea67256bf0d3e6b48aa231455268448...cb6a91eab189ce7376a24d76352b4828da6e3e3a

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/4384bb33aea67256bf0d3e6b48aa231455268448...cb6a91eab189ce7376a24d76352b4828da6e3e3a
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240516/43e37fe6/attachment-0001.htm>


More information about the tbb-commits mailing list