04a2b9e918ee8f718e8ca6d24242be49db7a920aLuke Smith eventKey = 'event:' + Y.stamp(Y.config.win) + 'resize',
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith // IE doesn't allow simulation of window.onresize, so I can't use
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith //Y.Event.simulate(Y.config.win, 'resize');
d1c882403d2bb4f003659393f9d1a635d47a7681Luke Smith setTimeout(function () {
9d8476d6656a36484b5450b9c4ac540f07e8b6d4Luke Smith // I can't get this damn test to pass in CI. It's likely a bad
9d8476d6656a36484b5450b9c4ac540f07e8b6d4Luke Smith // test, but I'm having a hell of a time divising a good one.
9d8476d6656a36484b5450b9c4ac540f07e8b6d4Luke Smith "test resize event throttling": true
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith "test Y.on('windowresize', fn)": function () {
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith function handler(e) {
d1c882403d2bb4f003659393f9d1a635d47a7681Luke Smith Y.Assert.areSame(win, thisObj, "this should be window");
d1c882403d2bb4f003659393f9d1a635d47a7681Luke Smith Y.Assert.areSame(win, e.target, "e.target should be window");
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith "test node.on('windowresize', fn)": function () {
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith refNode = Y.Node.create('<div />').appendTo(Y.one('body')),
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith function handler(e) {
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith // TODO: is this a bug?
d1c882403d2bb4f003659393f9d1a635d47a7681Luke Smith Y.Assert.areSame(win, thisObj, "this should be window");
d1c882403d2bb4f003659393f9d1a635d47a7681Luke Smith Y.Assert.areSame(win, e.target, "e.target should be window");
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith "test resize event throttling": function () {
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith // This prevents the test from timing out if the browser is
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith // inordinately slow
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith // Allow for 10ms of leeway from the threshold. FF is firing a few
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith // milliseconds before the threshold, and I think that's close
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith var end = new Date();
72ead0941bf169d58ad0a9045431338d68bdd965Luke Smith Y.assert(isOldGecko || (end - start + fudge >= threshold),
72ead0941bf169d58ad0a9045431338d68bdd965Luke Smith "Fired before threshold (" + threshold + ") - delta: " +
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith // recursive async function that fires resize on an incrementing
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith // delay, starting at 10ms, then 20ms, 30ms, and so on.
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith start = new Date();
cefe9be30f9a5722340b7d0cdf38cb03232fa963Luke Smith}, '@VERSION@' ,{requires:['event-resize', 'test']});