commit 0467379f524273ed810b5c21d6a8eb16d00445cb Author: Kathy Brade brade@pearlcrescent.com Date: Thu Sep 11 14:10:55 2014 -0400
Bug 13138: ESR31-about:tor shows "Tor is not working"
In Firefox 26 and newer, the BrowserOnAboutPageLoad() function that Torbutton previously used to detect about:tor page loads has been removed. The new approach is to have about:tor dispatch a custom event (which is the same approach Mozilla uses for about:home). --- src/chrome/content/aboutTor/aboutTor.xhtml | 7 ++++++- src/chrome/content/torbutton.js | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/chrome/content/aboutTor/aboutTor.xhtml b/src/chrome/content/aboutTor/aboutTor.xhtml index f8f829d..c13f60e 100644 --- a/src/chrome/content/aboutTor/aboutTor.xhtml +++ b/src/chrome/content/aboutTor/aboutTor.xhtml @@ -21,7 +21,7 @@ <title>&aboutTor.title;</title> <link rel="stylesheet" type="text/css" media="all" href="chrome://torbutton/skin/aboutTor.css"/> -<script type="text/javascript"> +<script type="text/javascript;version=1.7"> <![CDATA[ function onLoad() { @@ -125,6 +125,11 @@ function insertPropertyStrings() } catch(e) {}; }
+window.addEventListener("pageshow", function() { + let evt = new CustomEvent("AboutTorLoad", { bubbles: true }); + document.dispatchEvent(evt); +}); + ]]> </script> </head> diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js index 4ca6614..9b7ade2 100644 --- a/src/chrome/content/torbutton.js +++ b/src/chrome/content/torbutton.js @@ -506,9 +506,10 @@ function torbutton_init() { } }
- // Add our hook into about page load - m_tb_orig_BrowserOnAboutPageLoad = window.BrowserOnAboutPageLoad; - window.BrowserOnAboutPageLoad = torbutton_override_BrowserOnAboutPageLoad; + // Add event listener for about:tor page loads. + document.addEventListener("AboutTorLoad", function(aEvent) { + torbutton_on_abouttor_load(aEvent.target); + }, false, true);
// initialize preferences before we start our prefs observer torbutton_init_prefs(); @@ -966,7 +967,7 @@ function torbutton_update_abouttor_arrow(aDoc) { } catch(e) {} }
-function torbutton_override_BrowserOnAboutPageLoad(aDoc) { +function torbutton_on_abouttor_load(aDoc) { if (torbutton_is_abouttor_doc(aDoc) && !aDoc.documentElement.hasAttribute("aboutTorLoaded")) { aDoc.documentElement.setAttribute("aboutTorLoaded", true);
tor-commits@lists.torproject.org