UNPKG

accessibility-developer-tools

Version:

This is a library of accessibility-related testing and utility code.

100 lines (81 loc) 2.65 kB
<!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); }); if (parent && parent.iframeLoadHandler) { parent.iframeLoadHandler(); } </script> </body> </html>