diff options
author | Brandon Aaron <brandon.aaron@gmail.com> | 2007-12-04 20:51:16 +0000 |
---|---|---|
committer | Brandon Aaron <brandon.aaron@gmail.com> | 2007-12-04 20:51:16 +0000 |
commit | f576ceeea9eea5fec6b31172765df4da8b264ac8 (patch) | |
tree | e4c64e421cc0cdad6d6a9e8b501a6d45507ee2fe /test/unit/offset.js | |
parent | 76e3a901530609d3c4a695ccb8a48251445c6861 (diff) | |
download | jquery-f576ceeea9eea5fec6b31172765df4da8b264ac8.tar.gz jquery-f576ceeea9eea5fec6b31172765df4da8b264ac8.zip |
Beginnings of the offset test suite
Diffstat (limited to 'test/unit/offset.js')
-rw-r--r-- | test/unit/offset.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/unit/offset.js b/test/unit/offset.js new file mode 100644 index 000000000..835df89e3 --- /dev/null +++ b/test/unit/offset.js @@ -0,0 +1,51 @@ +module("offset"); + +// opens a new window to run the tests against +var testwin = function(name, fn) { + testwin[name] = load_offset_fixture(name); + var interval = setInterval(function() { + if (testwin[name] && testwin[name].$ && testwin[name].$.isReady) { + clearInterval(interval); + test(name, fn); + } + }, 0); + + function load_offset_fixture(name) { + 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' ); + if ( !win ) { + alert("Please disable your popup blocker for the offset test suite"); + throw "Please disable your popup blocker for the offset test suite"; + } + return win; + } +}; + +testwin("absolute", function() { + var $w = testwin["absolute"].$; + + equals( $w('#absolute-1').offset().top, 1, "$('#absolute-1').offset().top" ); + equals( $w('#absolute-1').offset().left, 1, "$('#absolute-1').offset().left" ); + + equals( $w('#absolute-1-1').offset().top, 5, "$('#absolute-1-1').offset().top" ); + equals( $w('#absolute-1-1').offset().left, 5, "$('#absolute-1-1').offset().left" ); + + equals( $w('#absolute-1-1-1').offset().top, 9, "$('#absolute-1-1-1').offset().top" ); + equals( $w('#absolute-1-1-1').offset().left, 9, "$('#absolute-1-1-1').offset().left" ); + + equals( $w('#absolute-2').offset().top, 20, "$('#absolute-2').offset().top" ); + equals( $w('#absolute-2').offset().left, 20, "$('#absolute-2').offset().left" ); + + testwin["absolute"].close(); +}); + +testwin("relative", function() { + var $w = testwin["relative"].$; + + equals( $w('#relative-1').offset().top, jQuery.browser.msie ? 6 : 7, "$('#relative-1').offset().top" ); + equals( $w('#relative-1').offset().left, 7, "$('#relative-1').offset().left" ); + + equals( $w('#relative-2').offset().top, jQuery.browser.msie ? 141 : 142, "$('#relative-2').offset().top" ); + equals( $w('#relative-2').offset().left, 27, "$('#relative-2').offset().left" ); + + testwin["relative"].close(); +});
\ No newline at end of file |