From 22f29355a74f922c03f8446139b572e07369813d Mon Sep 17 00:00:00 2001 From: Tim Plunkett Date: Mon, 16 Oct 2017 18:00:01 -0400 Subject: [PATCH 1/2] Document that evaluateScript() has specific needs --- src/Session.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Session.php b/src/Session.php index d8107724c..6bce51adf 100644 --- a/src/Session.php +++ b/src/Session.php @@ -332,6 +332,10 @@ public function executeScript($script) /** * Execute JS in browser and return it's response. * + * The "return" keyword is optional in the script passed as argument. + * Multiline scripts must be wrapped in an immediately-invoked function + * expression. + * * @param string $script javascript * * @return string From a7281248719eedb56a18f5a3d9535300a9bd6695 Mon Sep 17 00:00:00 2001 From: Tim Plunkett Date: Tue, 17 Oct 2017 12:24:16 -0400 Subject: [PATCH 2/2] Expand docs and copy to DriverInterface. --- src/Driver/DriverInterface.php | 6 ++++++ src/Session.php | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Driver/DriverInterface.php b/src/Driver/DriverInterface.php index 0880960c7..1f37dc671 100644 --- a/src/Driver/DriverInterface.php +++ b/src/Driver/DriverInterface.php @@ -578,6 +578,12 @@ public function executeScript($script); * * The "return" keyword is optional in the script passed as argument. Driver implementations * must accept the expression both with and without the keyword. + * Multiline scripts must be wrapped in an immediately-invoked + * function expression. + * Examples of valid scripts: + * - '1 + 1' + * - 'return 1 + 1;' + * - '(function () {return 1 + 1;})()' * * @param string $script * diff --git a/src/Session.php b/src/Session.php index 6bce51adf..f087bbbae 100644 --- a/src/Session.php +++ b/src/Session.php @@ -333,8 +333,12 @@ public function executeScript($script) * Execute JS in browser and return it's response. * * The "return" keyword is optional in the script passed as argument. - * Multiline scripts must be wrapped in an immediately-invoked function - * expression. + * Multiline scripts must be wrapped in an immediately-invoked + * function expression. + * Examples of valid scripts: + * - '1 + 1' + * - 'return 1 + 1;' + * - '(function () {return 1 + 1;})()' * * @param string $script javascript *