Skip to content
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

Merged
merged 2 commits into from
Apr 1, 2019
Merged

Handle iOS 12.2 for real devices #122

merged 2 commits into from
Apr 1, 2019

Conversation

imurchie
Copy link
Contributor

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.

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);
Copy link
Contributor

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) {
Copy link
Contributor

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

const msgId = data.id;
let msgId = data.id;

let result = data.result;
Copy link
Contributor

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

let error = data.error;
let method = this.dataMethods[msgId] || data.method;
if (this.isTargetBased) {
if (!(data.method || '').startsWith('Target')) {
Copy link
Contributor

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

return;
}
if (data.params.message) {
const message = JSON.parse(data.params.message);
Copy link
Contributor

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) {
Copy link
Contributor

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 ?

Copy link
Contributor Author

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' } ] }

isEventHandled = true;
break;
case 'Target.dispatchMessageFromTarget':
log.debug('HERE');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this log useful?

Copy link
Contributor

@mykola-mokhnach mykola-mokhnach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@imurchie imurchie merged commit 4a03ddc into master Apr 1, 2019
@imurchie imurchie deleted the isaac-webkit-12.2 branch April 1, 2019 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants