blob: 5542f79cfc35a4e67b9b6539337195b9e29a4674 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
<!DOCTYPE html>
<!--
This file is responsible for setting up the inner peer half of an XPC
communication channel. It instantiates a CrossPageChannel and attempts to
connect to the outer peer. The XPC configuration should match that of the
outer peer (i.e. same channel name, polling URIs, etc).
-->
<html>
<!--
Copyright 2009 The Closure Library Authors. All Rights Reserved.
Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<title>XPC test inner frame</title>
<script src="../../../base.js" type="text/javascript"></script>
<script type="text/javascript">
goog.require('goog.debug.Logger');
goog.require('goog.dom');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.net.xpc.CrossPageChannel');
</script>
<script type="text/javascript">
var channel;
var queuedMessage;
var OBJECT_RESULT_FROM_SERVICE = {'favorites': 'pie'};
function clearDebug() {
document.getElementById('debugDiv').innerHTML = '';
}
function instantiateChannel(cfg) {
if (window.channel) {
window.channel.dispose();
}
window.channel = new goog.net.xpc.CrossPageChannel(cfg);
window.channel.registerService('echo', echoHandler);
window.channel.registerService('response', responseHandler);
connectChannel(
parent.driver && parent.driver.innerFrameConnected ?
goog.bind(parent.driver.innerFrameConnected, parent.driver) : null);
}
function connectChannel(opt_callback) {
window.channel.connect(opt_callback || goog.nullFunction);
}
function sendEcho(payload) {
window.channel.send('echo', payload);
}
function echoHandler(payload) {
window.channel.send('response', payload);
return OBJECT_RESULT_FROM_SERVICE;
}
function isConnected() {
return window.channel && window.channel.isConnected();
}
function responseHandler(payload) {
if (parent.driver && parent.driver.innerFrameGotResponse) {
parent.driver.innerFrameGotResponse(payload);
}
}
</script>
</head>
<body>
<div style="position:absolute">
Debug [<a href="#" onclick="clearDebug()">clear</a>]: <br>
<div id=debugDiv style="border: 1px #000000 solid; font-size:xx-small"></div>
</div>
<script type="text/javascript">
var debugDiv = goog.dom.getElement('debugDiv');
var logger = goog.debug.Logger.getLogger('goog.net.xpc');
logger.setLevel(goog.debug.Logger.Level.ALL);
logger.addHandler(function(logRecord) {
var msgElm = goog.dom.createDom('div');
msgElm.innerHTML = logRecord.getMessage();
goog.dom.appendChild(debugDiv, msgElm);
});
</script>
</body>
</html>
|