title: Cross-origin frame issue while accessing the iframe contentDocument property
body: <p><strong>What I need</strong>: I want to inject scripts in to all iframes (windows) presented in a web page (as part of my chrome extension development).</p>
  
  <p>While doing so I am accessing iframe element contentDocument property, its causing the below error mentioned.</p>
  
  <p>Error: <code>Error: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "xxx.com" from accessing a cross-origin frame.
      at Error (native)
      at checkLoaded (chrome-extension://hkdhfkdhfkdhfkdhfkdhfkdhkdkd/js/app.js:152:33)</code></p>
  
  <p>I know we can't access elements or frames that have a different domain. But that is not the case in my scenario.</p>
  
  <p>How I verified it:</p>
  
  <pre><code>Protocol = https (Not able mention it as part of URLs as stackoverflow is not allowing me do so)
  
  iframe.src = xxx.com/dfg/rty?id=50061000000pOCB&amp;isdtp=vw&amp;inCon…85f85811b751bf4b4a18b5e&amp;IFrameOrigin=https%3A%2F%2Fxxx
  
  iframe.ownerdocument.location.origin = xxx.com
  </code></pre>
  
  <p>From the above information we can understand both the iframe and its parent document are having same domain.</p>
  
  <p>then I checked the document domain from where I am executing the script (chrome extension content script page), since content script shares the same document as web-page I got the same domain (xxx.com), but the content-script url is different (chrome-extension://kfhdkfdhfildfldf/js/app.js). Do this causing the issue.</p>
  
  <p>Can any one please try to explain me why cross-origin issue is occurring though the domains are same across the iframes.</p>