B2G/gecko/image/test/mochitest/animationPolling.js
/**
 * Create a new AnimationTest object.
 *
 * @param pollFreq The amount of time (in ms) to wait between consecutive
 *        snapshots if the reference image and the test image don't match.
 * @param timeout The total amount of time (in ms) to wait before declaring the
 *        test as failed.
 * @param referenceElementId The id attribute of the reference image element, or
 *        the source of the image to change to, once the reference snapshot has
 *        been successfully taken. This latter option could be used if you don't
 *        want the image to become invisible at any time during the test.
 * @param imageElementId The id attribute of the test image element.
 * @param debugElementId The id attribute of the div where links should be
 *        appended if the test fails.
 * @param cleanId The id attribute of the div or element to use as the 'clean'
 *        test. This element is only enabled when we are testing to verify that
 *        the reference image has been loaded. It can be undefined.
 * @param srcAttr The location of the source of the image, for preloading. This
 *        is usually not required, but it useful for preloading reference
 *        images.
 * @param xulTest A boolean value indicating whether or not this is a XUL test
 *        (uses hidden=true/false rather than display: none to hide/show
 *        elements).
 * @param closeFunc A function that should be called when this test is finished.
 *        If null, then cleanUpAndFinish() will be called. This can be used to
 *        chain tests together, so they are all finished exactly once.
 * @returns {AnimationTest}
 */
Create a new AnimationTest object.
@param pollFreq The amount of time (in ms) to wait between consecutive
snapshots if the reference image and the test image don't match.
@param timeout The total amount of time (in ms) to wait before declaring the
test as failed.
@param referenceElementId The id attribute of the reference image element, or
the source of the image to change to, once the reference snapshot has
been successfully taken. This latter option could be used if you don't
want the image to become invisible at any time during the test.
@param imageElementId The id attribute of the test image element.
@param debugElementId The id attribute of the div where links should be
appended if the test fails.
@param cleanId The id attribute of the div or element to use as the 'clean'
test. This element is only enabled when we are testing to verify that
the reference image has been loaded. It can be undefined.
@param srcAttr The location of the source of the image, for preloading. This
is usually not required, but it useful for preloading reference
images.
@param xulTest A boolean value indicating whether or not this is a XUL test
(uses hidden=true/false rather than display: none to hide/show
elements).
@param closeFunc A function that should be called when this test is finished.
If null, then cleanUpAndFinish() will be called. This can be used to
chain tests together, so they are all finished exactly once.
Create a new AnimationTest object . @param pollFreq The amount of time ( in ms ) to wait between consecutive snapshots if the reference image and the test image don ' t match . @param timeout The total amount of time ( in ms ) to wait before declaring the test as failed . @param referenceElementId The id attribute of the reference image element or the source of the image to change to once the reference snapshot has been successfully taken . This latter option could be used if you don ' t want the image to become invisible at any time during the test . @param imageElementId The id attribute of the test image element . @param debugElementId The id attribute of the div where links should be appended if the test fails . @param cleanId The id attribute of the div or element to use as the ' clean ' test . This element is only enabled when we are testing to verify that the reference image has been loaded . It can be undefined . @param srcAttr The location of the source of the image for preloading . This is usually not required but it useful for preloading reference images . @param xulTest A boolean value indicating whether or not this is a XUL test ( uses hidden = true / false rather than display : none to hide / show elements ) . @param closeFunc A function that should be called when this test is finished . If null then cleanUpAndFinish () will be called . This can be used to chain tests together so they are all finished exactly once .
function AnimationTest(pollFreq, timeout, referenceElementId, imageElementId,
                       debugElementId, cleanId, srcAttr, xulTest, closeFunc)
{
  clearImageCache();
  this.wereFailures = false;
  this.pollFreq = pollFreq;
  this.timeout = timeout;
  this.imageElementId = imageElementId;
  this.referenceElementId = referenceElementId;
  if (!document.getElementById(referenceElementId)) {
    this.reusingImageAsReference = true;
  }
  this.srcAttr = srcAttr;
  this.debugElementId = debugElementId;
  this.referenceSnapshot = ""; 
  this.pollCounter = 0;
  this.isTestFinished = false;
  this.numRefsTaken = 0;
  this.blankWaitTime = 0;
  this.cleanId = cleanId ? cleanId : '';
  this.xulTest = xulTest ? xulTest : '';
  this.closeFunc = closeFunc ? closeFunc : '';
}
function AnimationTest ( pollFreq , timeout , referenceElementId , imageElementId , debugElementId , cleanId , srcAttr , xulTest , closeFunc ) { clearImageCache ( ) ; this . wereFailures = false ; this . pollFreq = pollFreq ; this . timeout = timeout ; this . imageElementId = imageElementId ; this . referenceElementId = referenceElementId ; if ( ! document . getElementById ( referenceElementId ) ) { this . reusingImageAsReference = true ; } this . srcAttr = srcAttr ; this . debugElementId = debugElementId ; this . referenceSnapshot = "" ; this . pollCounter = 0 ; this . isTestFinished = false ; this . numRefsTaken = 0 ; this . blankWaitTime = 0 ; this . cleanId = cleanId ? cleanId : '' ; this . xulTest = xulTest ? xulTest : '' ; this . closeFunc = closeFunc ? closeFunc : '' ; }
Create a new AnimationTest object.
Create a new AnimationTest object .
// We want to test the cold loading behavior, so clear cache in case an // earlier test got our image in there already. // In this case, we're assuming the user passed in a string that // indicates the source of the image they want to change to, // after the reference image has been taken. // value will be set in takeReferenceSnapshot()