Permalink
Browse files

Merge pull request #20 from shane-tomlinson/master

two fixes - one to get rid of infinite loop in IE, one to allow tests to be run from clients other than localhost.
  • Loading branch information...
2 parents 7bdafd5 + a04e7e1 commit 64f92b1cff7671d0899ea38f69a029fc9f82f8b5 @lloyd lloyd committed Jan 5, 2012
Showing with 51 additions and 3 deletions.
  1. +14 −0 test/cases/multiple-frame/child.html
  2. +31 −0 test/cases/multiple-frame/run.js
  3. +4 −2 test/cases/origin/run.js
  4. +1 −0 test/index.html
  5. +1 −1 winchan.js
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="/winchan.js"></script>
+<script>
+// Delay the load so that there is time to add the extra iframe in the parent.
+setTimeout(function() {
+ WinChan.onOpen(function(origin, args, cb) {
+ cb(args);
+ });
+}, 1000);
+</script>
+</head>
+</html>
@@ -0,0 +1,31 @@
+$(document).ready(function(){
+ asyncTest("multiple frames in parent, stresses relay frame - takes ~1 second.", function() {
+ var iframe,
+ argString = "This is a string we'll send into and back from the dialog: " +
+ (new Date()).toString();
+
+ setTimeout(function() {
+ // We are adding the iframe AFTER the winchan is open. The child frame
+ // does not respond until 1 second after load.
+ iframe = document.createElement("iframe");
+ iframe.setAttribute("src", "javascript:0;");
+ // Give the extra frame a name that comes after the name of the WinChan
+ // relay frame in the alphabet so that the relay frame is not the last
+ // frame in window.opener.frames.
+ iframe.setAttribute("id", "zzzz");
+ document.body.appendChild(iframe);
+ }, 500);
+
+ WinChan.open({
+ url: "cases/multiple-frame/child.html",
+ relay_url: "/relay.html",
+ window_features: "width=700,height=375",
+ params: argString
+ }, function(err, resp) {
+ equal(resp, argString);
+ iframe.parentNode.removeChild(iframe);
+ start();
+ });
+ });
+
+});
View
@@ -15,10 +15,12 @@ $(document).ready(function(){
asyncTest("different origin correctly reported", function() {
var argString = "This is a string we'll send into and back from the dialog: " +
(new Date()).toString();
- var other_url = 'http://127.0.0.1:8200/test/cases/origin/child.html';
+ var other_host = document.location.protocol + "//" + document.location.hostname + ":8200";
+
+ var other_url = other_host + '/test/cases/origin/child.html';
WinChan.open({
url: other_url,
- relay_url: "http://127.0.0.1:8200/relay.html",
+ relay_url: other_host + "/relay.html",
window_features: "width=700,height=375"
}, function(err, resp) {
equal(resp, /^(https?:\/\/[-_a-zA-Z\.0-9:]+)/.exec(window.location.href)[1]);
View
@@ -12,6 +12,7 @@
<script type="text/javascript" src="cases/basic/run.js"></script>
<script type="text/javascript" src="cases/origin/run.js"></script>
<script type="text/javascript" src="cases/nav-away/run.js"></script>
+ <script type="text/javascript" src="cases/multiple-frame/run.js"></script>
</head>
<body>
View
@@ -52,7 +52,7 @@
var loc = window.location;
var frames = window.opener.frames;
var origin = loc.protocol + '//' + loc.host;
- for (i = frames.length - 1; i >= 0; i++) {
+ for (var i = frames.length - 1; i >= 0; i--) {
try {
if (frames[i].location.href.indexOf(origin) === 0 &&
frames[i].name === RELAY_FRAME_NAME)

0 comments on commit 64f92b1

Please sign in to comment.