Bug 881083 Add a "Validate this page" entry to the Web Development submenu r=IanN.
authorPhilip Chee <philip.chee@gmail.com>
Wed, 17 Jul 2013 01:28:13 +0800
changeset 12756 df887839a810eb715d76a8f9089a2246c43d10ef
parent 12755 ec7c6d8af7d84ae594fc8061b46290dd287dcdfc
child 12757 3ba0cc41732a044652c87a8f5d1cee21f2ac9a0a
push id9341
push userphilip.chee@gmail.com
push dateTue, 16 Jul 2013 17:30:51 +0000
treeherdercomm-central@9cf4459806ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN
bugs881083
Bug 881083 Add a "Validate this page" entry to the Web Development submenu r=IanN.
suite/browser/browser-prefs.js
suite/browser/jar.mn
suite/browser/navigator.xul
suite/browser/webDeveloperOverlay.js
suite/browser/webDeveloperOverlay.xul
suite/common/contentAreaClick.js
suite/locales/en-US/chrome/browser/region.properties
suite/locales/en-US/chrome/browser/webDeveloper.dtd
suite/locales/jar.mn
--- a/suite/browser/browser-prefs.js
+++ b/suite/browser/browser-prefs.js
@@ -285,16 +285,17 @@ pref("browser.link.open_newwindow", 3);
 // 0: no restrictions - divert everything
 // 1: don't divert window.open at all
 // 2: don't divert window.open with features
 pref("browser.link.open_newwindow.restriction", 2);
 
 // Translation service
 pref("browser.translation.service", "chrome://navigator-region/locale/region.properties");
 pref("browser.translation.serviceDomain", "chrome://navigator-region/locale/region.properties");
+pref("browser.validate.html.service", "chrome://navigator-region/locale/region.properties");
 
 // 0 goes back
 // 1 act like pgup
 // 2 and other values, nothing
 pref("browser.backspace_action", 0);
 
 // Controls behavior of the "Add Exception" dialog launched from SSL error pages:
 // 0 - don't pre-populate anything.
--- a/suite/browser/jar.mn
+++ b/suite/browser/jar.mn
@@ -24,16 +24,18 @@ comm.jar:
    content/navigator/navigatorOverlay.xul
    content/navigator/nsBrowserContentListener.js
    content/navigator/nsBrowserStatusHandler.js
    content/navigator/sessionHistoryUI.js
    content/navigator/safeBrowsingOverlay.js
    content/navigator/safeBrowsingOverlay.xul
    content/navigator/tabbrowser.xml
    content/navigator/urlbarBindings.xml
+   content/navigator/webDeveloperOverlay.js
+   content/navigator/webDeveloperOverlay.xul
 #ifdef XP_MACOSX
    content/navigator/platformNavigationBindings.xul                 (mac/platformNavigationBindings.xul)
    content/navigator/platformMailOverlay.xul                        (mac/platformMailOverlay.xul)
 #else
 #ifdef XP_WIN32
    content/navigator/platformNavigationBindings.xul                 (win/platformNavigationBindings.xul)
    content/navigator/platformMailOverlay.xul                        (win/platformMailOverlay.xul)
 #else
--- a/suite/browser/navigator.xul
+++ b/suite/browser/navigator.xul
@@ -8,16 +8,17 @@
 <?xml-stylesheet href="chrome://navigator/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://communicator/content/places/places.css" type="text/css"?>
 
 <?xul-overlay href="chrome://navigator/content/navigatorOverlay.xul"?>
 <?xul-overlay href="chrome://navigator/content/linkToolbarOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/contentAreaContextOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
 <?xul-overlay href="chrome://navigator/content/safeBrowsingOverlay.xul"?>
+<?xul-overlay href="chrome://navigator/content/webDeveloperOverlay.xul"?>
 
 <!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % navigatorDTD SYSTEM "chrome://navigator/locale/navigator.dtd" >
 %navigatorDTD;
 ]>
 
new file mode 100644
--- /dev/null
+++ b/suite/browser/webDeveloperOverlay.js
@@ -0,0 +1,32 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+var gWebDeveloper = {
+  validateThisPage: function validateThisPage(aEvent) {
+    var service = GetLocalizedStringPref("browser.validate.html.service");
+    var uri = getBrowser().currentURI;
+    var checkURL = service + encodeURIComponent(uri.spec);
+
+    if (!openNewTabOrWindow(aEvent, checkURL, getBrowser().contentDocument))
+      getBrowser().addTab(checkURL, { referrerURI: uri, focusNewTab: true });
+  },
+
+  initMenuItem: function initMenuItem() {
+    var menuitem = document.getElementById("validatePage");
+    var uri = getBrowser().currentURI;
+    if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
+      menuitem.removeAttribute("disabled");
+    else
+      menuitem.setAttribute("disabled", true);
+  },
+
+  initOverlay: function initOverlay(aEvent) {
+    window.removeEventListener("load", gWebDeveloper.initOverlay, false);
+    var popup = document.getElementById("toolsPopup");
+    popup.addEventListener("popupshowing", gWebDeveloper.initMenuItem, false);
+  }
+}
+
+window.addEventListener("load", gWebDeveloper.initOverlay, false);
new file mode 100644
--- /dev/null
+++ b/suite/browser/webDeveloperOverlay.xul
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!-- 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 overlay SYSTEM "chrome://navigator/locale/webDeveloper.dtd">
+
+<overlay id="webDeveloperOverlay"
+         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <script type="application/javascript"
+          src="chrome://navigator/content/webDeveloperOverlay.js"/>
+
+  <menupopup id="toolsPopup">
+    <menuitem id="validatePage"
+              label="&validatePage.label;"
+              accesskey="&validatePage.accesskey;"
+              oncommand="gWebDeveloper.validateThisPage(event);"/>
+  </menupopup>
+
+</overlay>
--- a/suite/common/contentAreaClick.js
+++ b/suite/common/contentAreaClick.js
@@ -94,17 +94,20 @@
     if (Services.prefs.getBoolPref("browser.tabs.opentabfor.middleclick")) {
       openNewTabWith(href, doc, null, event);
       event.stopPropagation();
       return true;
     }
 
     // should we open it in a new window?
     if (Services.prefs.getBoolPref("middlemouse.openNewWindow")) {
-      openNewWindowWith(href, doc);
+      if (gPrivate)
+        openNewPrivateWith(href, doc);
+      else
+        openNewWindowWith(href, doc);
       event.stopPropagation();
       return true;
     }
 
     // let someone else deal with it
     return false;
   }
 
--- a/suite/locales/en-US/chrome/browser/region.properties
+++ b/suite/locales/en-US/chrome/browser/region.properties
@@ -7,16 +7,17 @@
 # all.js
 #
 browser.startup.homepage=http://www.seamonkey-project.org/start/
 browser.throbber.url=http://www.seamonkey-project.org/
 browser.search.defaulturl=http://www.google.com/search?q=
 
 browser.translation.service=http://translate.google.com/translate?prev=/language_tools&u=
 browser.translation.serviceDomain=translate.google.com
+browser.validate.html.service=http://validator.w3.org/check?charset=%28detect+automatically%29&doctype=Inline&uri=
 
 #config.js
 #
 startup.homepage_override_url=http://www.seamonkey-project.org/releases/seamonkey%VERSION%/
 
 # This is the default set of web based feed handlers shown in the reader
 # selection UI
 browser.contentHandlers.types.0.title=Google
new file mode 100644
--- /dev/null
+++ b/suite/locales/en-US/chrome/browser/webDeveloper.dtd
@@ -0,0 +1,6 @@
+<!-- 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 validatePage.label            "Validate This Page">
+<!ENTITY validatePage.accesskey        "V">
--- a/suite/locales/jar.mn
+++ b/suite/locales/jar.mn
@@ -355,16 +355,17 @@
   locale/@AB_CD@/navigator/navigator.dtd                                    (%chrome/browser/navigator.dtd)
   locale/@AB_CD@/navigator/navigator.properties                             (%chrome/browser/navigator.properties)
   locale/@AB_CD@/navigator/navigatorOverlay.dtd                             (%chrome/browser/navigatorOverlay.dtd)
   locale/@AB_CD@/navigator/pageInfo.dtd                                     (%chrome/browser/pageInfo.dtd)
   locale/@AB_CD@/navigator/pageInfo.properties                              (%chrome/browser/pageInfo.properties)
   locale/@AB_CD@/navigator/tabbrowser.dtd                                   (%chrome/browser/tabbrowser.dtd)
   locale/@AB_CD@/navigator/tabbrowser.properties                            (%chrome/browser/tabbrowser.properties)
   locale/@AB_CD@/navigator/taskbar.properties                               (%chrome/browser/taskbar.properties)
+  locale/@AB_CD@/navigator/webDeveloper.dtd                                 (%chrome/browser/webDeveloper.dtd)
   locale/@AB_CD@/navigator-platform/mac/platformNavigationBindings.dtd      (%chrome/browser/mac/platformNavigationBindings.dtd)
   locale/@AB_CD@/navigator-platform/unix/platformNavigationBindings.dtd     (%chrome/browser/unix/platformNavigationBindings.dtd)
   locale/@AB_CD@/navigator-platform/win/platformNavigationBindings.dtd      (%chrome/browser/win/platformNavigationBindings.dtd)
   locale/@AB_CD@/navigator-region/region.properties                         (%chrome/browser/region.properties)
   locale/@AB_CD@/pippki/pref-certs.dtd                                      (%chrome/common/pref/pref-certs.dtd)
   locale/@AB_CD@/pippki/pref-masterpass.dtd                                 (%chrome/common/pref/pref-masterpass.dtd)
   locale/@AB_CD@/pippki/pref-ssl.dtd                                        (%chrome/common/pref/pref-ssl.dtd)