5415954b23eaa3429b98c4b3a00c2fa75bdefb8f
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2012 Intel Corporation.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8 * Redistributions of works must retain the original copyright notice, this list
9   of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the original copyright notice,
11   this list of conditions and the following disclaimer in the documentation
12   and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its contributors
14   may be used to endorse or promote products derived from this work without
15   specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
21 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 Authors:
29         Jin,Weihu <weihux.jin@intel.com>
30
31 -->
32 <html>
33 <head>
34   <title>Geolocation Test:Geolocation_watchPosition_PositionOptions_timeout_0_maximumAge_0</title>
35   <link rel="author" title="Intel" href="http://www.intel.com/" />
36     <link rel="help" href="http://www.w3.org/TR/2012/PR-geolocation-API-20120510/#geolocation" />
37   <meta name="assert" content="watchPosition - should be triggered when timeout is 0 and maximumAge is 0" />
38   <script src="../resources/testharness.js"></script>
39   <script src="../resources/testharnessreport.js"></script>
40   <script src="testinterface.js"></script>
41 </head>
42 <body>
43   <div id="log"></div>
44   <script>
45     //==== PRIORITY P2
46
47     var t = async_test(document.title);
48     setup({timeout: 60000});
49
50     try {
51       if(!check("geolocation", navigator)) {
52         t.step(function() {
53           assert_unreach("navigator.geolocation missing, test failed");
54         });
55       } else {
56         navigator.geolocation.watchPosition(successCallback, errorCallback, { timeout: 0, maximumAge: 0 });
57       }
58     } catch(err) {
59       t.step(function() {
60         assert_unreached("Error message: {" + err.message + " }");
61       });
62     }
63
64     function successCallback(position) {
65       t.done();
66     }
67
68     function errorCallback(error) {
69       var msg = "";
70       if(error.code == 0) {
71         msg = "UNKNOW_ERROR";
72       } else if (error.code == 1) { // PERMISSION_DENIED
73         msg = "The user rejects the browser requests";
74       } else if (error.code == 2) { //POSITION_UNAVAILABLE
75         msg = "Cannot find your location. Make sure your networkconnection is active and click the link to try again.";
76       } else if (error.code == 3) { //TIMEOUT
77         t.done();
78         return;
79       }
80       t.step(function () {
81         assert_unreached("PositionErrorCallback handle Event is triggered with the exception of "+ msg.toString());
82       });
83       t.done();
84     }
85   </script>
86 </body>
87 </html>