Bug 489817 - migrate existing geolocation tests from mochitest to browser-chrome; r=(ctalbert + doug.turner)

This commit is contained in:
Joel Maher 2009-06-08 21:50:04 +02:00
parent 10418307c4
commit 75b52fe065
15 changed files with 26 additions and 214 deletions

View File

@ -257,6 +257,7 @@ user_pref("svg.smil.enabled", true); // Needed for SMIL mochitests until bug 482
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("camino.warn_when_closing", false); // Camino-only, harmless to others
"""

View File

@ -85,11 +85,6 @@ ifdef WINCE_WINDOWS_MOBILE
CPPSRCS += WinMobileLocationProvider.cpp
endif
ifdef ENABLE_TESTS
DIRS += test
endif
EXTRA_COMPONENTS = \
NetworkGeolocationProvider.js \
$(NULL)

View File

@ -1,50 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org build system.
#
# The Initial Developer of the Original Code is Mozilla Corporation
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Doug Turner <dougt@meer.net>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = dom_geolocation_test
ifdef ENABLE_TESTS
EXTRA_COMPONENTS = TestGeolocationProvider.js
endif
include $(topsrcdir)/config/rules.mk

View File

@ -1,137 +0,0 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const Ci = Components.interfaces;
const Cc = Components.classes;
function GeoPositionCoordsObject() {
};
GeoPositionCoordsObject.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords, Ci.nsIClassInfo]),
// Class Info is required to be able to pass objects back into the DOM.
getInterfaces: function(countRef) {
var interfaces = [Ci.nsIDOMGeoPositionCoords, Ci.nsIClassInfo, Ci.nsISupports];
countRef.value = interfaces.length;
return interfaces;
},
getHelperForLanguage: function(language) null,
contractID: "",
classDescription: "testing geolocation coords object",
classID: null,
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
flags: Ci.nsIClassInfo.DOM_OBJECT,
latitude: 37.41857,
longitude: -122.08769,
// some numbers that we can test against
altitude: 42,
accuracy: 42,
altitudeAccuracy: 42,
heading: 42,
speed: 42,
};
function GeoPositionObject() {
};
GeoPositionObject.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition, Ci.nsIClassInfo]),
// Class Info is required to be able to pass objects back into the DOM.
getInterfaces: function(countRef) {
var interfaces = [Ci.nsIDOMGeoPosition, Ci.nsIClassInfo, Ci.nsISupports];
countRef.value = interfaces.length;
return interfaces;
},
getHelperForLanguage: function(language) null,
contractID: "",
classDescription: "test geolocation object",
classID: null,
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
flags: Ci.nsIClassInfo.DOM_OBJECT,
coords: new GeoPositionCoordsObject(),
timestamp: Date.now(),
};
function MyLocation() {};
MyLocation.prototype = {
classDescription: "A component that returns a geolocation",
classID: Components.ID("{10F622A4-6D7F-43A1-A938-5FFCBE2B1D1D}"),
contractID: "@mozilla.org/geolocation/provider;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIGeolocationProvider]),
geolocation: null,
timer: null,
timerInterval: 500,
startup: function() {
var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
observerService.addObserver(this, "geolocation-test-control", false);
},
isReady: function() {return true},
watch: function(c) {
var watchCallback =
{
notify: function(timer) { this.parent.currentLocation.timestamp = Date.now();
c.update(this.parent.currentLocation); }
};
watchCallback.parent = this;
if(!this.timer)
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this.timer.initWithCallback(watchCallback,
this.timerInterval,
Ci.nsITimer.TYPE_REPEATING_SLACK);
},
currentLocation: new GeoPositionObject(),
shutdown: function() {
if(this.timer)
this.timer.cancel();
var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
observerService.removeObserver(this, "geolocation-test-control");
},
observe: function (subject, topic, data) {
if (topic == "geolocation-test-control") {
if (data == "stop-responding")
{
if(this.timer)
this.timer.cancel();
}
else if (data == "start-responding")
{
if(!this.timer)
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this.timer.initWithCallback(watchCallback,
this.timerInterval,
Ci.nsITimer.TYPE_REPEATING_SLACK);
}
}
},
};
var components = [MyLocation];
function NSGetModule(compMgr, fileSpec) {
return XPCOMUtils.generateModule(components);
}

View File

@ -56,6 +56,7 @@ _TEST_FILES = \
geolocation_common.js \
geolocation.html \
test_optional_api_params.html \
network_geolocation.sjs \
$(NULL)

View File

@ -1,19 +1,5 @@
function ensure_geolocationProvider()
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const testing_provider_cid = Components.ID("{10F622A4-6D7F-43A1-A938-5FFCBE2B1D1D}");
var testing_factory = Components.manager.getClassObject(testing_provider_cid, Components.interfaces.nsIFactory);
Components.manager.nsIComponentRegistrar.registerFactory(testing_provider_cid,
"Test Geolocation Provider",
"@mozilla.org/geolocation/provider;1",
testing_factory);
}
function stop_geolocationProvider()
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

View File

@ -0,0 +1,24 @@
function handleRequest(request, response)
{
var coords = {
latitude: 37.41857,
longitude: -122.08769,
altitude: 42,
accuracy: 42,
altitudeAccuracy: 42,
heading: 42,
speed: 42,
};
var geoposition = {
location: coords,
};
response.setStatusLine("1.0", 200, "OK");
response.setHeader("Content-Type", "aplication/x-javascript", false);
response.write(JSON.stringify(geoposition));
}

View File

@ -33,7 +33,6 @@ function accept() {
clickNotificationButton(kAcceptButton);
}
ensure_geolocationProvider();
SimpleTest.waitForExplicitFinish();
// one-shot position requests

View File

@ -39,7 +39,6 @@ function accept() {
/** Test for Bug **/
ensure_geolocationProvider();
SimpleTest.waitForExplicitFinish();
watchID = navigator.geolocation.watchPosition(successCallback, null, null);

View File

@ -32,7 +32,6 @@ function successCallback(position){
/** Test for Bug **/
ensure_geolocationProvider();
SimpleTest.waitForExplicitFinish();
navigator.geolocation.getCurrentPosition(successCallback, failureCallback, null);

View File

@ -34,7 +34,6 @@ function successCallback(position){
/** Test for Bug **/
ensure_geolocationProvider();
SimpleTest.waitForExplicitFinish();
watchID = navigator.geolocation.getCurrentPosition(successCallback, failureCallback, null);

View File

@ -46,7 +46,6 @@ function testAccepted() {
/** Test for Bug **/
ensure_geolocationProvider();
SimpleTest.waitForExplicitFinish();
watchID = navigator.geolocation.watchPosition(successCallback, failureCallback, null);

View File

@ -23,7 +23,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=452566
const NOT_ENOUGH_ARGS = 2153185281;
ensure_geolocationProvider();
ok(navigator.geolocation, "Should have geolocation");
var exception = null;

View File

@ -21,7 +21,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=455327
<script class="testbody" type="text/javascript">
/** Test for Bug **/
ensure_geolocationProvider();
SimpleTest.waitForExplicitFinish();
stop_geolocationProvider();

View File

@ -102,7 +102,6 @@ TEST_HARNESS_BINS := \
# the build, but that we need for the test harness.
TEST_HARNESS_COMPONENTS := \
test_necko.xpt \
TestGeolocationProvider.js \
$(NULL)
# We need the test plugin as some tests rely on it