B2G/gecko/browser/components/sessionstore/src/SessionStore.jsm
/**
   * Splits out the cookies from aWinState into aTargetWinState based on the
   * tabs that are in aTargetWinState.
   * This alters the state of aWinState and aTargetWinState.
   */
Splits out the cookies from aWinState into aTargetWinState based on the
tabs that are in aTargetWinState.
This alters the state of aWinState and aTargetWinState.
Splits out the cookies from aWinState into aTargetWinState based on the tabs that are in aTargetWinState . This alters the state of aWinState and aTargetWinState .
function ssi_splitCookiesFromWindow(aWinState, aTargetWinState) {
    if (!aWinState.cookies || !aWinState.cookies.length)
      return;
    let cookieHosts = {};
    aTargetWinState.tabs.forEach(function(tab) {
      tab.entries.forEach(function(entry) {
        this._extractHostsForCookiesFromEntry(entry, cookieHosts, false);
      }, this);
    }, this);
    let hosts = Object.keys(cookieHosts).join("|").replace("\\.", "\\.", "g");
    if (!hosts.length)
      return;
    let cookieRegex = new RegExp(".*(" + hosts + ")");
    for (let cIndex = 0; cIndex < aWinState.cookies.length;) {
      if (cookieRegex.test(aWinState.cookies[cIndex].host)) {
        aTargetWinState.cookies =
          aTargetWinState.cookies.concat(aWinState.cookies.splice(cIndex, 1));
        continue;
      }
      cIndex++;
    }
  }
function ssi_splitCookiesFromWindow ( aWinState , aTargetWinState ) { if ( ! aWinState . cookies || ! aWinState . cookies . length ) return ; let cookieHosts = { } ; aTargetWinState . tabs . forEach ( function ( tab ) { tab . entries . forEach ( function ( entry ) { this . _extractHostsForCookiesFromEntry ( entry , cookieHosts , false ) ; } , this ) ; } , this ) ; let hosts = Object . keys ( cookieHosts ) . join ( "|" ) . replace ( "\\." , "\\." , "g" ) ; if ( ! hosts . length ) return ; let cookieRegex = new RegExp ( ".*(" + hosts + ")" ) ; for ( let cIndex = 0 ; cIndex < aWinState . cookies . length ; ) { if ( cookieRegex . test ( aWinState . cookies [ cIndex ] . host ) ) { aTargetWinState . cookies = aTargetWinState . cookies . concat ( aWinState . cookies . splice ( cIndex , 1 ) ) ; continue ; } cIndex ++ ; } }
Splits out the cookies from aWinState into aTargetWinState based on the
 tabs that are in aTargetWinState.
Splits out the cookies from aWinState into aTargetWinState based on the tabs that are in aTargetWinState .
// Get the hosts for history entries in aTargetWinState // By creating a regex we reduce overhead and there is only one loop pass // through either array (cookieHosts and aWinState.cookies). // If we don't actually have any hosts, then we don't want to do anything.