Bug 1335291 - Change the console flag for insecure geo requests from warning to error. r=jdm
authorMichelangelo De Simone <mdesimone@mozilla.com>
Mon, 30 Jan 2017 18:23:14 -0800
changeset 331829 46d24f66905f04bb4b561d791a8b1012004b717b
parent 331828 b5acbffc8ebf1472c5e6d6f85acdf52e142b0d31
child 331830 e13b9d48a99abd6713fc0b557e6731f08e9adc37
push id36703
push usermdesimone@mozilla.com
push dateTue, 31 Jan 2017 18:09:50 +0000
treeherderautoland@46d24f66905f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs1335291
milestone54.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 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);