Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Fixing relay frame bug where multiple frames sometimes caused infinit…
Browse files Browse the repository at this point in the history
…e loop when searching for relay.

* Add test case to ensure the problem happens on IE.
  • Loading branch information
Shane Tomlinson committed Jan 5, 2012
1 parent 7bdafd5 commit 2899317
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
14 changes: 14 additions & 0 deletions test/cases/multiple-frame/child.html
Original file line number Diff line number Diff line change
@@ -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>
31 changes: 31 additions & 0 deletions test/cases/multiple-frame/run.js
Original file line number Diff line number Diff line change
@@ -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();
});
});

});
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion winchan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2899317

Please sign in to comment.