file_crossOriginObjects.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <script>
  5. // Override the |frames| property to test that such overrides are
  6. // properly ignored cross-origin.
  7. window.frames = "override";
  8. // If we get a postMessage, we grab references to everything and set
  9. // document.domain to trim off our topmost subdomain.
  10. window.onmessage = function(evt) {
  11. window.windowReferences = [];
  12. window.locationReferences = [];
  13. for (var i = 0; i < parent.length; ++i) {
  14. windowReferences.push(parent[i]);
  15. locationReferences.push(parent[i].location);
  16. }
  17. document.domain = document.domain.substring(document.domain.indexOf('.') + 1);
  18. evt.source.postMessage('', '*');
  19. }
  20. function checkWindowReferences() {
  21. for (var i = 0; i < parent.length; ++i) {
  22. if (windowReferences[i] != parent[i])
  23. throw new Error("Window references don't match for " + i + " after document.domain");
  24. if (locationReferences[i] != parent[i].location)
  25. throw new Error("Location references don't match for " + i + " after document.domain");
  26. }
  27. return true;
  28. }
  29. </script>
  30. </head>
  31. <body>
  32. </body>
  33. </html>