Bug 865850 - Integrate about:networking into Firefox. r=ttaubert
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 07 Aug 2013 20:15:28 -0400
changeset 154589 dcb7c39d1cf816810dc1f1adc231726d57427f0d
parent 154588 7edbd10a7d034b4d8e34ba2324893f046a60bd0c
child 154590 a52c17379fa00609b038db8e4c265606a86655a6
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs865850
milestone26.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 865850 - Integrate about:networking into Firefox. r=ttaubert
browser/app/profile/firefox.js
docshell/base/nsAboutRedirector.cpp
docshell/build/nsDocShellModule.cpp
toolkit/content/aboutNetworking.css
toolkit/content/aboutNetworking.js
toolkit/content/aboutNetworking.xhtml
toolkit/content/jar.mn
toolkit/locales/en-US/chrome/global/aboutNetworking.dtd
toolkit/locales/jar.mn
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -619,16 +619,19 @@ pref("network.protocol-handler.warn-exte
 // It will also try to open link clicks inside the browser before
 // failing over to the system handlers.
 pref("network.protocol-handler.expose-all", true);
 pref("network.protocol-handler.expose.mailto", false);
 pref("network.protocol-handler.expose.news", false);
 pref("network.protocol-handler.expose.snews", false);
 pref("network.protocol-handler.expose.nntp", false);
 
+// Warning for about:networking page
+pref("network.warnOnAboutNetworking", true);
+
 pref("accessibility.typeaheadfind", false);
 pref("accessibility.typeaheadfind.timeout", 5000);
 pref("accessibility.typeaheadfind.linksonly", false);
 pref("accessibility.typeaheadfind.flashBar", 1);
 
 // plugin finder service url
 pref("pfs.datasource.url", "https://pfs.mozilla.org/plugins/PluginFinderService.php?mimetype=%PLUGIN_MIMETYPE%&appID=%APP_ID%&appVersion=%APP_VERSION%&clientOS=%CLIENT_OS%&chromeLocale=%CHROME_LOCALE%&appRelease=%APP_RELEASE%");
 
--- a/docshell/base/nsAboutRedirector.cpp
+++ b/docshell/base/nsAboutRedirector.cpp
@@ -60,16 +60,18 @@ static RedirEntry kRedirMap[] = {
       nsIAboutModule::ALLOW_SCRIPT },
     { "newaddon", "chrome://mozapps/content/extensions/newaddon.xul",
       nsIAboutModule::ALLOW_SCRIPT |
       nsIAboutModule::HIDE_FROM_ABOUTABOUT },
     { "support", "chrome://global/content/aboutSupport.xhtml",
       nsIAboutModule::ALLOW_SCRIPT },
     { "telemetry", "chrome://global/content/aboutTelemetry.xhtml",
       nsIAboutModule::ALLOW_SCRIPT },
+    { "networking", "chrome://global/content/aboutNetworking.xhtml",
+       nsIAboutModule::ALLOW_SCRIPT },
     // about:srcdoc is unresolvable by specification.  It is included here
     // because the security manager would disallow srcdoc iframes otherwise.
     { "srcdoc", "about:blank",
       nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
       nsIAboutModule::HIDE_FROM_ABOUTABOUT }
 };
 static const int kRedirTotal = NS_ARRAY_LENGTH(kRedirMap);
 
