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

Avoid error in some environments #638

Merged
merged 1 commit into from
Mar 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion ember_debug/services/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,29 @@ const Session = EmberObject.extend({
getItem(/*key*/) {}
});

let SESSION_STORAGE_SUPPORTED = false;

try {
if (typeof sessionStorage !== 'undefined') {
SESSION_STORAGE_SUPPORTED = true;
}
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to log any sort of message here or does just catching the error retain the functionality, so everything appears good?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Catching the error retains the functionality, so everything appears good.

// This can be reached with the following succession of events:
//
// 1. On Google Chrome
// 2. Disable 3rd-party cookies
// 3. Open the browser inspector
// 4. Open on the Ember inspector
// 5. Visit a page showing an Ember app, on a frame
// loaded from a different domain
//
// It's important that the Ember inspector is already open when
// you land on the page (hence step 4 before 5). Reloading the iframe
// page with the Ember inspector open also reproduces the problem.
}

// Feature detection
if (typeof sessionStorage !== 'undefined') {
if (SESSION_STORAGE_SUPPORTED) {
Session.reopen({
sessionStorage,
prefix: '__ember__inspector__',
Expand Down