[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-80.0b2-10.0-1] fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#tor



commit c2228fa0593281dba61a9f4bad0014943a88d634
Author: Alex Catarineu <acat@xxxxxxxxxxxxxx>
Date:   Wed Aug 19 19:20:43 2020 +0200

    fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#tor
---
 .../torpreferences/content/requestBridgeDialog.jsm | 40 ++++++----------------
 .../content/requestBridgeDialog.xhtml              | 20 +++++------
 .../torpreferences/content/torLogDialog.jsm        |  3 +-
 .../torpreferences/content/torLogDialog.xhtml      | 13 +++----
 4 files changed, 30 insertions(+), 46 deletions(-)

diff --git a/browser/components/torpreferences/content/requestBridgeDialog.jsm b/browser/components/torpreferences/content/requestBridgeDialog.jsm
index 027e6a152655..45419d001a7b 100644
--- a/browser/components/torpreferences/content/requestBridgeDialog.jsm
+++ b/browser/components/torpreferences/content/requestBridgeDialog.jsm
@@ -8,12 +8,10 @@ const { TorStrings } = ChromeUtils.import("resource:///modules/TorStrings.jsm");
 class RequestBridgeDialog {
   constructor() {
     this._dialog = null;
-    this._submitCommand = null;
     this._submitButton = null;
     this._dialogDescription = null;
     this._captchaImage = null;
     this._captchaEntryTextbox = null;
-    this._captchaRefreshCommand = null;
     this._captchaRefreshButton = null;
     this._incorrectCaptchaHbox = null;
     this._incorrectCaptchaLabel = null;
@@ -26,12 +24,8 @@ class RequestBridgeDialog {
       submitButton:
         "accept" /* not really a selector but a key for dialog's getButton */,
       dialogDescription: "description#torPreferences-requestBridge-description",
-      submitCommand: "command#torPreferences-requestBridge-submitCommand",
       captchaImage: "image#torPreferences-requestBridge-captchaImage",
-      captchaEntryTextbox:
-        "input#torPreferences-requestBridge-captchaTextbox",
-      refreshCaptchaCommand:
-        "command#torPreferences-requestBridge-refreshCaptchaCommand",
+      captchaEntryTextbox: "input#torPreferences-requestBridge-captchaTextbox",
       refreshCaptchaButton:
         "button#torPreferences-requestBridge-refreshCaptchaButton",
       incorrectCaptchaHbox:
@@ -45,7 +39,8 @@ class RequestBridgeDialog {
     const selectors = RequestBridgeDialog.selectors;
 
     this._dialog = dialog;
-    this._dialog.setAttribute(
+    const dialogWin = dialog.parentElement;
+    dialogWin.setAttribute(
       "title",
       TorStrings.settings.requestBridgeDialogTitle
     );
@@ -61,16 +56,17 @@ class RequestBridgeDialog {
       } else if (bridges) {
         this._bridges = bridges;
         this._submitButton.disabled = false;
-        this._dialog.acceptDialog();
+        this._dialog.cancelDialog();
       }
     });
 
-    this._submitCommand = this._dialog.querySelector(selectors.submitCommand);
-
     this._submitButton = this._dialog.getButton(selectors.submitButton);
     this._submitButton.setAttribute("label", TorStrings.settings.submitCaptcha);
-    this._submitButton.setAttribute("command", this._submitCommand.id);
     this._submitButton.disabled = true;
+    this._dialog.addEventListener("dialogaccept", e => {
+      e.preventDefault();
+      this.onSubmitCaptcha();
+    });
 
     this._dialogDescription = this._dialog.querySelector(
       selectors.dialogDescription
@@ -93,30 +89,14 @@ class RequestBridgeDialog {
       TorStrings.settings.captchaTextboxPlaceholder
     );
     this._captchaEntryTextbox.disabled = true;
-    this._captchaEntryTextbox.onkeypress = evt => {
-      const ENTER_KEY = 13;
-      if (evt.keyCode == ENTER_KEY) {
-        // logically same as pressing the 'submit' button of the parent dialog
-        this.onSubmitCaptcha();
-        return false;
-      }
-      return true;
-    };
     // disable submit if entry textbox is empty
     this._captchaEntryTextbox.oninput = () => {
       this._submitButton.disabled = this._captchaEntryTextbox.value == "";
     };
 
-    this._captchaRefreshCommand = this._dialog.querySelector(
-      selectors.refreshCaptchaCommand
-    );
     this._captchaRefreshButton = this._dialog.querySelector(
       selectors.refreshCaptchaButton
     );
-    this._captchaRefreshButton.setAttribute(
-      "command",
-      this._captchaRefreshCommand.id
-    );
     this._captchaRefreshButton.disabled = true;
 
     this._incorrectCaptchaHbox = this._dialog.querySelector(
@@ -183,7 +163,9 @@ class RequestBridgeDialog {
         this._bridges = aBridges;
 
         this._submitButton.disabled = false;
-        this._dialog.acceptDialog();
+        // This was successful, but use cancelDialog() to close, since
+        // we intercept the `dialogaccept` event.
+        this._dialog.cancelDialog();
       })
       .catch(aError => {
         this._bridges = [];
diff --git a/browser/components/torpreferences/content/requestBridgeDialog.xhtml b/browser/components/torpreferences/content/requestBridgeDialog.xhtml
index 1081194caf50..64c4507807fb 100644
--- a/browser/components/torpreferences/content/requestBridgeDialog.xhtml
+++ b/browser/components/torpreferences/content/requestBridgeDialog.xhtml
@@ -3,13 +3,11 @@
 <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://browser/content/torpreferences/torPreferences.css"?>
 
-<dialog id="torPreferences-requestBridge-dialog" type="child" class="prefwindow"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-    xmlns:html="http://www.w3.org/1999/xhtml";
-    title="Request Bridge"
-    buttons="cancel,accept"
-    role="dialog">
-  <command id="torPreferences-requestBridge-submitCommand" oncommand="requestBridgeDialog.onSubmitCaptcha();"/>
+<window type="child"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+        xmlns:html="http://www.w3.org/1999/xhtml";>
+<dialog id="torPreferences-requestBridge-dialog"
+        buttons="accept,cancel">
   <!-- ok, so &#8203; is a zero-width space. We need to have *something* in the innerText so that XUL knows how tall the
        description node is so that it can determine how large to make the dialog element's inner draw area. If we have
        nothing in the innerText, then it collapse to 0 height, and the contents of the dialog ends up partially hidden >:( -->
@@ -18,8 +16,9 @@
   <image id="torPreferences-requestBridge-captchaImage" flex="1"/>
   <hbox id="torPreferences-requestBridge-inputHbox">
     <html:input id="torPreferences-requestBridge-captchaTextbox" type="text" style="-moz-box-flex: 1;"/>
-    <command id="torPreferences-requestBridge-refreshCaptchaCommand" oncommand="requestBridgeDialog.onRefreshCaptcha();"/>
-    <button id="torPreferences-requestBridge-refreshCaptchaButton" image="chrome://browser/skin/reload.svg"/>
+    <button id="torPreferences-requestBridge-refreshCaptchaButton"
+            image="chrome://browser/skin/reload.svg"
+            oncommand="requestBridgeDialog.onRefreshCaptcha();"/>
   </hbox>
   <hbox id="torPreferences-requestBridge-incorrectCaptchaHbox" align="center">
     <image id="torPreferences-requestBridge-errorIcon" />
@@ -32,4 +31,5 @@
     let dialog = document.getElementById("torPreferences-requestBridge-dialog");
     requestBridgeDialog.init(window, dialog);
   ]]></script>
-</dialog>
\ No newline at end of file
+</dialog>
+</window>
\ No newline at end of file
diff --git a/browser/components/torpreferences/content/torLogDialog.jsm b/browser/components/torpreferences/content/torLogDialog.jsm
index 70e49ac048f8..ba4b76738447 100644
--- a/browser/components/torpreferences/content/torLogDialog.jsm
+++ b/browser/components/torpreferences/content/torLogDialog.jsm
@@ -23,7 +23,8 @@ class TorLogDialog {
 
   _populateXUL(aDialog) {
     this._dialog = aDialog;
-    this._dialog.setAttribute("title", TorStrings.settings.torLogDialogTitle);
+    const dialogWin = this._dialog.parentElement;
+    dialogWin.setAttribute("title", TorStrings.settings.torLogDialogTitle);
 
     this._logTextarea = this._dialog.querySelector(
       TorLogDialog.selectors.logTextarea
diff --git a/browser/components/torpreferences/content/torLogDialog.xhtml b/browser/components/torpreferences/content/torLogDialog.xhtml
index ae0f4b294204..9c17f8132978 100644
--- a/browser/components/torpreferences/content/torLogDialog.xhtml
+++ b/browser/components/torpreferences/content/torLogDialog.xhtml
@@ -3,11 +3,11 @@
 <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://browser/content/torpreferences/torPreferences.css"?>
 
-<dialog id="torPreferences-torLog-dialog" type="child" class="prefwindow"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-    xmlns:html="http://www.w3.org/1999/xhtml";
-    buttons="accept,extra1"
-    role="dialog">
+<window type="child"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+        xmlns:html="http://www.w3.org/1999/xhtml";>
+<dialog id="torPreferences-torLog-dialog"
+    buttons="accept,extra1">
   <html:textarea
     id="torPreferences-torDialog-textarea"
     multiline="true"
@@ -19,4 +19,5 @@
     let dialog = document.getElementById("torPreferences-torLog-dialog");
     torLogDialog.init(window, dialog);
   ]]></script>
-</dialog>
\ No newline at end of file
+</dialog>
+</window>
\ No newline at end of file

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits