Bug 1335291 - Change the console flag for insecure geo requests from warning to error. r?jdm draft
authorMichelangelo De Simone <mdesimone@mozilla.com>
Mon, 30 Jan 2017 18:23:14 -0800
changeset 468335 4f3e598de49b1c3e1b181bc1b02525e0ba31421c
parent 468305 1fe66bd0efba89df59d2046e8c91418eb5ae10b8
child 543917 371e93d9f02d0dbec9f467ab60fc56e14a39e93e
push id43430
push userbmo:mdesimone@mozilla.com
push dateTue, 31 Jan 2017 02:23:33 +0000
reviewersjdm
bugs1335291
milestone54.0a1
Bug 1335291 - Change the console flag for insecure geo requests from warning to error. r?jdm MozReview-Commit-ID: 4gLN8jVDyPm
dom/geolocation/nsGeolocation.cpp
dom/tests/mochitest/geolocation/test_geoGetCurrentPositionBlockedInInsecureContext.html
dom/tests/mochitest/geolocation/test_geoWatchPositionBlockedInInsecureContext.html
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -1193,17 +1193,17 @@ Geolocation::ShouldBlockInsecureRequests
   }
 
   nsCOMPtr<nsIDocument> doc = win->GetDoc();
   if (!doc) {
     return false;
   }
 
   if (!nsGlobalWindow::Cast(win)->IsSecureContext()) {
-    nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
+    nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
                                     NS_LITERAL_CSTRING("DOM"), doc,
                                     nsContentUtils::eDOM_PROPERTIES,
                                     "GeolocationInsecureRequestIsForbidden");
     return true;
   }
 
   return false;
 }
--- a/dom/tests/mochitest/geolocation/test_geoGetCurrentPositionBlockedInInsecureContext.html
+++ b/dom/tests/mochitest/geolocation/test_geoGetCurrentPositionBlockedInInsecureContext.html
@@ -24,16 +24,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   // secure context.
   function successCallback(position) {
     ok(false, "Success callback is not expected to be called");
     SimpleTest.finish();
   }
 
   function errorCallback(error) {
     ok(true, "Check for the error callback to be called for insecure requests");
+    is(error.code, error.PERMISSION_DENIED, "Check error code for insecure requests");
     SimpleTest.finish();
   }
 
   // Insecure requests should be blocked, for that we enable the relevant pref.
   SpecialPowers.pushPrefEnv({"set": [["geo.security.allowinsecure", false]]}, function() {
     force_prompt(true, function() {
       navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
     })
--- a/dom/tests/mochitest/geolocation/test_geoWatchPositionBlockedInInsecureContext.html
+++ b/dom/tests/mochitest/geolocation/test_geoWatchPositionBlockedInInsecureContext.html
@@ -27,16 +27,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   function successCallback(position) {
     ok(false, "Success callback is not expected to be called");
     navigator.geolocation.clearWatch(wid);
     SimpleTest.finish();
   }
 
   function errorCallback(error) {
     ok(true, "Check for the error callback to be called for insecure requests");
+    is(error.code, error.PERMISSION_DENIED, "Check error code for insecure requests");
     navigator.geolocation.clearWatch(wid);
     SimpleTest.finish();
   }
 
   // Insecure requests should be blocked, for that we enable the relevant pref.
   SpecialPowers.pushPrefEnv({"set": [["geo.security.allowinsecure", false]]}, function() {
     force_prompt(true, function() {
       wid = navigator.geolocation.watchPosition(successCallback, errorCallback);