Created
February 6, 2012 17:28
-
-
Save arantius/1753499 to your computer and use it in GitHub Desktop.
greasemonkey issue 1508 test case
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
// ==UserScript== | |
// @name iframe test | |
// @version 1 | |
// @namespace iframe | |
// @include http://localhost/1 | |
// @include http://localhost/2 | |
// ==/UserScript== | |
function tdump(msg) { | |
dump(new Date().toLocaleTimeString() + ' ' + msg + '\n'); | |
} | |
if(location.path === '/1') { | |
window.addEventListener('message', function(e) { | |
tdump(e.data); | |
}, false); | |
} | |
if (location.pathname === '/2') { | |
tdump('the userscript has now been executed in the iframe'); | |
} else { | |
document.documentElement.innerHTML = | |
'<iframe src=http://localhost/2></iframe>'; | |
document.querySelector('iframe').onload = function(e) { | |
tdump('iframe onload event (' + e.target.src + ')'); | |
}; | |
setTimeout(function() { | |
document.querySelector('iframe').src = 'about:blank'; | |
}, 5000); | |
setTimeout(function() { | |
document.querySelector('iframe').src = 'http://localhost/2'; | |
}, 10000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment