B2G/gecko/browser/base/content/test/newtab/head.js
/**
 * Compares the current grid arrangement with the given pattern.
 * @param the pattern (see below)
 * @param the array of sites to compare with (optional)
 *
 * Example: checkGrid("3p,2,,1p")
 * Result: We expect the first cell to contain the pinned site 'http://example.com/#3'.
 *         The second cell contains 'http://example.com/#2'. The third cell is empty.
 *         The fourth cell contains the pinned site 'http://example.com/#4'.
 */
Compares the current grid arrangement with the given pattern.
@param the pattern
@param the array of sites to compare with (optional)


Compares the current grid arrangement with the given pattern . @param the pattern @param the array of sites to compare with ( optional )
function checkGrid(aSitesPattern, aSites) {
  let length = aSitesPattern.split(",").length;
  let sites = (aSites || getGrid().sites).slice(0, length);
  let current = sites.map(function (aSite) {
    if (!aSite)
      return "";
    let pinned = aSite.isPinned();
    let pinButton = aSite.node.querySelector(".newtab-control-pin");
    let hasPinnedAttr = pinButton.hasAttribute("pinned");
    if (pinned != hasPinnedAttr)
      ok(false, "invalid state (site.isPinned() != site[pinned])");
    return aSite.url.replace(/^http:\/\/example\.com\/#(\d+)$/, "$1") + (pinned ? "p" : "");
  });
  is(current, aSitesPattern, "grid status = " + aSitesPattern);
}
function checkGrid ( aSitesPattern , aSites ) { let length = aSitesPattern . split ( "," ) . length ; let sites = ( aSites || getGrid ( ) . sites ) . slice ( 0 , length ) ; let current = sites . map ( function ( aSite ) { if ( ! aSite ) return "" ; let pinned = aSite . isPinned ( ) ; let pinButton = aSite . node . querySelector ( ".newtab-control-pin" ) ; let hasPinnedAttr = pinButton . hasAttribute ( "pinned" ) ; if ( pinned != hasPinnedAttr ) ok ( false , "invalid state (site.isPinned() != site[pinned])" ) ; return aSite . url . replace ( / ^http:\/\/example\.com\/#(\d+)$ / , "$1" ) + ( pinned ? "p" : "" ) ; } ) ; is ( current , aSitesPattern , "grid status = " + aSitesPattern ) ; }
Compares the current grid arrangement with the given pattern.
Compares the current grid arrangement with the given pattern .