-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade JS syn to v0.15.0 #358
Conversation
6ffe75a
to
cfb81e9
Compare
Codecov Report
@@ Coverage Diff @@
## master #358 +/- ##
============================================
+ Coverage 90.02% 90.62% +0.60%
Complexity 150 150
============================================
Files 1 1
Lines 421 448 +27
============================================
+ Hits 379 406 +27
Misses 42 42
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
cfb81e9
to
2920fdc
Compare
08c6a48
to
4bc7bc2
Compare
@@ -222,25 +222,29 @@ protected function withSyn() | |||
/** | |||
* Creates some options for key events | |||
* | |||
* @param string $char the character or code | |||
* @param string $modifier one of 'shift', 'alt', 'ctrl' or 'meta' | |||
* @param string|int $char the character or code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why adding support for integers there ? This looks like a new feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #358 (comment), the method is called from Selenium2Driver::keyXxx()
methods, so this is a phpdoc fix to match 1:1 the possible input types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is protected and not tagged as @internal
. So someone extending the class (and I know some people do extend this class) could rely on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it is not only a phpdoc fix. You also change the code to implement it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#358 (comment) resolved, the phpdoc is changed correctly and int
can/is passed by the testing suite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof can this PR be merged or is there anything else to address?
As the upgraded syn.js lib might cause edge case incompatibilities please tag with increased minor version, ie. 1.7.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if integers are passed without being handled explicitly here, how did it work before ? Were we dispatching broken events (in which case it mean that this is not actually tested by the driver testsuite as it was passing) or was the old version of Syn fixing this for us ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see https://github.com/minkphp/driver-testsuite/blob/f038a1493dbb378b1fc2912a4806fe0117ca1c59/tests/Js/EventsTest.php#L107 test - int
is passed
and how the places - keyXxx methods are annotated - https://github.com/minkphp/Mink/blob/852ce7865833bc482ff4ac9db6d7ed43c58ee4c3/src/Driver/DriverInterface.php#L525
the phpdoc was simply wrong before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof , I can confirm, that:
\Behat\Mink\Driver\DriverInterface::keyPress
method PhpDoc has@param string|int $char ...
;- implementation of that interface method
\Behat\Mink\Driver\Selenium2Driver::keyPress
is passing that$char
parameter to the\Behat\Mink\Driver\Selenium2Driver::charToOptions
method (changed below).
I agree with the made PhpDoc change, but I don't agree with the is_numeric
change into is_int
as this could be a BC break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a thorough investigation, I longer consider this a BC break and agree with a merge.
4bc7bc2
to
5e4e4bd
Compare
src/Selenium2Driver.php
Outdated
@@ -204,7 +204,7 @@ public static function getDefaultCapabilities() | |||
protected function withSyn() | |||
{ | |||
$hasSyn = $this->wdSession->execute(array( | |||
'script' => 'return typeof window["Syn"]!=="undefined" && typeof window["Syn"].trigger!=="undefined"', | |||
'script' => 'return typeof window.syn !== \'undefined\' && typeof window.syn.trigger !== \'undefined\'', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing typeof ... !== \'undefined\'
constructs with ... !== undefined
would also work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -222,25 +222,29 @@ protected function withSyn() | |||
/** | |||
* Creates some options for key events | |||
* | |||
* @param string $char the character or code | |||
* @param string $modifier one of 'shift', 'alt', 'ctrl' or 'meta' | |||
* @param string|int $char the character or code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof , I can confirm, that:
\Behat\Mink\Driver\DriverInterface::keyPress
method PhpDoc has@param string|int $char ...
;- implementation of that interface method
\Behat\Mink\Driver\Selenium2Driver::keyPress
is passing that$char
parameter to the\Behat\Mink\Driver\Selenium2Driver::charToOptions
method (changed below).
I agree with the made PhpDoc change, but I don't agree with the is_numeric
change into is_int
as this could be a BC break.
if (is_int($char)) { | ||
$charCode = $char; | ||
$char = chr($charCode); | ||
} else { | ||
$charCode = ord($char); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this code fragment, because it could potentially lead to the BC break when is_int($char)
and is_numeric($char)
yields different results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aik099 for ex. when 1
char/string is passed, I expect 1
to be pressed, is_numeric
was wrong here, also all tests pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting observation. Never thought that number (e.g. 1
, 7
) could also be interpreted as a symbol and not a char code. Need to look closely at these tests you're talking about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aik099 please merge minkphp/driver-testsuite#61 test for it, also adds a test for capital letter key press
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof , I've debugged the original (prior to this PR) version of the \Behat\Mink\Driver\Selenium2Driver::charToOptions
method and the results are as follows:
- When a letter is given as input, then it's converted into an ASCII code
- When a number is given (as a string or as an integer) it's interpreted as an ASCII code itself
This behavior partially matches the DocBlock on the \Behat\Mink\Driver\DriverInterface::keyPress
:
* @param string|int $char could be either char ('b') or char-code (98)
Due to the usage of the is_numeric
function (in implementation), a digit from '0'
to '9'
passed in as a string was interpreted as an ASCII code as well, which is a bug.
To overcome this developers likely had to pass in the ASCII code of these digits. Tests for the such case were missing, but now they're added via minkphp/driver-testsuite#61 .
5e4e4bd
to
c2ec87d
Compare
@mvorisek , I've rerun the builds and they seem to pass with a new test. |
@aik099 yes, please merge this PR as well and close the 3 mentioned #/issues in the description then. |
Hi @stof, this PR is approved but Alex wants your feedback as well, can you please give this PR a green light? |
@mvorisek , I guess you need to add a line to the changelog explaining the bug, that was fixed with this PR: the numbers from After that, I'll try to merge this PR. |
@aik099 CHANGELOG added |
Merged. Thank you @mvorisek . |
@aik099 Thank you, would it be possible to tag a new release please? |
How that would help you? |
I no longer need it as I desided to fork this repo.. But I would like to get my changes still merged, especially #359. Thank you. |
syn.js downloaded by
npm install syn
and moved fromnode_modules/syn/dist/global/syn.js
(no local compilation, only non-minified version is available, thankfully, as it is much better for debugging)replaces #333
fixes #279 and maybe also #20