portnetwork_worker1.js 974 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2011 The Closure Library Authors. All Rights Reserved.
  2. // Use of this source code is governed by the Apache License, Version 2.0.
  3. // See the COPYING file for details.
  4. /**
  5. * @fileoverview A web worker for integration testing the PortPool class.
  6. *
  7. * @nocompile
  8. */
  9. self.CLOSURE_BASE_PATH = '../../';
  10. importScripts('../../bootstrap/webworkers.js');
  11. importScripts('../../base.js');
  12. // The provide is necessary to stop the jscompiler from thinking this is an
  13. // entry point and adding it into the manifest incorrectly.
  14. goog.provide('goog.messaging.testdata.portnetwork_worker1');
  15. goog.require('goog.messaging.PortCaller');
  16. goog.require('goog.messaging.PortChannel');
  17. function startListening() {
  18. var caller =
  19. new goog.messaging.PortCaller(new goog.messaging.PortChannel(self));
  20. caller.dial('frame').registerService('sendToMain', function(msg) {
  21. msg.push('worker1');
  22. caller.dial('main').send('result', msg);
  23. }, true);
  24. }
  25. startListening();