merge from backout

This commit is contained in:
Brad Lassey 2009-08-12 19:26:27 -07:00
commit c9ed635a4b
13 changed files with 30 additions and 410 deletions

View File

@ -260,8 +260,6 @@ user_pref("media.cache_size", 100);
user_pref("security.warn_viewing_mixed", false);
user_pref("geo.wifi.uri", "http://localhost:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs");
user_pref("geo.wifi.testing", true);
user_pref("camino.warn_when_closing", false); // Camino-only, harmless to others
// Make url-classifier updates so rare that they won't affect tests

View File

@ -4,7 +4,6 @@ const Ci = Components.interfaces;
const Cc = Components.classes;
var gLoggingEnabled = false;
var gTestingEnabled = false;
function nowInSeconds()
{
@ -52,12 +51,10 @@ WifiGeoAddressObject.prototype = {
flags: Ci.nsIClassInfo.DOM_OBJECT,
};
function WifiGeoCoordsObject(lat, lon, acc, alt, altacc) {
function WifiGeoCoordsObject(lat, lon, acc) {
this.latitude = lat;
this.longitude = lon;
this.accuracy = acc;
this.altitude = alt;
this.altitudeAccuracy = altacc;
};
WifiGeoCoordsObject.prototype = {
@ -80,29 +77,27 @@ WifiGeoCoordsObject.prototype = {
latitude: 0,
longitude: 0,
accuracy: 0,
altitude: 0,
altitudeAccuracy: 0,
heading: 0,
speed: 0,
};
function WifiGeoPositionObject(location, address) {
function WifiGeoPositionObject(lat, lon, acc, address) {
this.coords = new WifiGeoCoordsObject(location.latitude,
location.longitude,
location.accuracy || 12450, // .5 * circumference of earth.
location.altitude || 0,
location.altitude_accuracy || 0);
this.coords = new WifiGeoCoordsObject(lat, lon, acc);
if (address) {
this.address = new WifiGeoAddressObject(address.street_number || null,
address.street || null,
address.premises || null,
address.city || null,
address.county || null,
address.region || null,
address.country || null,
address.country_code || null,
address.postal_code || null);
this.address = new WifiGeoAddressObject(address.street_number,
address.street,
address.premises,
address.city,
address.county,
address.region,
address.country,
address.country_code,
address.postal_code);
}
else
this.address = null;
@ -137,11 +132,6 @@ function WifiGeoPositionProvider() {
try {
gLoggingEnabled = this.prefService.getBoolPref("geo.wifi.logging.enabled");
} catch (e) {}
try {
gTestingEnabled = this.prefService.getBoolPref("geo.wifi.testing");
} catch (e) {}
};
WifiGeoPositionProvider.prototype = {
@ -175,15 +165,9 @@ WifiGeoPositionProvider.prototype = {
LOG("provider url = " + this.provider_url);
// if we don't see anything in 5 seconds, kick of one IP geo lookup.
// if we are testing, just hammer this callback so that we are more or less
// always sending data. It doesn't matter if we have an access point or not.
this.hasSeenWiFi = false;
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
if (gTestingEnabled == false)
this.timer.initWithCallback(this, 5000, this.timer.TYPE_ONE_SHOT);
else
this.timer.initWithCallback(this, 200, this.timer.TYPE_REPEATING_SLACK);
this.timer.initWithCallback(this, 5000, this.timer.TYPE_ONE_SHOT);
let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
os.addObserver(this, "private-browsing", false);
@ -308,7 +292,10 @@ WifiGeoPositionProvider.prototype = {
LOG("No address in response");
}
var newLocation = new WifiGeoPositionObject(response.location, address);
var newLocation = new WifiGeoPositionObject(response.location.latitude,
response.location.longitude,
response.location.accuracy,
address);
var update = Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationUpdate);
update.update(newLocation);

View File

@ -275,7 +275,7 @@ nsGeolocationRequest::Allow()
PRInt32 tempAge;
nsresult rv = mOptions->GetMaximumAge(&tempAge);
if (NS_SUCCEEDED(rv)) {
if (tempAge >= 0)
if (tempAge > 0)
maximumAge = tempAge;
}
}

View File

@ -45,11 +45,6 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
test_manyCurrentSerial.html \
test_manyCurrentConcurrent.html \
test_garbageWatch.html \
test_manyWatchConcurrent.html \
test_manyWatchSerial.html \
test_manyWindows.html \
test_allowCurrent.html \
test_allowWatch.html \
@ -61,7 +56,7 @@ _TEST_FILES = \
geolocation_common.js \
geolocation.html \
test_optional_api_params.html \
network_geolocation.sjs \
network_geolocation.sjs \
$(NULL)

View File

@ -1,29 +1,9 @@
function start_sending_garbage()
{
var baseURL = "http://localhost:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs";
var xhr = new XMLHttpRequest();
xhr.open("GET", baseURL + "?action=start-garbage", false);
xhr.send(null);
}
function stop_sending_garbage()
{
var baseURL = "http://localhost:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs";
var xhr = new XMLHttpRequest();
xhr.open("GET", baseURL + "?action=stop-garbage", false);
xhr.send(null);
}
function stop_geolocationProvider()
{
var baseURL = "http://localhost:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs";
var xhr = new XMLHttpRequest();
xhr.open("GET", baseURL + "?action=stop-responding", false);
xhr.open("GET", baseURL + "?action=stop-responding&latitude=3.14", false);
xhr.send(null);
}
@ -51,15 +31,8 @@ function check_geolocation(location) {
ok("altitude" in coords, "Check to see if there is a altitude");
ok("accuracy" in coords, "Check to see if there is a accuracy");
ok("altitudeAccuracy" in coords, "Check to see if there is a alt accuracy");
// optional ok("heading" in coords, "Check to see if there is a heading");
// optional ok("speed" in coords, "Check to see if there is a speed");
ok (location.coords.latitude == 37.41857, "lat matches known value");
ok (location.coords.longitude == -122.08769, "lon matches known value");
ok(location.coords.altitude == 42, "alt matches known value");
ok(location.coords.altitudeAccuracy == 42, "alt acc matches known value");
ok("heading" in coords, "Check to see if there is a heading");
ok("speed" in coords, "Check to see if there is a speed");
}

View File

@ -31,40 +31,19 @@ function controlResponse(params)
if (params.action == "start-responding") {
setState("sendresponse", "true");
}
if (params.action == "start-garbage") {
setState("garbage", "true");
}
if (params.action == "stop-garbage") {
setState("garbage", "false");
}
}
function setPosition(params)
{
var address = {
street_number: "street_number",
street: "street",
premises: "premises",
city: "city",
county: "county",
region: "region",
country: "country",
country_code: "country_code",
postal_code: "postal_code",
};
// this isnt' the w3c data structure, it is the network location provider structure.
var coords = {
latitude: 37.41857,
longitude: -122.08769,
altitude: 42,
accuracy: 42,
altitude_accuracy: 42,
altitudeAccuracy: 42,
heading: 42,
speed: 42,
};
var geoposition = {
@ -112,19 +91,6 @@ function handleRequest(request, response)
var sendresponse = getState("sendresponse");
var position = getState("coords");
if (getState("garbage") == "true") {
// better way?
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
position = "";
var len = Math.floor(Math.random() * 5000);
for (var i=0; i< len; i++) {
var c = Math.floor(Math.random() * chars.length);
position += chars.substring(c, c+1);
}
}
if (sendresponse == "true") {
response.setStatusLine("1.0", 200, "OK");
response.setHeader("Cache-Control", "no-cache", false);

View File

@ -35,12 +35,8 @@ function accept() {
SimpleTest.waitForExplicitFinish();
var options = {
maximumAge: 0,
};
// one-shot position requests
navigator.geolocation.getCurrentPosition(successCallback, null, options);
navigator.geolocation.getCurrentPosition(successCallback, null, null);
setTimeout(accept, 50);

View File

@ -36,7 +36,7 @@ function successCallback(position){
SimpleTest.waitForExplicitFinish();
watchID = navigator.geolocation.watchPosition(successCallback, failureCallback, null);
watchID = navigator.geolocation.getCurrentPosition(successCallback, failureCallback, null);
// click deny
setTimeout(clickNotificationButton, 50, kDenyButton);

View File

@ -1,55 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=482260
-->
<head>
<title>Test for garbage data returned from location provider </title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="geolocation_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=455327">Mozilla Bug 482260</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug **/
SimpleTest.waitForExplicitFinish();
start_sending_garbage();
function successCallback(pos){
ok(false, "success should have never been called.");
stop_sending_garbage();
SimpleTest.finish();
}
function errorCallback(err) {
ok(err.code == err.TIMEOUT, "ensure error is a timeout.");
stop_sending_garbage();
SimpleTest.finish();
}
var options = {
maximumAge: 0,
timeout: 1000,
};
navigator.geolocation.watchPosition(successCallback,
errorCallback,
options);
setTimeout(clickNotificationButton, 10, kAcceptButton);
</script>
</pre>
</body>
</html>

View File

@ -1,62 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=482260
-->
<head>
<title>Test for getCurrentPosition </title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="geolocation_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=482260">Mozilla Bug 482260</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
var completeCount = 100;
var hasAccepted = false;
function successCallback(position) {
check_geolocation(position);
}
function accept() {
hasAccepted = true;
clickNotificationButton(kAcceptButton);
}
SimpleTest.waitForExplicitFinish();
// one-shot position requests
var options = {
maximumAge: 0,
};
var y = completeCount;
for (var x=0; x< y; x++)
navigator.geolocation.getCurrentPosition(successCallback, null, options);
setTimeout(accept, 50);
setTimeout(done, 1000);
function done() {
completeCount--;
ok(1, "Saw all successCallbacks");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

View File

@ -1,55 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=482260
-->
<head>
<title>Test for getCurrentPosition </title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="geolocation_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=482260">Mozilla Bug 482260</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
var completeCount = 1000;
var hasAccepted = false;
function successCallback(position) {
check_geolocation(position);
completeCount--;
if (completeCount > 0)
navigator.geolocation.getCurrentPosition(successCallback, null, null);
SimpleTest.finish();
}
function accept() {
hasAccepted = true;
clickNotificationButton(kAcceptButton);
}
SimpleTest.waitForExplicitFinish();
var options = {
maximumAge: 0,
};
// one-shot position requests
navigator.geolocation.getCurrentPosition(successCallback, null, options);
setTimeout(accept, 50);
</script>
</pre>
</body>
</html>

View File

@ -1,61 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=482260
-->
<head>
<title>Test for watchPosition </title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="geolocation_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=482260">Mozilla Bug 482260</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
var completeCount = 100;
var hasAccepted = false;
function successCallback(position) {
check_geolocation(position);
}
function accept() {
hasAccepted = true;
clickNotificationButton(kAcceptButton);
}
SimpleTest.waitForExplicitFinish();
// one-shot position requests
var options = {
maximumAge: 0,
};
var y = completeCount;
for (var x=0; x< y; x++)
navigator.geolocation.watchPosition(successCallback, null, options);
setTimeout(accept, 50);
setTimeout(done, 1000);
function done() {
completeCount--;
ok(1, "Saw all successCallbacks");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

View File

@ -1,62 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=482260
-->
<head>
<title>Test for watchPosition </title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="geolocation_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=482260">Mozilla Bug 482260</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
var hasAccepted = false;
var watchID = 0;
var completeCount = 10;
var options = {
maximumAge: 0,
};
function successCallback(position) {
check_geolocation(position);
navigator.geolocation.clearWatch(watchID);
completeCount--;
if (completeCount==0) {
ok(1, "all watchPosition successCallbacks called");
SimpleTest.finish();
} else {
watchID = navigator.geolocation.watchPosition(successCallback, null, options);
setTimeout(accept, 50);
}
}
function accept() {
hasAccepted = true;
clickNotificationButton(kAcceptButton);
}
SimpleTest.waitForExplicitFinish();
// one-shot position requests
watchID = navigator.geolocation.watchPosition(successCallback, null, options);
setTimeout(accept, 50);
</script>
</pre>
</body>
</html>