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

Side by Side Diff: chrome/test/chromedriver/js/call_function_test.html

Issue 2230053002: [chromedriver] Added option to make element references W3C compliant. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed presubmit errors. Created 4 years, 4 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
« no previous file with comments | « chrome/test/chromedriver/js/call_function.js ('k') | chrome/test/chromedriver/session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <html> 2 <html>
3 <script src='test.js'></script> 3 <script src='test.js'></script>
4 <script src='call_function.js'></script> 4 <script src='call_function.js'></script>
5 <script> 5 <script>
6 6
7 function clearCache() { 7 function clearCache() {
8 getPageCache().cache_ = {}; 8 getPageCache().cache_ = {};
9 } 9 }
10 10
11 function isValidUUID(uuid) {
12 assertEquals(36, uuid.length);
13 var list = uuid.split("-").map(function(x) {return x.length;});
14 assertEquals(5, list.length);
15 assertEquals(8, list[0]);
16 assertEquals(4, list[1]);
17 assertEquals(4, list[2]);
18 assertEquals(4, list[3]);
19 assertEquals(12, list[4]);
20 assert(/[a-z0-9-]{36}/.test(uuid));
21 }
22
23 function testUUID() {
24 var uuids = {}
25 for (var i = 0; i < 100; i++) {
26 var uuid = generateUUID();
27 isValidUUID(uuid);
28 assertEquals(null, uuids[uuid]);
29 uuids[uuid] = 1;
30 }
31 }
32
11 function testCallFunctionNoArgs() { 33 function testCallFunctionNoArgs() {
12 clearCache(); 34 clearCache();
13 35
14 var result = callFunction(null, function() { return 1; }, []); 36 var result = callFunction(null, function() { return 1; }, []);
15 assertEquals(0, result.status); 37 assertEquals(0, result.status);
16 assertEquals(1, result.value); 38 assertEquals(1, result.value);
17 } 39 }
18 40
19 function testCallFunctionThrows() { 41 function testCallFunctionThrows() {
20 clearCache(); 42 clearCache();
(...skipping 25 matching lines...) Expand all
46 var cache = getPageCache(); 68 var cache = getPageCache();
47 assertEquals(document.querySelector('div'), unwrap(result.value[1], cache)); 69 assertEquals(document.querySelector('div'), unwrap(result.value[1], cache));
48 } 70 }
49 71
50 function testCallFunctionArgsUnwrappedReturn() { 72 function testCallFunctionArgsUnwrappedReturn() {
51 clearCache(); 73 clearCache();
52 74
53 function func(elem) { 75 function func(elem) {
54 return elem.querySelector('div'); 76 return elem.querySelector('div');
55 } 77 }
56 var result = callFunction(null, func, [wrap(document)], true); 78 var result = callFunction(null, func, [wrap(document)], false, true);
57 assertEquals(document.querySelector('div'), result); 79 assertEquals(document.querySelector('div'), result);
58 } 80 }
59 81
60 function testCacheWrap() { 82 function testCacheWrap() {
83
61 clearCache(); 84 clearCache();
62 85
63 assertEquals(1, wrap(1)); 86 assertEquals(1, wrap(1));
64 assertEquals(1, unwrap(1)); 87 assertEquals(1, unwrap(1));
65 assertEquals("1", wrap("1")); 88 assertEquals("1", wrap("1"));
66 assertEquals("1", unwrap("1")); 89 assertEquals("1", unwrap("1"));
67 assertEquals(false, wrap(false)); 90 assertEquals(false, wrap(false));
68 assertEquals(false, unwrap(false)); 91 assertEquals(false, unwrap(false));
69 assertEquals(null, wrap(null)); 92 assertEquals(null, wrap(null));
70 assertEquals(null, unwrap(null)); 93 assertEquals(null, unwrap(null));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 198
176 var result = callFunction(null, func, [wrappedHost]); 199 var result = callFunction(null, func, [wrappedHost]);
177 assertEquals(0, result.status); 200 assertEquals(0, result.status);
178 assertEquals(wrappedHost['ELEMENT'], result.value['ELEMENT']); 201 assertEquals(wrappedHost['ELEMENT'], result.value['ELEMENT']);
179 var cache = getPageCache(); 202 var cache = getPageCache();
180 assertEquals(host, unwrap(result.value, cache)); 203 assertEquals(host, unwrap(result.value, cache));
181 204
182 document.body.removeChild(host); 205 document.body.removeChild(host);
183 } 206 }
184 207
185 function testCallFunctionWithShadowRoot() { 208 function DISABLED_testCallFunctionWithShadowRoot() {
186 clearCache(); 209 clearCache();
187 210
188 // Set up something in the shadow DOM. 211 // Set up something in the shadow DOM.
189 var host = document.body.appendChild(document.createElement('div')); 212 var host = document.body.appendChild(document.createElement('div'));
190 var root = host.createShadowRoot(); 213 var root = host.createShadowRoot();
191 var shadowDiv = root.appendChild(document.createElement('div')); 214 var shadowDiv = root.appendChild(document.createElement('div'));
192 215
193 function func(element) { 216 function func(element) {
194 return element; 217 return element;
195 } 218 }
196 var wrappedHost = wrap(host); 219 var wrappedHost = wrap(host);
197 var wrappedRoot = wrap(root); 220 var wrappedRoot = wrap(root);
198 221
199 // Trying without setting the shadow_path should fail. 222 // Trying without setting the shadow_path should fail.
200 var result = callFunction(null, func, [wrappedRoot]); 223 var result = callFunction(null, func, [wrappedRoot]);
201 assertEquals(StatusCode.STALE_ELEMENT_REFERENCE, result.status); 224 assertEquals(StatusCode.STALE_ELEMENT_REFERENCE, result.status);
202 // Should succeed with the shadow_path. 225 // Should succeed with the shadow_path.
203 result = callFunction([wrappedHost['ELEMENT']], func, [wrappedRoot]); 226 result = callFunction([wrappedHost['ELEMENT']], func, [wrappedRoot]);
204 assertEquals(0, result.status); 227 assertEquals(0, result.status);
205 assertEquals(wrappedRoot['ELEMENT'], result.value['ELEMENT']); 228 assertEquals(wrappedRoot['ELEMENT'], result.value['ELEMENT']);
206 var cache = getPageCache(root); 229 var cache = getPageCache(root);
207 assertEquals(root, unwrap(result.value, cache)); 230 assertEquals(root, unwrap(result.value, cache));
208 231
209 document.body.removeChild(host); 232 document.body.removeChild(host);
210 } 233 }
211 234
212 function testCacheWithShadowDomAttached() { 235
236 function DISABLED_testCacheWithShadowDomAttached() {
213 clearCache(); 237 clearCache();
214 var pageCache = getPageCache(); 238 var pageCache = getPageCache();
215 239
216 // Set up something in the shadow DOM. 240 // Set up something in the shadow DOM.
217 var host = document.body.appendChild(document.createElement('div')); 241 var host = document.body.appendChild(document.createElement('div'));
218 var root = host.createShadowRoot(); 242 var root = host.createShadowRoot();
219 var shadowDiv = root.appendChild(document.createElement('div')); 243 var shadowDiv = root.appendChild(document.createElement('div'));
220 244
221 // Test with attached element in shadow DOM. 245 // Test with attached element in shadow DOM.
222 var wrappedDiv = wrap(shadowDiv); 246 var wrappedDiv = wrap(shadowDiv);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 281 }
258 282
259 document.body.removeChild(host); 283 document.body.removeChild(host);
260 } 284 }
261 285
262 </script> 286 </script>
263 <body> 287 <body>
264 <div><span></span></div> 288 <div><span></span></div>
265 </body> 289 </body>
266 </html> 290 </html>
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/js/call_function.js ('k') | chrome/test/chromedriver/session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698