Last active
March 17, 2016 18:14
-
-
Save pstjvn/dc034f24fa14a079ce92 to your computer and use it in GitHub Desktop.
Question for l4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test scenario.</title> | |
</head> | |
<body> | |
<script> | |
var jobs = [], jobn = 0, result = '', i = 1; | |
var body = "<script>top.result += '3'</scr" + | |
"ipt><body></body>"; | |
function creationManager() { | |
if (jobs.length == 0) { | |
setTimeout(function() { | |
console.log('>>>', result); | |
}, 0); | |
return; | |
} | |
result += '1'; | |
jobs[jobn](); | |
result += '2'; | |
jobn++; | |
if (jobn >= jobs.length) { | |
jobs.length = 0; | |
jobn = 0; | |
} | |
creationManager(); | |
} | |
function writeBody(doc) { doc.write(body); } | |
function createWindow() { | |
document.getElementById('c' + i++) | |
.src = 'javascript:top.writeBody(document)'; | |
}; | |
jobs[jobs.length] = createWindow; | |
jobs[jobs.length] = createWindow; | |
window.onload = creationManager; | |
</script> | |
<script>document.write("<iframe id='c1' src='about:blank'></iframe><iframe id='c2'></iframe>");</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment