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
8 <script type="text/javascript">
9 // The window reference of the embedder to send post message reply.
10 var embedderWindowChannel = null;
12 var g_testName = 'uninitialized';
14 var notifyEmbedder = function(msg_array) {
15 embedderWindowChannel.postMessage(JSON.stringify(msg_array), '*');
18 var onGeolocationSuccess = function(position) {
19 var responseArray = [g_testName, 'access-granted'];
20 notifyEmbedder(responseArray);
23 var onGeolocationFailure = function(error) {
24 var responseArray = [g_testName, 'access-denied'];
25 notifyEmbedder(responseArray);
28 var requestGeolocation = function() {
29 navigator.geolocation.getCurrentPosition(onGeolocationSuccess,
30 onGeolocationFailure);
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');
43 window.addEventListener('message', onPostMessageReceived, false);
48 This is a guest that makes a geolocation request.
51 console.log('Guest loaded');