crossdomainrpc_test_response.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright 2007 The Closure Library Authors. All Rights Reserved.
  5. Use of this source code is governed by the Apache License, Version 2.0.
  6. See the COPYING file for details.
  7. -->
  8. <!--
  9. In reality, this response comes from a different domain. For simplicity of
  10. testing, this response is one the same domain, while exercising the same
  11. functionality.
  12. -->
  13. <title>crossdomainrpc test response</title>
  14. <body>
  15. <script type="text/javascript" src="../base.js"></script>
  16. <script type="text/javascript">
  17. goog.require('goog.Uri.QueryData');
  18. goog.require('goog.dom');
  19. goog.require('goog.events.EventTarget');
  20. goog.require('goog.json');
  21. goog.require('goog.log');
  22. goog.require('goog.net.EventType');
  23. goog.require('goog.userAgent');
  24. </script>
  25. <script type="text/javascript" src="crossdomainrpc.js"></script>
  26. <script type="text/javascript">
  27. function createPayload(size) {
  28. var chars = [];
  29. for (var i = 0; i < size; i++) {
  30. chars.push('0');
  31. }
  32. return chars.join('');
  33. };
  34. var payload = createPayload(16 * 1024);
  35. var currentDirectory = location.href.substring(
  36. 0, location.href.lastIndexOf('/')
  37. );
  38. var echo = {};
  39. echo[goog.net.CrossDomainRpc.PARAM_ECHO_REQUEST_ID] = 0;
  40. echo[goog.net.CrossDomainRpc.PARAM_ECHO_DUMMY_URI] = goog.userAgent.EDGE_OR_IE ?
  41. currentDirectory + '/crossdomainrpc_test.gif' :
  42. currentDirectory + '/crossdomainrpc_test.css';
  43. goog.net.CrossDomainRpc.sendResponse(
  44. '({"result":"' + payload + '"})',
  45. true, // is JSON
  46. echo, // parameters to echo back
  47. 123, // response code
  48. '{"a":1,"b":"2"}' // response headers
  49. );
  50. </script>
  51. </body>
  52. </html>