OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * Enum for WebDriver status codes. | 6 * Enum for WebDriver status codes. |
7 * @enum {number} | 7 * @enum {number} |
8 */ | 8 */ |
9 var StatusCode = { | 9 var StatusCode = { |
10 STALE_ELEMENT_REFERENCE: 10, | 10 STALE_ELEMENT_REFERENCE: 10, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 /** | 94 /** |
95 * @private | 95 * @private |
96 * @param {!Node} node The node to check. | 96 * @param {!Node} node The node to check. |
97 * @return {boolean} If the nodes is reachable. | 97 * @return {boolean} If the nodes is reachable. |
98 */ | 98 */ |
99 isNodeReachable_: function(node) { | 99 isNodeReachable_: function(node) { |
100 var nodeRoot = getNodeRoot(node); | 100 var nodeRoot = getNodeRoot(node); |
101 if (nodeRoot == document) | 101 if (nodeRoot == document) |
102 return true; | 102 return true; |
103 else if (SHADOW_DOM_ENABLED && nodeRoot instanceof ShadowRoot) | 103 else if (SHADOW_DOM_ENABLED && nodeRoot instanceof ShadowRoot) |
104 return true; | 104 return this.isNodeReachable_(nodeRoot.host); |
105 | |
106 return false; | 105 return false; |
107 } | 106 } |
108 }; | 107 }; |
109 | 108 |
110 /** | 109 /** |
111 * Returns the root element of the node. Found by traversing parentNodes until | 110 * Returns the root element of the node. Found by traversing parentNodes until |
112 * a node with no parent is found. This node is considered the root. | 111 * a node with no parent is found. This node is considered the root. |
113 * @param {!Node} node The node to find the root element for. | 112 * @param {!Node} node The node to find the root element for. |
114 * @return {!Node} The root node. | 113 * @return {!Node} The root node. |
115 */ | 114 */ |
(...skipping 25 matching lines...) Expand all Loading... |
141 * @param {*} value The value to wrap. | 140 * @param {*} value The value to wrap. |
142 * @return {*} The wrapped value. | 141 * @return {*} The wrapped value. |
143 */ | 142 */ |
144 function wrap(value) { | 143 function wrap(value) { |
145 if (typeof(value) == 'object' && value != null) { | 144 if (typeof(value) == 'object' && value != null) { |
146 var nodeType = value['nodeType']; | 145 var nodeType = value['nodeType']; |
147 if (nodeType == NodeType.ELEMENT || nodeType == NodeType.DOCUMENT | 146 if (nodeType == NodeType.ELEMENT || nodeType == NodeType.DOCUMENT |
148 || (SHADOW_DOM_ENABLED && value instanceof ShadowRoot)) { | 147 || (SHADOW_DOM_ENABLED && value instanceof ShadowRoot)) { |
149 var wrapped = {}; | 148 var wrapped = {}; |
150 var root = getNodeRoot(value); | 149 var root = getNodeRoot(value); |
151 wrapped[ELEMENT_KEY] = getPageCache(root).storeItem(value); | 150 wrapped[ELEMENT_KEY] = getPageCache().storeItem(value); |
152 return wrapped; | 151 return wrapped; |
153 } | 152 } |
154 | 153 |
155 var obj = (typeof(value.length) == 'number') ? [] : {}; | 154 var obj = (typeof(value.length) == 'number') ? [] : {}; |
156 for (var prop in value) | 155 for (var prop in value) |
157 obj[prop] = wrap(value[prop]); | 156 obj[prop] = wrap(value[prop]); |
158 return obj; | 157 return obj; |
159 } | 158 } |
160 return value; | 159 return value; |
161 } | 160 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 var returnValue = wrap(func.apply(null, unwrap(args, cache))); | 221 var returnValue = wrap(func.apply(null, unwrap(args, cache))); |
223 } catch (error) { | 222 } catch (error) { |
224 status = error.code || StatusCode.UNKNOWN_ERROR; | 223 status = error.code || StatusCode.UNKNOWN_ERROR; |
225 var returnValue = error.message; | 224 var returnValue = error.message; |
226 } | 225 } |
227 return { | 226 return { |
228 status: status, | 227 status: status, |
229 value: returnValue | 228 value: returnValue |
230 } | 229 } |
231 } | 230 } |
OLD | NEW |