function MockWindow(width, height, sizer) {
  this.innerWidth = width;
  this.innerHeight = height;
  this.addEventListener = function(e, f) {
    if (e == 'scroll')
      this.scrollCallback = f;
    if (e == 'resize')
      this.resizeCallback = f;
  };
  this.setSize = function(width, height) {
    this.innerWidth = width;
    this.innerHeight = height;
    this.resizeCallback();
  }
  this.scrollTo = function(x, y) {
    if (sizer) {
      x = Math.min(x, parseInt(sizer.style.width) - width);
      y = Math.min(y, parseInt(sizer.style.height) - height);
    }
    this.pageXOffset = Math.max(0, x);
    this.pageYOffset = Math.max(0, y);
    this.scrollCallback();
  };
  this.setTimeout = function(callback, time) {
    this.timerCallback = callback;
    return "timerId";
  };
  this.clearTimeout = function(timerId) {
    this.timerCallback = null;
  };
  this.runTimeout = function() {
    if (this.timerCallback)
      this.timerCallback();
  }
  if (sizer) {
    sizer.resizeCallback_ = function() {
      this.scrollTo(this.pageXOffset, this.pageYOffset);
    }.bind(this);
  }
  this.pageXOffset = 0;
  this.pageYOffset = 0;
  this.scrollCallback = null;
  this.resizeCallback = null;
  this.timerCallback = null;
}
// Utilities that are used in multiple tests.
Utilities that are used in multiple tests.
Utilities that are used in multiple tests .
function MockWindow(width, height, sizer) {
  this.innerWidth = width;
  this.innerHeight = height;
  this.addEventListener = function(e, f) {
    if (e == 'scroll')
      this.scrollCallback = f;
    if (e == 'resize')
      this.resizeCallback = f;
  };
  this.setSize = function(width, height) {
    this.innerWidth = width;
    this.innerHeight = height;
    this.resizeCallback();
  }
  this.scrollTo = function(x, y) {
    if (sizer) {
      x = Math.min(x, parseInt(sizer.style.width) - width);
      y = Math.min(y, parseInt(sizer.style.height) - height);
    }
    this.pageXOffset = Math.max(0, x);
    this.pageYOffset = Math.max(0, y);
    this.scrollCallback();
  };
  this.setTimeout = function(callback, time) {
    this.timerCallback = callback;
    return "timerId";
  };
  this.clearTimeout = function(timerId) {
    this.timerCallback = null;
  };
  this.runTimeout = function() {
    if (this.timerCallback)
      this.timerCallback();
  }
  if (sizer) {
    sizer.resizeCallback_ = function() {
      this.scrollTo(this.pageXOffset, this.pageYOffset);
    }.bind(this);
  }
  this.pageXOffset = 0;
  this.pageYOffset = 0;
  this.scrollCallback = null;
  this.resizeCallback = null;
  this.timerCallback = null;
}
function MockWindow ( width , height , sizer ) { this . innerWidth = width ; this . innerHeight = height ; this . addEventListener = function ( e , f ) { if ( e == 'scroll' ) this . scrollCallback = f ; if ( e == 'resize' ) this . resizeCallback = f ; } ; this . setSize = function ( width , height ) { this . innerWidth = width ; this . innerHeight = height ; this . resizeCallback ( ) ; } this . scrollTo = function ( x , y ) { if ( sizer ) { x = Math . min ( x , parseInt ( sizer . style . width ) - width ) ; y = Math . min ( y , parseInt ( sizer . style . height ) - height ) ; } this . pageXOffset = Math . max ( 0 , x ) ; this . pageYOffset = Math . max ( 0 , y ) ; this . scrollCallback ( ) ; } ; this . setTimeout = function ( callback , time ) { this . timerCallback = callback ; return "timerId" ; } ; this . clearTimeout = function ( timerId ) { this . timerCallback = null ; } ; this . runTimeout = function ( ) { if ( this . timerCallback ) this . timerCallback ( ) ; } if ( sizer ) { sizer . resizeCallback_ = function ( ) { this . scrollTo ( this . pageXOffset , this . pageYOffset ) ; } . bind ( this ) ; } this . pageXOffset = 0 ; this . pageYOffset = 0 ; this . scrollCallback = null ; this . resizeCallback = null ; this . timerCallback = null ; }
Utilities that are used in multiple tests.
Utilities that are used in multiple tests .