-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Handle iOS 12.2 for real devices #122
Conversation
lib/helpers.js
Outdated
function checkIsTargetBased (isSafari, platformVersion) { | ||
// on iOS 12.2 the messages get sent through the Target domain | ||
if (_.isString(platformVersion)) { | ||
platformVersion = parseFloat(platformVersion); |
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 use compareVersions/coerceVersion helpers from appium-support
lib/helpers.js
Outdated
@@ -209,8 +210,16 @@ function deferredPromise () { | |||
}; | |||
} | |||
|
|||
function checkIsTargetBased (isSafari, platformVersion) { |
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 not isTargetBased? check
prefix means we do some additional verification there
lib/webkit-rpc-client.js
Outdated
const msgId = data.id; | ||
let msgId = data.id; | ||
|
||
let result = data.result; |
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.
let {result, params, error} = data
lib/webkit-rpc-client.js
Outdated
let error = data.error; | ||
let method = this.dataMethods[msgId] || data.method; | ||
if (this.isTargetBased) { | ||
if (!(data.method || '').startsWith('Target')) { |
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.
lodash's startsWith method could also be used here. It does safe typecast
lib/webkit-rpc-client.js
Outdated
return; | ||
} | ||
if (data.params.message) { | ||
const message = JSON.parse(data.params.message); |
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 can throw an exception
} | ||
|
||
// the message is aggravatingly nested | ||
if (message.result) { |
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.
can we change that to message.result && message.result.result && message.result.result.value
?
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.
No. Anything nested would end up with empty results:
node
> message = {
... "result": {
..... "cookies": [
..... {
....... "name": "guineacookie1",
....... "value": "i%20am%20a%20cookie%20value",
....... "domain": "192.168.1.152",
....... "path": "/",
....... "expires": 0,
....... "size": 40,
....... "httpOnly": false,
....... "secure": false,
....... "session": true,
....... "sameSite": "None"
....... },
..... {
....... "name": "guineacookie2",
....... "value": "cooki%C3%A92",
....... "domain": "192.168.1.152",
....... "path": "/",
....... "expires": 0,
....... "size": 25,
....... "httpOnly": false,
....... "secure": false,
....... "session": true,
....... "sameSite": "None"
....... }
..... ]
..... },
... "id": 6
... }
{ result: { cookies: [ [Object], [Object] ] }, id: 6 }
> b = message.result && message.result.result && message.result.result.value;
undefined
> b = message.result && message.result.result
undefined
> b = message.result
{ cookies:
[ { name: 'guineacookie1',
value: 'i%20am%20a%20cookie%20value',
domain: '192.168.1.152',
path: '/',
expires: 0,
size: 40,
httpOnly: false,
secure: false,
session: true,
sameSite: 'None' },
{ name: 'guineacookie2',
value: 'cooki%C3%A92',
domain: '192.168.1.152',
path: '/',
expires: 0,
size: 25,
httpOnly: false,
secure: false,
session: true,
sameSite: 'None' } ] }
lib/webkit-rpc-client.js
Outdated
isEventHandled = true; | ||
break; | ||
case 'Target.dispatchMessageFromTarget': | ||
log.debug('HERE'); |
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.
is this log useful?
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.
LGTM
Add support for iOS 12.2 on real devices. For this to work
ios-webkit-debug-proxy
needs to be the latest from HEAD.This duplicates a bunch of logic, but as the package is structured now that is necessary. Once this is in I will allocate some time to refactor this to use the same message handler system, which should remove the duplication.