Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: chrome/test/chromedriver/js/call_function.js

Issue 217013005: Replace WebKitShadowRoot constructor with ShadowRoot constructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 * @const 25 * @const
26 * @type {string} 26 * @type {string}
27 */ 27 */
28 var ELEMENT_KEY = 'ELEMENT'; 28 var ELEMENT_KEY = 'ELEMENT';
29 29
30 /** 30 /**
31 * True if shadow dom is enabled. 31 * True if shadow dom is enabled.
32 * @const 32 * @const
33 * @type {boolean} 33 * @type {boolean}
34 */ 34 */
35 var SHADOW_DOM_ENABLED = typeof WebKitShadowRoot === 'function'; 35 var SHADOW_DOM_ENABLED = typeof ShadowRoot === 'function';
36 36
37 /** 37 /**
38 * A cache which maps IDs <-> cached objects for the purpose of identifying 38 * A cache which maps IDs <-> cached objects for the purpose of identifying
39 * a script object remotely. 39 * a script object remotely.
40 * @constructor 40 * @constructor
41 */ 41 */
42 function Cache() { 42 function Cache() {
43 this.cache_ = {}; 43 this.cache_ = {};
44 this.nextId_ = 1; 44 this.nextId_ = 1;
45 this.idPrefix_ = Math.random().toString(); 45 this.idPrefix_ = Math.random().toString();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
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 WebKitShadowRoot) 103 else if (SHADOW_DOM_ENABLED && nodeRoot instanceof ShadowRoot)
104 return true; 104 return true;
105 105
106 return false; 106 return false;
107 } 107 }
108 }; 108 };
109 109
110 /** 110 /**
111 * Returns the root element of the node. Found by traversing parentNodes until 111 * 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. 112 * 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. 113 * @param {!Node} node The node to find the root element for.
(...skipping 24 matching lines...) Expand all
138 * Wraps the given value to be transmitted remotely by converting 138 * Wraps the given value to be transmitted remotely by converting
139 * appropriate objects to cached object IDs. 139 * appropriate objects to cached object IDs.
140 * 140 *
141 * @param {*} value The value to wrap. 141 * @param {*} value The value to wrap.
142 * @return {*} The wrapped value. 142 * @return {*} The wrapped value.
143 */ 143 */
144 function wrap(value) { 144 function wrap(value) {
145 if (typeof(value) == 'object' && value != null) { 145 if (typeof(value) == 'object' && value != null) {
146 var nodeType = value['nodeType']; 146 var nodeType = value['nodeType'];
147 if (nodeType == NodeType.ELEMENT || nodeType == NodeType.DOCUMENT 147 if (nodeType == NodeType.ELEMENT || nodeType == NodeType.DOCUMENT
148 || (SHADOW_DOM_ENABLED && value instanceof WebKitShadowRoot)) { 148 || (SHADOW_DOM_ENABLED && value instanceof ShadowRoot)) {
149 var wrapped = {}; 149 var wrapped = {};
150 var root = getNodeRoot(value); 150 var root = getNodeRoot(value);
151 wrapped[ELEMENT_KEY] = getPageCache(root).storeItem(value); 151 wrapped[ELEMENT_KEY] = getPageCache(root).storeItem(value);
152 return wrapped; 152 return wrapped;
153 } 153 }
154 154
155 var obj = (typeof(value.length) == 'number') ? [] : {}; 155 var obj = (typeof(value.length) == 'number') ? [] : {};
156 for (var prop in value) 156 for (var prop in value)
157 obj[prop] = wrap(value[prop]); 157 obj[prop] = wrap(value[prop]);
158 return obj; 158 return obj;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 var returnValue = wrap(func.apply(null, unwrap(args, cache))); 222 var returnValue = wrap(func.apply(null, unwrap(args, cache)));
223 } catch (error) { 223 } catch (error) {
224 status = error.code || StatusCode.UNKNOWN_ERROR; 224 status = error.code || StatusCode.UNKNOWN_ERROR;
225 var returnValue = error.message; 225 var returnValue = error.message;
226 } 226 }
227 return { 227 return {
228 status: status, 228 status: status,
229 value: returnValue 229 value: returnValue
230 } 230 }
231 } 231 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698