| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Include test fixture. | 5 // Include test fixture. |
| 6 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']); | 6 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']); |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Test fixture. | 9 * Test fixture. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 node = $('nested_display_block'); | 134 node = $('nested_display_block'); |
| 135 assertEquals(false, cvox.DomUtil.isVisible(node)); | 135 assertEquals(false, cvox.DomUtil.isVisible(node)); |
| 136 | 136 |
| 137 // Options tests (for performance). | 137 // Options tests (for performance). |
| 138 node = $('nested_display_block'); | 138 node = $('nested_display_block'); |
| 139 assertEquals(true, | 139 assertEquals(true, |
| 140 cvox.DomUtil.isVisible(node, {checkAncestors: false})); | 140 cvox.DomUtil.isVisible(node, {checkAncestors: false})); |
| 141 node = $('nested_visibility_hide'); | 141 node = $('nested_visibility_hide'); |
| 142 assertEquals(false, | 142 assertEquals(false, |
| 143 cvox.DomUtil.isVisible(node, {checkDescendants: false})); | 143 cvox.DomUtil.isVisible(node, {checkDescendants: false})); |
| 144 |
| 145 // Test that an element not part of the DOM is treated as invisible. |
| 146 var div = document.createElement('div'); |
| 147 assertEquals(false, cvox.DomUtil.isVisible(div)); |
| 148 document.body.appendChild(div); |
| 149 assertEquals(true, cvox.DomUtil.isVisible(div)); |
| 144 }); | 150 }); |
| 145 | 151 |
| 146 /** Test determining if a node is a leaf node or not. @export */ | 152 /** Test determining if a node is a leaf node or not. @export */ |
| 147 TEST_F('CvoxDomUtilUnitTest', 'IsLeafNode', function() { | 153 TEST_F('CvoxDomUtilUnitTest', 'IsLeafNode', function() { |
| 148 this.loadDomUtilTestDoc_(); | 154 this.loadDomUtilTestDoc_(); |
| 149 | 155 |
| 150 var node = $('normal_node'); | 156 var node = $('normal_node'); |
| 151 assertEquals(false, cvox.DomUtil.isLeafNode(node)); | 157 assertEquals(false, cvox.DomUtil.isLeafNode(node)); |
| 152 node = $('display_none'); | 158 node = $('display_none'); |
| 153 assertEquals(true, cvox.DomUtil.isLeafNode(node)); | 159 assertEquals(true, cvox.DomUtil.isLeafNode(node)); |
| (...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 cvox.Memoize.scope(function() { | 1569 cvox.Memoize.scope(function() { |
| 1564 container.style.visibility = 'hidden'; | 1570 container.style.visibility = 'hidden'; |
| 1565 assertFalse(cvox.DomUtil.isVisible(target)); | 1571 assertFalse(cvox.DomUtil.isVisible(target)); |
| 1566 | 1572 |
| 1567 container.style.visibility = 'visible'; | 1573 container.style.visibility = 'visible'; |
| 1568 // This should be true! It will return the wrong answer because | 1574 // This should be true! It will return the wrong answer because |
| 1569 // we're deliberately leaving memoization on while modifying the DOM. | 1575 // we're deliberately leaving memoization on while modifying the DOM. |
| 1570 assertFalse(cvox.DomUtil.isVisible(target)); | 1576 assertFalse(cvox.DomUtil.isVisible(target)); |
| 1571 }); | 1577 }); |
| 1572 }); | 1578 }); |
| OLD | NEW |