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, $.browser.msie ? 6 : 7, "$('#relative-1').offset().top" );
45 equals( $w('#relative-1').offset().left, 7, "$('#relative-1').offset().left" );
47 equals( $w('#relative-1-1').offset().top, $.browser.msie ? 13 : 15, "$('#relative-1-1').offset().top" );
48 equals( $w('#relative-1-1').offset().left, 15, "$('#relative-1-1').offset().left" );
50 equals( $w('#relative-2').offset().top, $.browser.msie ? 141 : 142, "$('#relative-2').offset().top" );
51 equals( $w('#relative-2').offset().left, 27, "$('#relative-2').offset().left" );
53 testwin["relative"].close();
56 testwin("static", function() {
57 var $w = testwin["static"].$;
59 equals( $w('#static-1').offset().top, $.browser.msie ? 6 : 7, "$('#static-1').offset().top" );
60 equals( $w('#static-1').offset().left, 7, "$('#static-1').offset().left" );
62 equals( $w('#static-1-1').offset().top, $.browser.msie ? 13 : 15, "$('#static-1-1').offset().top" );
63 equals( $w('#static-1-1').offset().left, 15, "$('#static-1-1').offset().left" );
65 equals( $w('#static-1-1-1').offset().top, $.browser.msie ? 20 : 23, "$('#static-1-1-1').offset().top" );
66 equals( $w('#static-1-1-1').offset().left, 23, "$('#static-1-1-1').offset().left" );
68 equals( $w('#static-2').offset().top, $.browser.msie ? 121 : 122, "$('#static-2').offset().top" );
69 equals( $w('#static-2').offset().left, 7, "$('#static-2').offset().left" );
71 testwin["static"].close();
74 if ( !$.browser.msie || ($.browser.msie && parseInt($.browser.version) > 6) )
75 testwin("fixed", function() {
76 var $w = testwin["fixed"].$;
78 equals( $w('#fixed-1').offset().top, 1001, "$('#fixed-1').offset().top" );
79 equals( $w('#fixed-1').offset().left, $.browser.msie ? 994 : 1001, "$('#fixed-1').offset().left" );
81 equals( $w('#fixed-2').offset().top, 1021, "$('#fixed-2').offset().top" );
82 equals( $w('#fixed-2').offset().left, $.browser.msie ? 1014 : 1021, "$('#fixed-2').offset().left" );
84 testwin["fixed"].close();
87 testwin("table", function() {
88 var $w = testwin["table"].$;
90 equals( $w('#table-1').offset().top, 6, "$('#table-1').offset().top" );
91 equals( $w('#table-1').offset().left, 6, "$('#table-1').offset().left" );
93 equals( $w('#th-1').offset().top, 10, "$('#table-1').offset().top" );
94 equals( $w('#th-1').offset().left, 10, "$('#table-1').offset().left" );
96 equals( $w('#th-2').offset().top, 10, "$('#table-1').offset().top" );
97 equals( $w('#th-2').offset().left, 116, "$('#table-1').offset().left" );
99 testwin["table"].close();
102 testwin("scroll", function() {
103 var $w = testwin["scroll"].$;
105 equals( $w('#scroll-1').offset().top, $.browser.msie ? 6 : 7, "$('#scroll-1').offset().top" );
106 equals( $w('#scroll-1').offset().left, 7, "$('#scroll-1').offset().left" );
108 equals( $w('#scroll-1-1').offset().top, $.browser.msie ? 9 : 11, "$('#scroll-1-1').offset().top" );
109 equals( $w('#scroll-1-1').offset().left, 11, "$('#scroll-1-1').offset().left" );
111 testwin["scroll"].close();