-
Notifications
You must be signed in to change notification settings - Fork 251
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
Fix CSP bug in iOS9 #358
Fix CSP bug in iOS9 #358
Conversation
} | ||
txt = $driver.find_element(id: 'bugsnag-test-state').text | ||
assert_equal('DONE', txt, "Expected #bugsnag-test-state text to be 'DONE'. It was '#{txt}'.") |
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 adds a way for the test fixture app to communicate that it is complete, but that an error happened.
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 looks like a good changeset (and has a nice detailed description). I'm happy to approve this with the provision that an entry is added to the changelog documenting the fix.
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.
Same as the above - looks good though needs a changelog entry.
Thanks! Yeah until we arrange some time to rejig the automated release process it still prompts for the changelog entry at the time of the release. |
Goal
In iOS9 Safari, a request that violates the Content Security Policy (CSP) rules causes a
DOMException
to be thrown. Since v4.7.0, bugsnag callsstartSession()
synchronously upon startup, which means that any thrown error in that tick of the event loop results in the libary (and anything else in that synchronous execution context) to be unusable. The behaviour of iOS Safari was fixed in version 10, but since we support 9, this needs a workaround.Changeset
Changed
The
xml-http-request
transport mechanism already wrappedrequest.send()
with a try/catch, but the error in this instance was coming from therequest.open()
call. The try/catch block was moved out out to include all of the synchronous code insidesendReport()
/sendSession()
.Tests
A test that would fail for this browser was added to the end-to-end tests. However, BrowserStack does not support any iOS9 devices via their webdriver protocol, which is what we use. The oldest version available is iOS10.3, which does not exhibit this behaviour.
It is possible to verify locally with an iOS 9 simulator:
npm run build
BROWSER=chrome_61 bundle exec maze-runner features/csp.feature
PORT=9020 ruby features/lib/server.rb
http://localhost:9020/csp/script/a.html?ENDPOINT=/abc
PENDING
should change. If it changes toDONE
the test passes,ERROR
then the test failsHere is a screenshot of it having run in my simulator:
Discussion
Alternative Approaches
We could consider switch to SauceLabs, where you can use older iOS devices. This would require a lot more work.
Linked issues
Fixes #357.
Review
For the submitter, initial self-review:
For the pull request reviewer(s), this changeset has been reviewed for: