summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/prototype/test/unit/position_test.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/tests/mochitest/ajax/prototype/test/unit/position_test.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--dom/tests/mochitest/ajax/prototype/test/unit/position_test.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/dom/tests/mochitest/ajax/prototype/test/unit/position_test.js b/dom/tests/mochitest/ajax/prototype/test/unit/position_test.js
new file mode 100644
index 0000000000..5cea791b1f
--- /dev/null
+++ b/dom/tests/mochitest/ajax/prototype/test/unit/position_test.js
@@ -0,0 +1,44 @@
+var testVar = 'to be updated';
+
+new Test.Unit.Runner({
+
+ setup: function() {
+ scrollTo(0,0);
+ Position.prepare();
+ Position.includeScrollOffsets = false;
+ },
+
+ teardown: function() {
+ scrollTo(0,0);
+ Position.prepare();
+ Position.includeScrollOffsets = false;
+ },
+
+ testPrepare: function() {
+ Position.prepare();
+ this.assertEqual(0, Position.deltaX);
+ this.assertEqual(0, Position.deltaY);
+ scrollTo(20,30);
+ Position.prepare();
+ this.assertEqual(20, Position.deltaX);
+ this.assertEqual(30, Position.deltaY);
+ },
+
+ testWithin: function() {
+ [true, false].each(function(withScrollOffsets) {
+ Position.includeScrollOffsets = withScrollOffsets;
+ this.assert(!Position.within($('body_absolute'), 9, 9), 'outside left/top');
+ this.assert(Position.within($('body_absolute'), 10, 10), 'left/top corner');
+ this.assert(Position.within($('body_absolute'), 10, 19), 'left/bottom corner');
+ this.assert(!Position.within($('body_absolute'), 10, 20), 'outside bottom');
+ }, this);
+
+ scrollTo(20,30);
+ Position.prepare();
+ Position.includeScrollOffsets = true;
+ this.assert(!Position.within($('body_absolute'), 9, 9), 'outside left/top');
+ this.assert(Position.within($('body_absolute'), 10, 10), 'left/top corner');
+ this.assert(Position.within($('body_absolute'), 10, 19), 'left/bottom corner');
+ this.assert(!Position.within($('body_absolute'), 10, 20), 'outside bottom');
+ }
+}); \ No newline at end of file