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

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

Issue 11884058: [chromedriver] Implement commands: findChildElement, findChildElements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 11 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 * Stores a given item in the cache and returns a unique ID. 43 * Stores a given item in the cache and returns a unique ID.
44 * 44 *
45 * @param {!Object} item The item to store in the cache. 45 * @param {!Object} item The item to store in the cache.
46 * @return {number} The ID for the cached item. 46 * @return {number} The ID for the cached item.
47 */ 47 */
48 storeItem_: function(item) { 48 storeItem_: function(item) {
49 for (var i in this.cache_) { 49 for (var i in this.cache_) {
50 if (item == this.cache_[i]) 50 if (item == this.cache_[i])
51 return i; 51 return i;
52 } 52 }
53 this.cache_[this.nextId_] = item; 53 var id = this.nextId_.toString();
54 return this.nextId_++; 54 this.cache_[id] = item;
55 this.nextId_++;
56 return id;
55 }, 57 },
56 58
57 /** 59 /**
58 * Retrieves the cached object for the given ID. 60 * Retrieves the cached object for the given ID.
59 * 61 *
60 * @param {number} id The ID for the cached item to retrieve. 62 * @param {number} id The ID for the cached item to retrieve.
61 * @return {!Object} The retrieved item. 63 * @return {!Object} The retrieved item.
62 */ 64 */
63 retrieveItem_: function(id) { 65 retrieveItem_: function(id) {
64 var item = this.cache_[id]; 66 var item = this.cache_[id];
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 var returnValue = cache.wrap(func.apply(null, cache.unwrap(args))); 175 var returnValue = cache.wrap(func.apply(null, cache.unwrap(args)));
174 } catch (error) { 176 } catch (error) {
175 status = error.code || StatusCode.UNKNOWN_ERROR; 177 status = error.code || StatusCode.UNKNOWN_ERROR;
176 var returnValue = error.message; 178 var returnValue = error.message;
177 } 179 }
178 return { 180 return {
179 status: status, 181 status: status,
180 value: returnValue 182 value: returnValue
181 } 183 }
182 } 184 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/commands_unittest.cc ('k') | chrome/test/chromedriver/js/call_function_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698