- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / platform_apps / web_view / geolocation / geolocation_request_gone / guest.html
1 <!--
2  * Copyright 2013 The Chromium Authors. All rights reserved.  Use of this
3  * source code is governed by a BSD-style license that can be found in the
4  * LICENSE file.
5 -->
6 <html>
7   <head>
8     <script type="text/javascript">
9       // The window reference of the embedder to send post message reply.
10       var embedderWindowChannel = null;
11
12       var g_testName = 'uninitialized';
13
14       var notifyEmbedder = function(msg_array) {
15         embedderWindowChannel.postMessage(JSON.stringify(msg_array), '*');
16       };
17
18       var onGeolocationSuccess = function(position) {
19         var responseArray = [g_testName, 'access-granted'];
20         notifyEmbedder(responseArray);
21       };
22
23       var onGeolocationFailure = function(error) {
24         var responseArray = [g_testName, 'access-denied'];
25         notifyEmbedder(responseArray);
26       };
27
28       var requestGeolocation = function() {
29         navigator.geolocation.getCurrentPosition(onGeolocationSuccess,
30                                                  onGeolocationFailure);
31       };
32
33       var onPostMessageReceived = function(e) {
34         embedderWindowChannel = e.source;
35         var data = JSON.parse(e.data);
36         console.log('request: ' + data[0]);
37         if (data[0] == 'request-geolocation') {
38           window.console.log('guest: request-geolocation');
39           g_testName = data[1];
40           requestGeolocation();
41         }
42       };
43       window.addEventListener('message', onPostMessageReceived, false);
44     </script>
45   </head>
46   <body>
47     <div>
48       This is a guest that makes a geolocation request.
49     </div>
50     <script>
51       console.log('Guest loaded');
52     </script>
53   </body>
54 </html>