JSFiddle - React, Tailwind, and code Playground
HTML
<iframe src="javascript:window.parent.f1 = window;" style="z-index: 1" frameborder="0"></iframe>
<h1 style="text-align: center" onclick="f1.open('http://bb.com')">
First Iframe Blocked [OK]
</h1>
<h1 style="text-align: center" onclick="f2.open('http://bb.com')">
Second Iframe (By JavasCript) blocked [OK]
</h1>
<h1 style="text-align: center" onclick="f3.open('http://bb.com')">
Second Iframe (By Javascript + SetTimeout) vulnerable [FAIL]
</h1>
JavaScript
document.body.insertAdjacentHTML('beforeend', '<iframe src="javascript:window.parent.f2 = window;" style="z-index: 1" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>');
setTimeout(function(){
document.body.insertAdjacentHTML('beforeend', '<iframe src="javascript:window.parent.f3 = window;" style="z-index: 1" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>');
});