Skip to content

Commit

Permalink
Merge pull request #184 from gregorylegarec/fix/safari-9.1
Browse files Browse the repository at this point in the history
fix: intent error in Safari 9.1 🍎
  • Loading branch information
gregorylegarec authored Jun 21, 2017
2 parents 565adb8 + ef54526 commit 255c515
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ node_js:
- "6"

services:
- couchdb
- docker

env:
Expand Down
7 changes: 7 additions & 0 deletions src/intents.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ function injectService (url, element, intent, data) {
const messageHandler = (event) => {
if (event.origin !== serviceOrigin) return

if (event.data.type === 'load') {
// Safari 9.1 (At least) send a MessageEvent when the iframe loads,
// making the handshake fails.
console.warn && console.warn('Cozy Client ignored MessageEvent having data.type `load`.')
return
}

if (event.data.type === `intent-${intent._id}:ready`) {
handshaken = true
return event.source.postMessage(data, event.origin)
Expand Down

0 comments on commit 255c515

Please sign in to comment.