Bug 713991 - Geolocation fails when used with large number of access points. r=gmealer
authorDoug Turner <dougt@dougt.org>
Tue, 03 Jan 2012 20:13:34 -0800
changeset 83672 200a8d1fb4520c923c2b979b201a0a3f31c5f344
parent 83671 a737cc816eeccdb145f4d73043d02a2d4f79c5aa
child 83730 0eec6ba6a87aa3149854bb7680eff9ac0cb924f4
push id21783
push userdougt@mozilla.com
push dateWed, 04 Jan 2012 04:13:59 +0000
treeherdermozilla-central@200a8d1fb452 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgmealer
bugs713991
milestone12.0a1
first release with
nightly linux32
200a8d1fb452 / 12.0a1 / 20120104031035 / files
nightly linux64
200a8d1fb452 / 12.0a1 / 20120104031035 / files
nightly mac
200a8d1fb452 / 12.0a1 / 20120104031035 / files
nightly win32
200a8d1fb452 / 12.0a1 / 20120104031035 / files
nightly win64
200a8d1fb452 / 12.0a1 / 20120104031035 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 713991 - Geolocation fails when used with large number of access points. r=gmealer
dom/system/NetworkGeolocationProvider.js
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -213,27 +213,29 @@ WifiGeoPositionProvider.prototype = {
       // make sure that the ssid doesn't contain any | chars.
       ap.ssid = ap.ssid.replace("|", "\\|");
       // gls service parses the | as fields
       return "&wifi=mac:"+ap.mac+"|ssid:"+ap.ssid+"|ss:"+ap.signal;
     };
 
     if (accessPoints) {
         providerUrl = providerUrl + accessPoints.sort(sort).map(encode).join("");
-        // max length is 2k.  make sure we are under that
-        let x = providerUrl.length - 2000;
-        if (x >= 0) {
-            // we need to trim
-            let doomed = providerUrl.lastIndexOf("&", 2000);
-            LOG("Doomed:"+doomed);
-            providerUrl = providerUrl.substring(0, doomed);
-        }
     }
 
     providerUrl = encodeURI(providerUrl);
+
+    // max length is 2k.  make sure we are under that
+    let x = providerUrl.length - 2000;
+    if (x >= 0) {
+	// we need to trim
+	let doomed = providerUrl.lastIndexOf("&", 2000);
+	LOG("Doomed:"+doomed);
+	providerUrl = providerUrl.substring(0, doomed);
+    }
+    
     LOG("************************************* Sending request:\n" + providerUrl + "\n");
 
     // send our request to a wifi geolocation network provider:
     let xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
                         .createInstance(Ci.nsIXMLHttpRequest);
 
     // This is a background load
     xhr.mozBackgroundRequest = true;