function assertStyleAsync( assert, $element, prop, val, fn ) {
		var styleTestStart,
			el = $element.get( 0 ),
			styleTestTimeout = ( QUnit.config.testTimeout || 5000 ) - 200;

		function isCssImportApplied() {
			// Trigger reflow, repaint, redraw, whatever (cross-browser)
			$element.css( 'height' );
			// eslint-disable-next-line no-unused-expressions
			el.innerHTML;
			el.className = el.className;
			// eslint-disable-next-line no-unused-expressions
			document.documentElement.clientHeight;

			return $element.css( prop ) === val;
		}

		function styleTestLoop() {
			var styleTestSince = new Date().getTime() - styleTestStart;
			// If it is passing or if we timed out, run the real test and stop the loop
			if ( isCssImportApplied() || styleTestSince > styleTestTimeout ) {
				assert.equal( $element.css( prop ), val,
					'style "' + prop + ': ' + val + '" from url is applied (after ' + styleTestSince + 'ms)'
				);

				if ( fn ) {
					fn();
				}

				return;
			}
			// Otherwise, keep polling
			setTimeout( styleTestLoop );
		}

		// Start the loop
		styleTestStart = new Date().getTime();
		styleTestLoop();
	}
/**
	 * The sync style load test (for @import). This is, in a way, also an open bug for
	 * ResourceLoader ("execute js after styles are loaded"), but browsers don't offer a
	 * way to get a callback from when a stylesheet is loaded (that is, including any
	 * `@import` rules inside). To work around this, we'll have a little time loop to check
	 * if the styles apply.
	 *
	 * Note: This test originally used new Image() and onerror to get a callback
	 * when the url is loaded, but that is fragile since it doesn't monitor the
	 * same request as the css @import, and Safari 4 has issues with
	 * onerror/onload not being fired at all in weird cases like this.
	 */
The sync style load test (for @import). This is, in a way, also an open bug for
ResourceLoader ("execute js after styles are loaded"), but browsers don't offer a
way to get a callback from when a stylesheet is loaded (that is, including any
`@import` rules inside). To work around this, we'll have a little time loop to check
if the styles apply.

This test originally used new Image() and onerror to get a callback
when the url is loaded, but that is fragile since it doesn't monitor the
same request as the css @import, and Safari 4 has issues with
onerror/onload not being fired at all in weird cases like this.
The sync style load test ( for @import ) . This is in a way also an open bug for ResourceLoader ( " execute js after styles are loaded " ) but browsers don ' t offer a way to get a callback from when a stylesheet is loaded ( that is including any ` @import ` rules inside ) . To work around this we ' ll have a little time loop to check if the styles apply . This test originally used new Image () and onerror to get a callback when the url is loaded but that is fragile since it doesn ' t monitor the same request as the css @import and Safari 4 has issues with onerror / onload not being fired at all in weird cases like this .
function assertStyleAsync( assert, $element, prop, val, fn ) {
		var styleTestStart,
			el = $element.get( 0 ),
			styleTestTimeout = ( QUnit.config.testTimeout || 5000 ) - 200;
		function isCssImportApplied() {
			$element.css( 'height' );
			el.innerHTML;
			el.className = el.className;
			document.documentElement.clientHeight;
			return $element.css( prop ) === val;
		}
		function styleTestLoop() {
			var styleTestSince = new Date().getTime() - styleTestStart;
			if ( isCssImportApplied() || styleTestSince > styleTestTimeout ) {
				assert.equal( $element.css( prop ), val,
					'style "' + prop + ': ' + val + '" from url is applied (after ' + styleTestSince + 'ms)'
				);
				if ( fn ) {
					fn();
				}
				return;
			}
			setTimeout( styleTestLoop );
		}
		styleTestStart = new Date().getTime();
		styleTestLoop();
	}
function assertStyleAsync ( assert , $element , prop , val , fn ) { var styleTestStart , el = $element . get ( 0 ) , styleTestTimeout = ( QUnit . config . testTimeout || 5000 ) - 200 ; function isCssImportApplied ( ) { $element . css ( 'height' ) ; el . innerHTML ; el . className = el . className ; document . documentElement . clientHeight ; return $element . css ( prop ) === val ; } function styleTestLoop ( ) { var styleTestSince = new Date ( ) . getTime ( ) - styleTestStart ; if ( isCssImportApplied ( ) || styleTestSince > styleTestTimeout ) { assert . equal ( $element . css ( prop ) , val , 'style "' + prop + ': ' + val + '" from url is applied (after ' + styleTestSince + 'ms)' ) ; if ( fn ) { fn ( ) ; } return ; } setTimeout ( styleTestLoop ) ; } styleTestStart = new Date ( ) . getTime ( ) ; styleTestLoop ( ) ; }
The sync style load test (for @import).
The sync style load test ( for @import ) .
// Trigger reflow, repaint, redraw, whatever (cross-browser) // eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions // If it is passing or if we timed out, run the real test and stop the loop // Otherwise, keep polling // Start the loop