Skip to content
Browse files

Pass iframe support tests at doc ready. Fixes support fail in FF7

  • Loading branch information...
1 parent 0752687 commit 006fde228da59ae71c11a67ef65dbfc09e788773 @timmywil timmywil committed Oct 31, 2011
Showing with 8 additions and 4 deletions.
  1. +3 −1 test/data/support/bodyBackground.html
  2. +5 −3 test/unit/support.js
View
4 test/data/support/bodyBackground.html
@@ -32,7 +32,9 @@
<script src="../../../src/dimensions.js"></script>
</div>
<script>
- window.parent.supportCallback( jQuery( "body" ).css( "backgroundColor" ), jQuery.support );
+ jQuery(function() {
+ window.parent.supportCallback( jQuery( "body" ).css( "backgroundColor" ), jQuery.support );
+ });
</script>
</body>
</html>
View
8 test/unit/support.js
@@ -33,12 +33,14 @@ supportIFrameTest( "proper boxModel in compatMode CSS1Compat (IE6 and IE7)", "bo
supportIFrameTest( "body background is not lost if set prior to loading jQuery (#9238)", "bodyBackground", function( color, support ) {
expect( 2 );
- var okValue = {
+ var i,
+ passed = true,
+ okValue = {
"#000000": true,
"rgb(0, 0, 0)": true
- };
+ };
ok( okValue[ color ], "color was not reset (" + color + ")" );
- var i, passed = true;
+
for ( i in jQuery.support ) {
if ( jQuery.support[ i ] !== support[ i ] ) {
passed = false;

1 comment on commit 006fde2

@mikesherov
jQuery Foundation member

So, I actually sorta figured out why FF7 complains and Chrome doesn't, and Opera does sometimes before this change.

It seems as if Firefox lets 2 windows run javascript independent of each other (as expected?). By the time the window.supportCallback actually runs in FF7, there is no gaurantee the support tests ran in the IFRAME yet. If you change the setTimeout in supportIFrameTest to something like 100 instead of 0, FF complains a lot less often. It's a race.

It seems as if it's the same situation in Opera, however Opera seems like the document.ready on the iframe fires early enough to never complain. It's still a race, but the IFRAME always wins. If you want the IFRAME to lose, just put an alert('hi!'); after window.parent.supportCallback( jQuery( "body" ).css( "backgroundColor" ), jQuery.support ); and you'll see that the IFRAME now loses because the alert stops execution on that IFRAME.

For Chrome, different story. It seems as if Chrome finishes executing all the code in the IFRAME (including doc ready ?) before executing the callback on the parent window. To demonstrate, go ahead and and put that same alert in. If you notice, if you close the alert after 4 seconds, it's four more seconds before the test finishing running. It's as if the alert stops JS execution on both windows!

Weird.

Please sign in to comment.
Something went wrong with that request. Please try again.