title: Elegant way of detecting window.opener cross-origin when accessing it's property
body: <p>I have a parent window on <code>http://a.com</code> domain and this window opens with <code>window.open</code> a new window on domain <code>http://b.com</code>. Now, JS on second (child) window tries to access it's parent property like:</p>
  
  <pre><code> var api = {}
  
   if(window.opener.parentProp) { // essential to check for this property
     api = window.opener
   } else {
     api = window
   }
  </code></pre>
  
  <p>which generates the following cross-origin error:</p>
  
  <pre><code>Uncaught DOMException: Blocked a frame with origin "https://b.com" from accessing a cross-origin frame.(…)
  </code></pre>
  
  <p>I have figured out the following solution</p>
  
  <pre><code> try {
     if(window.opener.parentProp) { // essential to check for this property
       api = window.opener
     } else {
       api = window
     }
   } catch(e) {
     api = window
   }
  </code></pre>
  
  <p>but how likes <code>try</code> and <code>catch</code> blocks, right? :D So the question is, are you familiar with more elegant solutions like:</p>
  
  <pre><code>if(window.opener.breakingCrossOriginPolicy) // just a simple property name for example purposes
  </code></pre>
  
  <p>?</p>