aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authormrmr19932015-04-28 04:03:53 +0100
committermrmr19932015-04-28 04:11:49 +0100
commit99ffe60fe28e015f379b697ef2499ecb2faeb958 (patch)
tree2d87c8847193facef9f51177d715ea6275bf66ec /tests
parent1b1e12df7157510bc375ad97fb65e2582fb7be4c (diff)
downloadvimium-99ffe60fe28e015f379b697ef2499ecb2faeb958.tar.bz2
Make DomUtils.getVisibleClientRects default to expected behaviour
This requires passing of an extra truthy argument in order to access the (generally) unexpected behaviour of sometimes returning the rects of child elements. All locations in the code that *actually* wanted this behaviour have been updated to continue using it. Also add a comment about the unexpected behaviour in the function description.
Diffstat (limited to 'tests')
-rw-r--r--tests/dom_tests/dom_utils_test.coffee28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/dom_tests/dom_utils_test.coffee b/tests/dom_tests/dom_utils_test.coffee
index ad8bde3c..e98dc958 100644
--- a/tests/dom_tests/dom_utils_test.coffee
+++ b/tests/dom_tests/dom_utils_test.coffee
@@ -4,19 +4,19 @@ context "Check visibility",
document.getElementById("test-div").innerHTML = """
<div id='foo'>test</div>
"""
- assert.isTrue (DomUtils.getVisibleClientRect document.getElementById 'foo') != null
+ assert.isTrue (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true) != null
should "detect display:none links as hidden", ->
document.getElementById("test-div").innerHTML = """
<a id='foo' style='display:none'>test</a>
"""
- assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'foo'
+ assert.equal null, (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true)
should "detect visibility:hidden links as hidden", ->
document.getElementById("test-div").innerHTML = """
<a id='foo' style='visibility:hidden'>test</a>
"""
- assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'foo'
+ assert.equal null, (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true)
should "detect elements nested in display:none elements as hidden", ->
document.getElementById("test-div").innerHTML = """
@@ -24,7 +24,7 @@ context "Check visibility",
<a id='foo'>test</a>
</div>
"""
- assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'foo'
+ assert.equal null, (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true)
should "detect links nested in visibility:hidden elements as hidden", ->
document.getElementById("test-div").innerHTML = """
@@ -32,23 +32,23 @@ context "Check visibility",
<a id='foo'>test</a>
</div>
"""
- assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'foo'
+ assert.equal null, (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true)
should "detect links outside viewport as hidden", ->
document.getElementById("test-div").innerHTML = """
<a id='foo' style='position:absolute;top:-2000px'>test</a>
<a id='bar' style='position:absolute;left:2000px'>test</a>
"""
- assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'foo'
- assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'bar'
+ assert.equal null, (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true)
+ assert.equal null, (DomUtils.getVisibleClientRect (document.getElementById 'bar'), true)
should "detect links only partially outside viewport as visible", ->
document.getElementById("test-div").innerHTML = """
<a id='foo' style='position:absolute;top:-10px'>test</a>
<a id='bar' style='position:absolute;left:-10px'>test</a>
"""
- assert.isTrue (DomUtils.getVisibleClientRect document.getElementById 'foo') != null
- assert.isTrue (DomUtils.getVisibleClientRect document.getElementById 'bar') != null
+ assert.isTrue (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true) != null
+ assert.isTrue (DomUtils.getVisibleClientRect (document.getElementById 'bar'), true) != null
should "detect links that contain only floated / absolutely-positioned divs as visible", ->
document.getElementById("test-div").innerHTML = """
@@ -56,14 +56,14 @@ context "Check visibility",
<div style='float:left'>test</div>
</a>
"""
- assert.isTrue (DomUtils.getVisibleClientRect document.getElementById 'foo') != null
+ assert.isTrue (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true) != null
document.getElementById("test-div").innerHTML = """
<a id='foo'>
<div style='position:absolute;top:0;left:0'>test</div>
</a>
"""
- assert.isTrue (DomUtils.getVisibleClientRect document.getElementById 'foo') != null
+ assert.isTrue (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true) != null
should "detect links that contain only invisible floated divs as invisible", ->
document.getElementById("test-div").innerHTML = """
@@ -71,7 +71,7 @@ context "Check visibility",
<div style='float:left;visibility:hidden'>test</div>
</a>
"""
- assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'foo'
+ assert.equal null, (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true)
should "detect links inside opacity:0 elements as visible", ->
# XXX This is an expected failure. See issue #16.
@@ -80,7 +80,7 @@ context "Check visibility",
<a id='foo'>test</a>
</div>
"""
- assert.isTrue (DomUtils.getVisibleClientRect document.getElementById 'foo') != null
+ assert.isTrue (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true) != null
should "Detect links within SVGs as visible", ->
# XXX this is an expected failure
@@ -91,4 +91,4 @@ context "Check visibility",
</a>
</svg>
"""
- assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'foo'
+ assert.equal null, (DomUtils.getVisibleClientRect (document.getElementById 'foo'), true)