3 // opens a new window to run the tests against
4 var testwin = function(name, fn) {
5 testwin[name] = load_offset_fixture(name);
6 var interval = setInterval(function() {
7 if (testwin[name] && testwin[name].$ && testwin[name].$.isReady) {
8 clearInterval(interval);
13 function load_offset_fixture(name) {
14 var win = window.open( "./data/offset/" + name + ".html?num"+parseInt(Math.random()*1000), name, 'left=0,top=0,width=500,height=500,toolbar=1,resizable=0' );
16 alert("Please disable your popup blocker for the offset test suite");
17 throw "Please disable your popup blocker for the offset test suite";
23 testwin("absolute", function() {
24 var $w = testwin["absolute"].$;
26 equals( $w('#absolute-1').offset().top, 1, "$('#absolute-1').offset().top" );
27 equals( $w('#absolute-1').offset().left, 1, "$('#absolute-1').offset().left" );
29 equals( $w('#absolute-1-1').offset().top, 5, "$('#absolute-1-1').offset().top" );
30 equals( $w('#absolute-1-1').offset().left, 5, "$('#absolute-1-1').offset().left" );
32 equals( $w('#absolute-1-1-1').offset().top, 9, "$('#absolute-1-1-1').offset().top" );
33 equals( $w('#absolute-1-1-1').offset().left, 9, "$('#absolute-1-1-1').offset().left" );
35 equals( $w('#absolute-2').offset().top, 20, "$('#absolute-2').offset().top" );
36 equals( $w('#absolute-2').offset().left, 20, "$('#absolute-2').offset().left" );
38 testwin["absolute"].close();
41 testwin("relative", function() {
42 var $w = testwin["relative"].$;
44 equals( $w('#relative-1').offset().top, jQuery.browser.msie ? 6 : 7, "$('#relative-1').offset().top" );
45 equals( $w('#relative-1').offset().left, 7, "$('#relative-1').offset().left" );
47 equals( $w('#relative-2').offset().top, jQuery.browser.msie ? 141 : 142, "$('#relative-2').offset().top" );
48 equals( $w('#relative-2').offset().left, 27, "$('#relative-2').offset().left" );
50 testwin["relative"].close();