소스 검색

Clarify execute_async_script docs regarding callback execution

`execute_async_script` doesn't ever call this Perl callback. Even
though it's passed in as the last argument to our
execute_async_script, it isn't actually the last argument in the
context of the executed javascript. The callback that gets executed in
the async script is generated by Selenium and appended to the argument
list. So, previously the argument list looked something like:

    ["myid", "return arguments[0];", $automatic_callback]

But, the example in the docs happened to work as written because the
automatic Javascript callback just returns its argument, and that
happens to be the same thing that the Perl callback was trying to do.

The chromium implementation of [execute_async_script.js][1] can
probably explain it better than I can.

[1]: https://code.google.com/p/chromium/codesearch#chromium/src/chrome/test/chromedriver/js/execute_async_script.js&q=reportValue&sq=package:chromium&l=65
Daniel Gempesaw 12 년 전
부모
커밋
d43baeec2a
1개의 변경된 파일1개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 2
      lib/Selenium/Remote/Driver.pm

+ 1 - 2
lib/Selenium/Remote/Driver.pm

@@ -983,8 +983,7 @@ sub javascript {
         var elem = window.document.findElementById(arg1);
         callback(elem);
     };
-    my $callback = q{return arguments[0];};
-    my $elem = $driver->execute_async_script($script,'myid',$callback);
+    my $elem = $driver->execute_async_script($script,'myid');
     $elem->click;
 
 =cut