From f576ceeea9eea5fec6b31172765df4da8b264ac8 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Tue, 4 Dec 2007 20:51:16 +0000 Subject: [PATCH] Beginnings of the offset test suite --- test/data/offset/absolute.html | 26 +++++++++++++++++ test/data/offset/relative.html | 32 +++++++++++++++++++++ test/offset.html | 27 ++++++++++++++++++ test/unit/offset.js | 51 ++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 test/data/offset/absolute.html create mode 100644 test/data/offset/relative.html create mode 100644 test/offset.html create mode 100644 test/unit/offset.js diff --git a/test/data/offset/absolute.html b/test/data/offset/absolute.html new file mode 100644 index 000000000..5b8b7edb2 --- /dev/null +++ b/test/data/offset/absolute.html @@ -0,0 +1,26 @@ + + + + + absolute + + + + + +
absolute-1 +
absolute-1-1 +
absolute-1-1-1
+
+
+
absolute-2
+ + \ No newline at end of file diff --git a/test/data/offset/relative.html b/test/data/offset/relative.html new file mode 100644 index 000000000..dc78976b9 --- /dev/null +++ b/test/data/offset/relative.html @@ -0,0 +1,32 @@ + + + + + relative + + + + + +
relative-1 +
relative-1-1 +
relative-1-1-1
+
+
+
relative-2
+
+ + \ No newline at end of file diff --git a/test/offset.html b/test/offset.html new file mode 100644 index 000000000..f802dea34 --- /dev/null +++ b/test/offset.html @@ -0,0 +1,27 @@ + + + + + jQuery Offset Test Suite + + + + + + + +

jQuery Offset Test Suite

+ +

+ + +
+ + +
    + + 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 -- 2.39.5