2008-09-04 16:31:09 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for watchPosition </title>
|
|
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="text/javascript" src="prompt_common.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=">Mozilla Bug </a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
var numCallbacks = 5;
|
|
|
|
var callbackCounter = new Array(numCallbacks);
|
|
|
|
var watchID = new Array(numCallbacks);
|
|
|
|
|
2008-11-12 14:52:56 -08:00
|
|
|
function failureCallback(error)
|
|
|
|
{
|
2008-12-05 08:29:43 -08:00
|
|
|
ok(error.code == error.POSITION_UNAVAILABLE, "Failure was something other than position unavailable");
|
2008-11-12 14:52:56 -08:00
|
|
|
removePrompt();
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
2008-09-04 16:31:09 -07:00
|
|
|
// define success callbacks
|
|
|
|
for(var i = 0; i < numCallbacks; i++) {
|
|
|
|
eval("function successCallback" + i + "(position) {" +
|
|
|
|
"callbackCounter[" + i + "]++;" +
|
|
|
|
"success_callback(position);" +
|
|
|
|
"}"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function registerWatches() {
|
|
|
|
for(var i = 0; i < numCallbacks; i++) {
|
|
|
|
watchID[i] = eval("navigator.geolocation.watchPosition(successCallback"
|
2008-11-12 14:52:56 -08:00
|
|
|
+ i + ", failureCallback, null);"
|
2008-09-04 16:31:09 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearWatches() {
|
|
|
|
for(var i = 0; i < numCallbacks; i++)
|
|
|
|
navigator.geolocation.clearWatch(watchID[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testDeclined() {
|
|
|
|
clearWatches();
|
|
|
|
removePrompt();
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Test for Bug **/
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
attachPrompt();
|
|
|
|
|
|
|
|
ok(navigator.geolocation, "Ensure that the geolocation object is present");
|
|
|
|
|
|
|
|
promptOption = DECLINE;
|
|
|
|
|
|
|
|
registerWatches();
|
|
|
|
|
|
|
|
// wait for position changes
|
|
|
|
setTimeout(testDeclined, timeout);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|