I'm currently developping a chrome extension based on manifest v3.
I'm trying to access a table from a content_script.
The table is located into an iframe inside another iframe.
The page is structured as follow
--------------------------------------------------------------------------------------------------------------------------------------
<iframe id="iframe_centrale" src="/[...]">
[...]
<iframe id="iframe" src="/[...]">
[...]
<table></table>
[...]
</iframe>
[...]
</iframe>
--------------------------------------------------------------------------------------------------------------------------------------
I'm accessing the table as follow
--------------------------------------------------------------------------------------------------------------------------------------
var tableElement = null;
var iframe = null;
iframe = document.getElementById('iframe_centrale');
if(null != iframe)
{
iframe = iframe.contentWindow.document.getElementById("iframe");
if(null != iframe)
{
tableElement = iframe.contentWindow.document.evaluate("//table", iframe.contentDocument, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if((null != tableElement)
{
// Read table
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------
When I'm trying to access the second iframe I face the following error
--------------------------------------------------------------------------------------------------------------------------------------
Uncaught SecurityError: Blocked a frame with origin "https://subdomain.domain.fr" from accessing a frame with origin "https://subdomain.domain.fr". The frame requesting access set "document.domain" to "domain.fr", but the frame being accessed did not. Both must set "document.domain" to the same value to allow access --------------------------------------------------------------------------------------------------------------------------------------
What I don't understand is why I'm having this exception when the first iframe URL is in the same domain than the first one.
I also tried to workaround this exception by retrieving the iframe id using 'chrome.webNavigation.getAllFrames()' and injecting a script into it using 'chrome.tabs.executeScript()'
However the second iframe is not detected since it's itself into an iframe.
Does anybody knows why I'm facing a cross-origin exeception ?
Does anybody knows how I could retrieve the second iframe id to inject a script ?
Thanks in advance for your help.