1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/geolocation/test_timerRestartWatch.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=526326 1.8 +--> 1.9 +<head> 1.10 + <title>Test for watchPosition </title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="text/javascript" src="geolocation_common.js"></script> 1.13 + 1.14 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.15 +</head> 1.16 +<body> 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=526326">Mozilla Bug 526326</a> 1.18 +<p id="display"></p> 1.19 +<div id="content" style="display: none"> 1.20 + 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script class="testbody" type="text/javascript"> 1.24 + 1.25 +SimpleTest.waitForExplicitFinish(); 1.26 + 1.27 +// ensure we are using the right testing provider 1.28 +resume_geolocationProvider(function() { 1.29 + force_prompt(true, test1); 1.30 +}); 1.31 + 1.32 +var watchID; 1.33 +var times = 0; 1.34 + 1.35 +function errorCallback(err) { 1.36 + ok(err.code == err.TIMEOUT, "ensure error is a timeout."); 1.37 + times++; 1.38 + 1.39 + // make sure we got at least 3 times errorCallback 1.40 + if (times >= 3) { 1.41 + navigator.geolocation.clearWatch(watchID); 1.42 + resume_geolocationProvider(function() { 1.43 + set_network_request_cache_enabled(true, 1.44 + function() { SimpleTest.finish(); } ); 1.45 + }); 1.46 + } 1.47 +} 1.48 + 1.49 +function successCallback(position) { 1.50 + ok(1, "on success"); 1.51 + // Now that we got a success callback, lets try to ensure 1.52 + // that we get a timeout error. 1.53 + // The network cache is already off, now stop the sjs from reponding to requests 1.54 + stop_geolocationProvider(function(){}); 1.55 +} 1.56 + 1.57 +var options = { 1.58 + maximumAge: 0, 1.59 + timeout: 1000 1.60 +}; 1.61 + 1.62 +function test1() { 1.63 + set_network_request_cache_enabled(false, 1.64 + function() { 1.65 + watchID = navigator.geolocation.watchPosition(successCallback, errorCallback, options); 1.66 + }); 1.67 +} 1.68 +</script> 1.69 +</pre> 1.70 +</body> 1.71 +</html> 1.72 +