{"ScriptPreparationCode":"var iframeElementCollection = document.getElementsByTagName(\u0027iframe\u0027);\r\nvar findWindow = window.frames[0];\r\n\r\nfunction isIframeElement(el) {\r\n\treturn el.tagName === \u0027IFRAME\u0027;\r\n}\r\n\r\nfunction getAllIframes(from) {\r\n\tconst iframes = [];\r\n\r\n\tfor(const el of from.querySelectorAll(\u0027*\u0027)) {\r\n\t\tif(isIframeElement(el)) {\r\n\t\t\tiframes.push(el);\r\n\t\t} else if(el.shadowRoot) {\r\n\t\t\tiframes.push(...getAllIframes(el.shadowRoot));\r\n\t\t}\r\n\t}\r\n\r\n\treturn iframes;\r\n}","TestCases":[{"Name":"finding a window in live collection","Code":"for(const iframeEl of iframeElementCollection) {\r\n if(findWindow === iframeEl.contentWindow) {\r\n return iframeEl;\r\n }\r\n}","IsDeferred":false},{"Name":"finding a window with shadowroot handling","Code":"for(const iframeEl of getAllIframes(document.body)) {\r\n if(findWindow === iframeEl.contentWindow) {\r\n return iframeEl;\r\n }\r\n}","IsDeferred":false}]}