| 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_next_e2e_test_base.js']); | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); |
| 7 | 7 |
| 8 GEN_INCLUDE(['../../testing/snippets.js']); | 8 GEN_INCLUDE(['../../testing/snippets.js']); |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Downward movement is forward. | 130 // Downward movement is forward. |
| 131 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(right, left)); | 131 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(right, left)); |
| 132 | 132 |
| 133 // Ordered. | 133 // Ordered. |
| 134 right = right.lastChild; | 134 right = right.lastChild; |
| 135 assertEquals(Dir.BACKWARD, AutomationUtil.getDirection(right, left)); | 135 assertEquals(Dir.BACKWARD, AutomationUtil.getDirection(right, left)); |
| 136 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); | 136 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); |
| 137 }); | 137 }); |
| 138 }); | 138 }); |
| 139 | 139 |
| 140 TEST_F('AutomationUtilE2ETest', 'IsInSameWebpage', function() { | |
| 141 this.runWithLoadedTree(this.basicDoc, function(root) { | |
| 142 this.runWithLoadedTree(this.secondDoc, function(root2) { | |
| 143 chrome.automation.getDesktop(this.newCallback(function(desktop) { | |
| 144 assertTrue(AutomationUtil.isInSameWebpage(root, root)); | |
| 145 assertTrue(AutomationUtil.isInSameWebpage(root.firstChild, root)); | |
| 146 assertTrue(AutomationUtil.isInSameWebpage(root, root.firstChild)); | |
| 147 | |
| 148 assertTrue(AutomationUtil.isInSameWebpage(root2, root2)); | |
| 149 assertTrue(AutomationUtil.isInSameWebpage(root2.firstChild, root2)); | |
| 150 assertTrue(AutomationUtil.isInSameWebpage(root2, root2.firstChild)); | |
| 151 | |
| 152 assertFalse(AutomationUtil.isInSameWebpage(root, root2)); | |
| 153 assertFalse(AutomationUtil.isInSameWebpage(root.firstChild, root2)); | |
| 154 assertFalse(AutomationUtil.isInSameWebpage(root2.firstChild)); | |
| 155 assertFalse(AutomationUtil.isInSameWebpage( | |
| 156 root.firstChild, root2.firstChild)); | |
| 157 | |
| 158 assertFalse(AutomationUtil.isInSameWebpage(root, desktop)); | |
| 159 assertFalse(AutomationUtil.isInSameWebpage(root2, desktop)); | |
| 160 }.bind(this))); | |
| 161 }.bind(this)); | |
| 162 }.bind(this)); | |
| 163 }); | |
| 164 | |
| 165 TEST_F('AutomationUtilE2ETest', 'IsInSameWebpageIframe', function() { | |
| 166 // Wait for load complete on both outer frame and iframe. | |
| 167 var outerFrame; | |
| 168 var innerFrame; | |
| 169 var desktop; | |
| 170 var onSuccess = this.newCallback(function() { | |
| 171 assertTrue(AutomationUtil.isInSameWebpage(outerFrame, innerFrame)); | |
| 172 assertFalse(AutomationUtil.isInSameWebpage(outerFrame, desktop)); | |
| 173 assertFalse(AutomationUtil.isInSameWebpage(innerFrame, desktop)); | |
| 174 assertFalse(AutomationUtil.isInSameWebpage(outerFrame.parent, innerFrame)); | |
| 175 }.bind(this)); | |
| 176 | |
| 177 chrome.automation.getDesktop(function(r) { | |
| 178 desktop = r; | |
| 179 this.runWithTab(this.iframeDoc, function(newTabUrl) { | |
| 180 var listener = function(evt) { | |
| 181 if (evt.target.docUrl == newTabUrl) | |
| 182 outerFrame = evt.target; | |
| 183 if (evt.target.docUrl.indexOf('data:text/html') == 0) | |
| 184 innerFrame = evt.target; | |
| 185 | |
| 186 if (outerFrame && innerFrame) { | |
| 187 desktop.removeEventListener('loadComplete', listener, true); | |
| 188 onSuccess(); | |
| 189 } | |
| 190 }.bind(this); | |
| 191 desktop.addEventListener('loadComplete', listener, true); | |
| 192 }.bind(this)); | |
| 193 }.bind(this)); | |
| 194 }); | |
| 195 | |
| 196 TEST_F('AutomationUtilE2ETest', 'VisitContainer', function() { | 140 TEST_F('AutomationUtilE2ETest', 'VisitContainer', function() { |
| 197 this.runWithLoadedTree(toolbarDoc, function(r) { | 141 this.runWithLoadedTree(toolbarDoc, function(r) { |
| 198 var pred = function(n) { return n.role != 'rootWebArea'; }; | 142 var pred = function(n) { return n.role != 'rootWebArea'; }; |
| 199 | 143 |
| 200 var toolbar = AutomationUtil.findNextNode(r, 'forward', pred); | 144 var toolbar = AutomationUtil.findNextNode(r, 'forward', pred); |
| 201 assertEquals('toolbar', toolbar.role); | 145 assertEquals('toolbar', toolbar.role); |
| 202 | 146 |
| 203 var back = AutomationUtil.findNextNode(toolbar, 'forward', pred); | 147 var back = AutomationUtil.findNextNode(toolbar, 'forward', pred); |
| 204 assertEquals('Back', back.name); | 148 assertEquals('Back', back.name); |
| 205 assertEquals(toolbar, | 149 assertEquals(toolbar, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 226 assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1.parent))); | 170 assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1.parent))); |
| 227 assertEquals(h1.parent.parent, | 171 assertEquals(h1.parent.parent, |
| 228 AutomationUtil.hitTest(r, getCP(h1.parent.parent))); | 172 AutomationUtil.hitTest(r, getCP(h1.parent.parent))); |
| 229 | 173 |
| 230 assertEquals(a, AutomationUtil.hitTest(r, getCP(a))); | 174 assertEquals(a, AutomationUtil.hitTest(r, getCP(a))); |
| 231 assertEquals(a, AutomationUtil.hitTest(r, getCP(a.parent))); | 175 assertEquals(a, AutomationUtil.hitTest(r, getCP(a.parent))); |
| 232 assertEquals(a.parent.parent, | 176 assertEquals(a.parent.parent, |
| 233 AutomationUtil.hitTest(r, getCP(a.parent.parent))); | 177 AutomationUtil.hitTest(r, getCP(a.parent.parent))); |
| 234 }); | 178 }); |
| 235 }); | 179 }); |
| OLD | NEW |