Added try-catch block when activating google cal sync

This commit is contained in:
alext 2017-03-10 09:23:31 +01:00
parent 8f974150c5
commit 34a7277a1e
1 changed files with 7 additions and 1 deletions

View File

@ -47,7 +47,8 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {};
// When the browser redirects to the google user consent page the "window.document" variable
// becomes "undefined" and when it comes back to the redirect URL it changes back. So check
// whether the variable is undefined to avoid javascript errors.
if (windowHandle.document !== undefined) {
try {
if (windowHandle.document !== undefined) {
if (windowHandle.document.URL.indexOf(redirectUrl) !== -1) {
// The user has granted access to his data.
windowHandle.close();
@ -81,6 +82,11 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {};
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
}
}
} catch(Error) {
// Accessing the document object before the window is loaded throws an error, but
// it will only happen during the initialization of the window. Attaching "load"
// event handling is not possible due to CORS restrictions.
}
}, 100);
} else {