MOBILE-4303 iframe: Avoid trying to access inaccessible iframes

With this change, the error about trying to access an iframe with different protocol, domain or port should no longer appear in console
This commit is contained in:
Dani Palou 2023-04-03 15:39:28 +02:00
parent 28b48ac524
commit 9211b350dc

View File

@ -231,6 +231,12 @@ export class CoreIframeUtilsProvider {
* @returns Window and Document.
*/
getContentWindowAndDocument(element: CoreFrameElement): { window: Window | null; document: Document | null } {
const src = 'src' in element ? element.src : element.data;
if (!CoreUrlUtils.isLocalFileUrl(src)) {
// No permissions to access the iframe.
return { window: null, document: null };
}
let contentWindow: Window | null = 'contentWindow' in element ? element.contentWindow : null;
let contentDocument: Document | null = null;