title: security error the operation is insecure in firefox document.stylesheets
body: <p>The following code throws an error in the Firefox Console at the line with the continue. </p>
  
  <pre><code>SecurityError: The operation is insecure.
  if( !sheet.cssRules ) { continue; }
  </code></pre>
  
  <p>However does not in Chrome and IE 11... Can someone explain the -why- of this? (And also how to re-work to make it safe.) I assume this is a cross-domain issue, but I'm stuck as how to re-work the code properly.</p>
  
  <pre><code>var bgColor = getStyleRuleValue('background-color', 'bg_selector');
  
  function getStyleRuleValue(style, selector, sheet) {
    var sheets = typeof sheet !== 'undefined' ? [sheet] : document.styleSheets;
    for (var i = 0, l = sheets.length; i &lt; l; i++) {
      var sheet = sheets[i];
      if( !sheet.cssRules ) { continue; }
      for (var j = 0, k = sheet.cssRules.length; j &lt; k; j++) {
        var rule = sheet.cssRules[j];
        if (rule.selectorText &amp;&amp; rule.selectorText.split(',').indexOf(selector) !== -1) 
           return rule.style[style];            
       }
     }
    return null;
   }
  </code></pre>