--- a/docshell/build/nsDocShellModule.cpp
+++ b/docshell/build/nsDocShellModule.cpp
@@ -178,16 +178,17 @@ const mozilla::Module::ContractIDEntry k
   { NS_ABOUT_MODULE_CONTRACTID_PREFIX "license", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
   { NS_ABOUT_MODULE_CONTRACTID_PREFIX "neterror", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
   { NS_ABOUT_MODULE_CONTRACTID_PREFIX "compartments", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
   { NS_ABOUT_MODULE_CONTRACTID_PREFIX "memory", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
   { NS_ABOUT_MODULE_CONTRACTID_PREFIX "addons", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
   { NS_ABOUT_MODULE_CONTRACTID_PREFIX "newaddon", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
   { NS_ABOUT_MODULE_CONTRACTID_PREFIX "support", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
   { NS_ABOUT_MODULE_CONTRACTID_PREFIX "telemetry", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
+  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "networking", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
   { NS_ABOUT_MODULE_CONTRACTID_PREFIX "srcdoc", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
   { NS_URI_LOADER_CONTRACTID, &kNS_URI_LOADER_CID },
   { NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &kNS_DOCUMENTLOADER_SERVICE_CID },
   { NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID },
   { NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID },
   { NS_MIMESERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID },
   { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default", &kNS_EXTERNALPROTOCOLHANDLER_CID },
   { NS_PREFETCHSERVICE_CONTRACTID, &kNS_PREFETCHSERVICE_CID },
new file mode 100644
--- /dev/null
+++ b/toolkit/content/aboutNetworking.css
@@ -0,0 +1,60 @@
+/* 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/. */
+
+body {
+  min-width: 330px;
+  max-width: 100%;
+  min-height: 330px;
+  max-height: 100%;
+}
+
+#menu {
+  position: absolute;
+  top: 5px;
+  color: gray;
+}
+
+.warningBackground {
+  display: none;
+  background: -moz-Dialog;
+  width:100%;
+  height:100%;
+  z-index:10;
+  top:0;
+  left:0;
+  position:fixed;
+}
+
+.warningMessage {
+  color: -moz-FieldText;
+  position: relative;
+  min-width: 330px;
+  max-width: 50em;
+  margin: 4em auto;
+  border: 1px solid ThreeDShadow;
+  border-radius: 10px;
+  padding: 3em;
+  -moz-padding-start: 30px;
+  background: -moz-Field;
+  margin-left: auto;
+  text-align: center;
+}
+
+.tab {
+  display: none;
+}
+
+.active {
+  display: block;
+}
+
+#menu .selected {
+ color: blue;
+}
+
+#refreshdiv {
+  top: 5px;
+  position: absolute;
+  right: 30px;
+}
new file mode 100644
--- /dev/null
+++ b/toolkit/content/aboutNetworking.js
@@ -0,0 +1,174 @@
+/* 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/. */
+
+'use strict';
+
+const Ci = Components.interfaces;
+const Cc = Components.classes;
+const Cu = Components.utils;
+
+const gDashboard = Cc['@mozilla.org/network/dashboard;1'].
+  getService(Ci.nsIDashboard);
+const gPrefs = Cc["@mozilla.org/preferences-service;1"].
+  getService(Ci.nsIPrefService).getBranch("network.");
+
+const REFRESH_INTERVAL_MS = 3000;
+
+function col(element) {
+  let col = document.createElement('td');
+  let content = document.createTextNode(element);
+  col.appendChild(content);
+  return col;
+}
+
+function displayHttp(data) {
+  let cont = document.getElementById('http_content');
+  let parent = cont.parentNode;
+  let new_cont = document.createElement('tbody');
+  new_cont.setAttribute('id', 'http_content');
+
+  for (let i = 0; i < data.host.length; i++) {
+    let row = document.createElement('tr');
+    row.appendChild(col(data.host[i]));
+    row.appendChild(col(data.port[i]));
+    row.appendChild(col(data.spdy[i]));
+    row.appendChild(col(data.ssl[i]));
+    row.appendChild(col(data.active[i].rtt.length));
+    row.appendChild(col(data.idle[i].rtt.length));
+    new_cont.appendChild(row);
+  }
+
+  parent.replaceChild(new_cont, cont);
+}
+
+function displaySockets(data) {
+  let cont = document.getElementById('sockets_content');
+  let parent = cont.parentNode;
+  let new_cont = document.createElement('tbody');
+  new_cont.setAttribute('id', 'sockets_content');
+
+  for (let i = 0; i < data.host.length; i++) {
+    let row = document.createElement('tr');
+    row.appendChild(col(data.host[i]));
+    row.appendChild(col(data.port[i]));
+    row.appendChild(col(data.tcp[i]));
+    row.appendChild(col(data.active[i]));
+    row.appendChild(col(data.socksent[i]));
+    row.appendChild(col(data.sockreceived[i]));
+    new_cont.appendChild(row);
+  }
+
+  parent.replaceChild(new_cont, cont);
+}
+
+function displayDns(data) {
+  let cont = document.getElementById('dns_content');
+  let parent = cont.parentNode;
+  let new_cont = document.createElement('tbody');
+  new_cont.setAttribute('id', 'dns_content');
+
+  for (let i = 0; i < data.hostname.length; i++) {
+    let row = document.createElement('tr');
+    row.appendChild(col(data.hostname[i]));
+    row.appendChild(col(data.family[i]));
+    let column = document.createElement('td');
+
+    for (let j = 0; j< data.hostaddr[i].length; j++) {
+      column.appendChild(document.createTextNode(data.hostaddr[i][j]));
+      column.appendChild(document.createElement('br'));
+    }
+
+    row.appendChild(column);
+    row.appendChild(col(data.expiration[i]));
+    new_cont.appendChild(row);
+  }
+
+  parent.replaceChild(new_cont, cont);
+}
+
+function displayWebsockets(data) {
+  let cont = document.getElementById('websockets_content');
+  let parent = cont.parentNode;
+  let new_cont = document.createElement('tbody');
+  new_cont.setAttribute('id', 'websockets_content');
+
+  for (let i = 0; i < data.hostport.length; i++) {
+    let row = document.createElement('tr');
+    row.appendChild(col(data.hostport[i]));
+    row.appendChild(col(data.encrypted[i]));
+    row.appendChild(col(data.msgsent[i]));
+    row.appendChild(col(data.msgreceived[i]));
+    row.appendChild(col(data.sentsize[i]));
+    row.appendChild(col(data.receivedsize[i]));
+    new_cont.appendChild(row);
+  }
+
+  parent.replaceChild(new_cont, cont);
+}
+
+function requestNetworkingData() {
+  gDashboard.requestSockets(displaySockets);
+  gDashboard.requestHttpConnections(displayHttp);
+  gDashboard.requestWebsocketConnections(displayWebsockets);
+  gDashboard.requestDNSInfo(displayDns);
+}
+
+function init() {
+  gDashboard.enableLogging = true;
+  if (gPrefs.getBoolPref("warnOnAboutNetworking")) {
+    let div = document.getElementById("warning_message");
+    div.classList.add("active");
+    document.getElementById("confpref").addEventListener("click", confirm);
+  }
+
+  requestNetworkingData();
+
+  document.getElementById("autorefcheck").addEventListener("click", function() {
+    let refrButton = document.getElementById("refreshButton");
+    if (this.checked) {
+      this.interval = setInterval(requestNetworkingData, REFRESH_INTERVAL_MS);
+      refrButton.disabled = "disabled";
+    } else {
+      clearInterval(this.interval);
+      refrButton.disabled = null;
+    }
+  });
+
+  let refr = document.getElementById("refreshButton");
+  refr.addEventListener("click", requestNetworkingData);
+  if (document.getElementById("autorefcheck").checked)
+    refr.disabled = "disabled";
+
+  // Event delegation on #menu element
+  let menu = document.getElementById("menu");
+  menu.addEventListener("click", function click(e) {
+    if (e.target)
+      show(e.target);
+  });
+}
+
+function confirm () {
+  let div = document.getElementById("warning_message");
+  div.classList.remove("active");
+  let warnBox = document.getElementById("warncheck");
+  gPrefs.setBoolPref("warnOnAboutNetworking", warnBox.checked);
+}
+
+function show(button) {
+  let current_tab = document.querySelector(".active");
+  let content = document.getElementById(button.value);
+  if (current_tab == content)
+    return;
+  current_tab.classList.remove("active");
+  content.classList.add("active");
+
+  let current_button = document.querySelector(".selected");
+  current_button.classList.remove("selected");
+  button.classList.add("selected");
+}
+
+window.addEventListener("DOMContentLoaded", function load() {
+  window.removeEventListener("DOMContentLoaded", load);
+  init();
+});
new file mode 100644
--- /dev/null
+++ b/toolkit/content/aboutNetworking.xhtml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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/. -->
+
+
+<!DOCTYPE html [
+<!ENTITY % htmlDTD PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> %htmlDTD;
+<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd"> %globalDTD;
+<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd"> %brandDTD;
+<!ENTITY % networkingDTD SYSTEM "chrome://global/locale/aboutNetworking.dtd"> %networkingDTD;
+]>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>&aboutNetworking.title;</title>
+        <link rel="stylesheet" href="chrome://global/skin/about.css" type="text/css" />
+        <link rel="stylesheet" href="chrome://global/content/aboutNetworking.css" type="text/css" />
+        <script type="application/javascript;version=1.7" src="chrome://global/content/aboutNetworking.js" />
+    </head>
+    <body id="body">
+        <div id="warning_message" class="warningBackground">
+            <div class="warningMessage">
+                &aboutNetworking.warning; <br/> <br/>
+                <label><input id="warncheck" type="checkbox" checked="yes" />&aboutNetworking.showNextTime;</label> <br/> <br/>
+                <button id="confpref">&aboutNetworking.ok;</button>
+            </div>
+        </div>
+        <div id="menu">
+            <button class="selected" value="http">&aboutNetworking.http;</button>
+            <button value="sockets">&aboutNetworking.sockets;</button>
+            <button value="dns">&aboutNetworking.dns;</button>
+            <button value="websockets">&aboutNetworking.websockets;</button>
+        </div>
+        <div id="refreshdiv">
+            <button id="refreshButton">&aboutNetworking.refresh;</button>
+            <input id="autorefcheck" type="checkbox" name="Autorefresh" />&aboutNetworking.autoRefresh;
+        </div>
+
+        <div id="http" class="tab active">
+            <table border="1" width="100%">
+                <thead>
+                    <tr>
+                        <th>&aboutNetworking.hostname;</th>
+                        <th>&aboutNetworking.port;</th>
+                        <th>&aboutNetworking.spdy;</th>
+                        <th>&aboutNetworking.ssl;</th>
+                        <th>&aboutNetworking.active;</th>
+                        <th>&aboutNetworking.idle;</th>
+                    </tr>
+                </thead>
+                <tbody id="http_content" />
+            </table>
+        </div>
+
+        <div id="sockets" class="tab">
+            <table border="1" width="100%">
+                <thead>
+                    <tr>
+                        <th>&aboutNetworking.host;</th>
+                        <th>&aboutNetworking.port;</th>
+                        <th>&aboutNetworking.tcp;</th>
+                        <th>&aboutNetworking.active;</th>
+                        <th>&aboutNetworking.sent;</th>
+                        <th>&aboutNetworking.received;</th>
+                    </tr>
+                </thead>
+                <tbody id="sockets_content" />
+            </table>
+        </div>
+
+        <div id="dns" class="tab">
+            <table border="1" width="100%">
+                <thead>
+                    <tr>
+                        <th>&aboutNetworking.hostname;</th>
+                        <th>&aboutNetworking.family;</th>
+                        <th>&aboutNetworking.addresses;</th>
+                        <th>&aboutNetworking.expires;</th>
+                    </tr>
+                </thead>
+                <tbody id="dns_content" />
+            </table>
+        </div>
+
+        <div id="websockets" class="tab">
+            <table border="1" width="100%">
+                <thead>
+                    <tr>
+                        <th>&aboutNetworking.hostname;</th>
+                        <th>&aboutNetworking.ssl;</th>
+                        <th>&aboutNetworking.messagesSent;</th>
+                        <th>&aboutNetworking.messagesReceived;</th>
+                        <th>&aboutNetworking.bytesSent;</th>
+                        <th>&aboutNetworking.bytesReceived;</th>
+                    </tr>
+                </thead>
+                <tbody id="websockets_content" />
+            </table>
+        </div>
+    </body>
+</html>
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -9,16 +9,19 @@ toolkit.jar:
    content/global/XPCNativeWrapper.js         (XPCNativeWrapper.js)
 *  content/global/xul.css                     (xul.css)
    content/global/textbox.css                 (textbox.css)
    content/global/menulist.css                (menulist.css)
    content/global/about.xhtml                 (about.xhtml)
    content/global/aboutAbout.xhtml            (aboutAbout.xhtml)
    content/global/aboutRights.xhtml           (aboutRights.xhtml)
    content/global/aboutRights-unbranded.xhtml (aboutRights-unbranded.xhtml)
+   content/global/aboutNetworking.js
+   content/global/aboutNetworking.xhtml
+   content/global/aboutNetworking.css
 *  content/global/aboutSupport.js
 *  content/global/aboutSupport.xhtml
 *  content/global/aboutTelemetry.js
    content/global/aboutTelemetry.xhtml
    content/global/aboutTelemetry.css          (aboutTelemetry.css)
    content/global/directionDetector.html
    content/global/plugins.html
    content/global/plugins.css
new file mode 100644
--- /dev/null
+++ b/toolkit/locales/en-US/chrome/global/aboutNetworking.dtd
@@ -0,0 +1,31 @@
+<!-- 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/. -->
+
+<!ENTITY aboutNetworking.title                 "About Networking">
+<!ENTITY aboutNetworking.warning               "This is very experimental. Do not use without adult supervision.">
+<!ENTITY aboutNetworking.showNextTime          "Show this warning next time">
+<!ENTITY aboutNetworking.ok                    "OK">
+<!ENTITY aboutNetworking.http                  "Http">
+<!ENTITY aboutNetworking.sockets               "Sockets">
+<!ENTITY aboutNetworking.dns                   "DNS">
+<!ENTITY aboutNetworking.websockets            "WebSockets">
+<!ENTITY aboutNetworking.refresh               "Refresh">
+<!ENTITY aboutNetworking.autoRefresh           "Autorefresh every 3 seconds">
+<!ENTITY aboutNetworking.hostname              "Hostname">
+<!ENTITY aboutNetworking.port                  "Port">
+<!ENTITY aboutNetworking.spdy                  "SPDY">
+<!ENTITY aboutNetworking.ssl                   "SSL">
+<!ENTITY aboutNetworking.active                "Active">
+<!ENTITY aboutNetworking.idle                  "Idle">
+<!ENTITY aboutNetworking.host                  "Host">
+<!ENTITY aboutNetworking.tcp                   "TCP">
+<!ENTITY aboutNetworking.sent                  "Sent">
+<!ENTITY aboutNetworking.received              "Received">
+<!ENTITY aboutNetworking.family                "Family">
+<!ENTITY aboutNetworking.addresses             "Addresses">
+<!ENTITY aboutNetworking.expires               "Expires (Seconds)">
+<!ENTITY aboutNetworking.messagesSent          "Messages Sent">
+<!ENTITY aboutNetworking.messagesReceived      "Messages Received">
+<!ENTITY aboutNetworking.bytesSent             "Bytes Sent">
+<!ENTITY aboutNetworking.bytesReceived         "Bytes Received">
--- a/toolkit/locales/jar.mn
+++ b/toolkit/locales/jar.mn
@@ -4,16 +4,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
 @AB_CD@.jar:
 % locale global @AB_CD@ %locale/@AB_CD@/global/
   locale/@AB_CD@/global/about.dtd                       (%chrome/global/about.dtd)
   locale/@AB_CD@/global/aboutAbout.dtd                  (%chrome/global/aboutAbout.dtd)
   locale/@AB_CD@/global/aboutRights.dtd                 (%chrome/global/aboutRights.dtd)
+  locale/@AB_CD@/global/aboutNetworking.dtd             (%chrome/global/aboutNetworking.dtd)
   locale/@AB_CD@/global/aboutSupport.dtd                (%chrome/global/aboutSupport.dtd)
   locale/@AB_CD@/global/aboutSupport.properties         (%chrome/global/aboutSupport.properties)
   locale/@AB_CD@/global/aboutTelemetry.dtd              (%chrome/global/aboutTelemetry.dtd)
   locale/@AB_CD@/global/aboutTelemetry.properties       (%chrome/global/aboutTelemetry.properties)
   locale/@AB_CD@/global/actions.dtd                     (%chrome/global/actions.dtd)
   locale/@AB_CD@/global/appPicker.dtd                   (%chrome/global/appPicker.dtd)
   locale/@AB_CD@/global/brand.dtd                       (generic/chrome/global/brand.dtd)
   locale/@AB_CD@/global/browser.properties              (%chrome/global/browser.properties)