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

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

Issue 12675002: [chromedriver] Implement command: executeAsyncScript and setScriptTimeout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address +5000 timeout problem. Created 7 years, 9 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
(Empty)
1 <!DOCTYPE HTML>
2 <html>
3 <script src='test.js'></script>
4 <script src='execute_async_script.js'></script>
5 <script>
6
7 function resetAsyncScriptInfo() {
8 var info = getAsyncScriptInfo();
9 info.id = 0;
10 info.finished = false;
11 delete info.result;
12 }
13
14 function testJavascriptError() {
15 resetAsyncScriptInfo();
16
17 try {
18 executeAsyncScript('f(123);', []);
19 assert(false);
20 } catch (error) {
21 assertEquals(17, error.code);
22 }
23 }
24
25 function testExecuteAsyncScript() {
26 resetAsyncScriptInfo();
27
28 var injectedArgs = null;
29 function captureArguments(args) {
30 injectedArgs = args;
31 }
32 // Pass function captureArguments as the first argument. It is used to capture
33 // the injected arguments to the following script.
34 var script =
35 'var args = arguments; args[0](args); args[args.length - 1](args[1]);';
36 var script_args = [captureArguments, 1];
37 executeAsyncScript(script, script_args);
38
39 assertEquals(3, injectedArgs.length);
40 assertEquals(captureArguments, injectedArgs[0]);
41 assertEquals(1, injectedArgs[1]);
42 var info = getAsyncScriptInfo();
43 assert(info.finished);
44 assertEquals(1, info.result);
45 assertEquals(1, info.id);
46 }
47
48 function testFirstScriptFinishAfterSecondScriptExecute() {
49 resetAsyncScriptInfo();
50
51 executeAsyncScript(
52 'var f = arguments[0]; setTimeout(function(){ f(1); }, 100000);', []);
53 var info = getAsyncScriptInfo();
54 assert(!info.finished);
55 assert(!info.hasOwnProperty('result'));
56 assertEquals(1, info.id);
57
58 executeAsyncScript('var fn = arguments[0]; fn(2);', []);
59 assert(info.finished);
60 assertEquals(2, info.result);
61 assertEquals(2, info.id);
62 }
63
64 </script>
65 <body>
66 </body>
67 </html>
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/js/execute_async_script.js ('k') | chrome/test/chromedriver/run_py_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698