瀏覽代碼

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