Bug 1354721 - add about:geo xhtml page that can show network
geo logging
MozReview-Commit-ID: 5L0ck0jOc5G
new file mode 100644
--- /dev/null
+++ b/browser/base/content/aboutGeo.xhtml
@@ -0,0 +1,115 @@
+<?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 % netErrorDTD
+ SYSTEM "chrome://global/locale/netError.dtd">
+ %netErrorDTD;
+ <!ENTITY % globalDTD
+ SYSTEM "chrome://global/locale/global.dtd">
+ %globalDTD;
+]>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+
+ <link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" />
+
+ <script type="application/javascript"><![CDATA[
+ Components.utils.import("resource://gre/modules/PopupNotifications.jsm");
+
+ function log(msg) {
+ document.getElementById("textArea").value += `${msg}\n`;
+ }
+
+ function Listener() {}
+
+ Listener.prototype = {
+ update: function(arg) {
+ log(`${arg.coords.latitude}, ${arg.coords.longitude}`);
+ },
+
+ debugLogger: function(arg) {
+ log(arg);
+ },
+
+ notifyError: function(arg) {
+ log(arg);
+ }
+ };
+
+ let domWindow = QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIWebNavigation)
+ .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
+ .rootTreeItem
+ .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIDOMWindow);
+ let browser = domWindow.gBrowser;
+ let notify = new PopupNotifications(browser,
+ domWindow.document.getElementById("notification-popup"),
+ domWindow.document.getElementById("notification-popup-box"));
+
+ let hasPermission = false;
+ let isRunning = false;
+ let geo = null;
+
+ function startupGeo() {
+ let button = document.getElementById("startStopButton");
+ button.innerHTML = "Stop"
+ isRunning = true;
+ geo = Components.classes['@mozilla.org/geolocation/provider;1'].createInstance(Components.interfaces.nsIGeolocationProvider);
+ geo.watch(new Listener());
+ geo.enableLoggingToListener(true);
+ geo.startup();
+ }
+
+ function startStopToggled() {
+ let button = document.getElementById("startStopButton");
+ if (isRunning) {
+ isRunning = false;
+ button.innerHTML = "Start";
+ geo.shutdown();
+ geo = null;
+ listener = null;
+ return;
+ }
+
+ if (hasPermission) {
+ startupGeo();
+ return;
+ }
+
+ notify.show(browser.selectedBrowser, "geopopup",
+ "Allow location access for testing?", null,
+ { label: "Don't Allow", accessKey: "a", callback: () => {} },
+ [{ label: "Allow Location Access", accessKey: "b",
+ callback: () => {
+ hasPermission = true;
+ startupGeo();
+ }
+ }]
+ );
+ }
+
+ window.onclose = () => {
+ if (geo != null) {
+ geo.shutdown();
+ }
+ }
+ ]]></script>
+ </head>
+
+ <body style="margin-top: 10pt">
+ <button id="startStopButton" onclick="startStopToggled();">Start</button>
+ <div style="height: 90vh">
+ <textarea id="textArea" style="width: 100%; height:100%; resize: none"></textarea>
+ </div>
+ </body>
+</html>
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -8,16 +8,17 @@ browser.jar:
#endif
% overlay chrome://global/content/viewSource.xul chrome://browser/content/viewSourceOverlay.xul
% overlay chrome://global/content/viewPartialSource.xul chrome://browser/content/viewSourceOverlay.xul
content/browser/aboutDialog-appUpdater.js (content/aboutDialog-appUpdater.js)
* content/browser/aboutDialog.xul (content/aboutDialog.xul)
content/browser/aboutDialog.js (content/aboutDialog.js)
content/browser/aboutDialog.css (content/aboutDialog.css)
+ content/browser/aboutGeo.xhtml (content/aboutGeo.xhtml)
content/browser/aboutRobots.xhtml (content/aboutRobots.xhtml)
* content/browser/abouthome/aboutHome.xhtml (content/abouthome/aboutHome.xhtml)
content/browser/abouthome/aboutHome.js (content/abouthome/aboutHome.js)
* content/browser/abouthome/aboutHome.css (content/abouthome/aboutHome.css)
content/browser/abouthome/snippet1.png (content/abouthome/snippet1.png)
content/browser/abouthome/snippet2.png (content/abouthome/snippet2.png)
content/browser/abouthome/downloads.png (content/abouthome/downloads.png)
content/browser/abouthome/bookmarks.png (content/abouthome/bookmarks.png)
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -68,16 +68,19 @@ static const RedirEntry kRedirMap[] = {
{ "rights",
"chrome://global/content/aboutRights.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::MAKE_LINKABLE |
nsIAboutModule::ALLOW_SCRIPT },
{ "robots", "chrome://browser/content/aboutRobots.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT },
+ { "geo", "chrome://browser/content/aboutGeo.xhtml",
+ nsIAboutModule::HIDE_FROM_ABOUTABOUT |
+ nsIAboutModule::ALLOW_SCRIPT },
{ "searchreset", "chrome://browser/content/search/searchReset.xhtml",
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
{ "sessionrestore", "chrome://browser/content/aboutSessionRestore.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{ "welcomeback", "chrome://browser/content/aboutWelcomeBack.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{ "sync-tabs", "chrome://browser/content/sync/aboutSyncTabs.xul",
--- a/browser/components/build/nsModule.cpp
+++ b/browser/components/build/nsModule.cpp
@@ -86,16 +86,17 @@ static const mozilla::Module::ContractID
#endif
{ NS_FEEDSNIFFER_CONTRACTID, &kNS_FEEDSNIFFER_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "blocked", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "certerror", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "socialerror", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "providerdirectory", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "tabcrashed", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "feeds", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
+ { NS_ABOUT_MODULE_CONTRACTID_PREFIX "geo", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "privatebrowsing", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "rights", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "robots", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "searchreset", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "sessionrestore", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "welcomeback", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "sync-tabs", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "home", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },