B2G/gecko/content/base/src/CSPUtils.jsm
/**
   * Intersects with another CSPSourceList, deciding the subset directive
   * that should be enforced, and returning a new instance.
   * @param that
   *        the other CSPSourceList to intersect "this" with
   * @returns
   *        a new instance of a CSPSourceList representing the intersection
   */
Intersects with another CSPSourceList, deciding the subset directive
that should be enforced, and returning a new instance.
@param that
the other CSPSourceList to intersect "this" with
@returns
a new instance of a CSPSourceList representing the intersection
Intersects with another CSPSourceList deciding the subset directive that should be enforced and returning a new instance . @param that the other CSPSourceList to intersect " this " with @returns a new instance of a CSPSourceList representing the intersection
function cspsd_intersectWith(that) {
    var newCSPSrcList = null;
    if (!that) return this.clone();
    if (this.isNone() || that.isNone())
      newCSPSrcList = CSPSourceList.fromString("'none'", this._CSPRep);
    if (this.isAll()) newCSPSrcList = that.clone();
    if (that.isAll()) newCSPSrcList = this.clone();
    if (!newCSPSrcList) {
      var isrcs = [];
      for (var i in this._sources) {
        for (var j in that._sources) {
          var s = that._sources[j].intersectWith(this._sources[i]);
          if (s) {
            isrcs.push(s);
          }
        }
      }
      dup: for (var i = 0; i < isrcs.length; i++) {
        for (var j = 0; j < i; j++) {
          if (isrcs[i].equals(isrcs[j])) {
            isrcs.splice(i, 1);
            i--;
            continue dup;
          }
        }
      }
      newCSPSrcList = new CSPSourceList();
      newCSPSrcList._sources = isrcs;
    }
    newCSPSrcList._isImplicit = this._isImplicit && that._isImplicit;
    if ((!newCSPSrcList._CSPRep) && that._CSPRep) {
      newCSPSrcList._CSPRep = that._CSPRep;
    }
    return newCSPSrcList;
  }
function cspsd_intersectWith ( that ) { var newCSPSrcList = null ; if ( ! that ) return this . clone ( ) ; if ( this . isNone ( ) || that . isNone ( ) ) newCSPSrcList = CSPSourceList . fromString ( "'none'" , this . _CSPRep ) ; if ( this . isAll ( ) ) newCSPSrcList = that . clone ( ) ; if ( that . isAll ( ) ) newCSPSrcList = this . clone ( ) ; if ( ! newCSPSrcList ) { var isrcs = [ ] ; for ( var i in this . _sources ) { for ( var j in that . _sources ) { var s = that . _sources [ j ] . intersectWith ( this . _sources [ i ] ) ; if ( s ) { isrcs . push ( s ) ; } } } dup : for ( var i = 0 ; i < isrcs . length ; i ++ ) { for ( var j = 0 ; j < i ; j ++ ) { if ( isrcs [ i ] . equals ( isrcs [ j ] ) ) { isrcs . splice ( i , 1 ) ; i -- ; continue dup ; } } } newCSPSrcList = new CSPSourceList ( ) ; newCSPSrcList . _sources = isrcs ; } newCSPSrcList . _isImplicit = this . _isImplicit && that . _isImplicit ; if ( ( ! newCSPSrcList . _CSPRep ) && that . _CSPRep ) { newCSPSrcList . _CSPRep = that . _CSPRep ; } return newCSPSrcList ; }
Intersects with another CSPSourceList, deciding the subset directive
 that should be enforced, and returning a new instance.
Intersects with another CSPSourceList deciding the subset directive that should be enforced and returning a new instance .
// the shortcuts didn't apply, must do intersection the hard way. // --  find only common sources // XXX (sid): we should figure out a better algorithm for this. // This is horribly inefficient. // Next, remove duplicates // if either was explicit, so is this.