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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 | 190 |
191 /** | 191 /** |
192 * Calls a given function and returns its value. | 192 * Calls a given function and returns its value. |
193 * | 193 * |
194 * The inputs to and outputs of the function will be unwrapped and wrapped | 194 * The inputs to and outputs of the function will be unwrapped and wrapped |
195 * respectively, unless otherwise specified. This wrapping involves converting | 195 * respectively, unless otherwise specified. This wrapping involves converting |
196 * between cached object reference IDs and actual JS objects. The cache will | 196 * between cached object reference IDs and actual JS objects. The cache will |
197 * automatically be pruned each call to remove stale references. | 197 * automatically be pruned each call to remove stale references. |
198 * | 198 * |
199 * @param {Array.<string>} shadowHostIds The host ids of the nested shadow | 199 * @param {Array<string>} shadowHostIds The host ids of the nested shadow |
200 * DOMs the function should be executed in the context of. | 200 * DOMs the function should be executed in the context of. |
201 * @param {function(...[*]) : *} func The function to invoke. | 201 * @param {function(...[*]) : *} func The function to invoke. |
202 * @param {!Array.<*>} args The array of arguments to supply to the function, | 202 * @param {!Array<*>} args The array of arguments to supply to the function, |
203 * which will be unwrapped before invoking the function. | 203 * which will be unwrapped before invoking the function. |
204 * @param {boolean=} opt_unwrappedReturn Whether the function's return value | 204 * @param {boolean=} opt_unwrappedReturn Whether the function's return value |
205 * should be left unwrapped. | 205 * should be left unwrapped. |
206 * @return {*} An object containing a status and value property, where status | 206 * @return {*} An object containing a status and value property, where status |
207 * is a WebDriver status code and value is the wrapped value. If an | 207 * is a WebDriver status code and value is the wrapped value. If an |
208 * unwrapped return was specified, this will be the function's pure return | 208 * unwrapped return was specified, this will be the function's pure return |
209 * value. | 209 * value. |
210 */ | 210 */ |
211 function callFunction(shadowHostIds, func, args, opt_unwrappedReturn) { | 211 function callFunction(shadowHostIds, func, args, opt_unwrappedReturn) { |
212 var cache = getPageCache(); | 212 var cache = getPageCache(); |
(...skipping 16 matching lines...) Expand all Loading... |
229 var returnValue = wrap(func.apply(null, unwrap(args, cache))); | 229 var returnValue = wrap(func.apply(null, unwrap(args, cache))); |
230 } catch (error) { | 230 } catch (error) { |
231 status = error.code || StatusCode.UNKNOWN_ERROR; | 231 status = error.code || StatusCode.UNKNOWN_ERROR; |
232 var returnValue = error.message; | 232 var returnValue = error.message; |
233 } | 233 } |
234 return { | 234 return { |
235 status: status, | 235 status: status, |
236 value: returnValue | 236 value: returnValue |
237 } | 237 } |
238 } | 238 } |
OLD | NEW |