aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgabrielluong2013-06-14 16:22:14 (EDT)
committerkwalker2013-06-14 16:22:14 (EDT)
commitf913b48910630484002fece219b0e2f1d395ee3b (patch)
treec6d823bca579f2d8d19800c471d012d3f1fcd2dc
parent8bc25cdb134e7935a86d1e603ac7cad36e50aea7 (diff)
downloadorg.eclipse.orion.client-f913b48910630484002fece219b0e2f1d395ee3b.zip
org.eclipse.orion.client-f913b48910630484002fece219b0e2f1d395ee3b.tar.gz
org.eclipse.orion.client-f913b48910630484002fece219b0e2f1d395ee3b.tar.bz2
Bug 409768 - Revising browser detection strategy for non-supported browsers
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js59
1 files changed, 46 insertions, 13 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js b/bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js
index f48f371..0dfe73c 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js
@@ -7,37 +7,70 @@
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
*******************************************************************************/
-/*global window document define login logout localStorage orion alert*/
+/*global window document define login logout localStorage orion alert confirm*/
/*jslint browser:true sub:true*/
define(function() {
function isSupportedBrowser() {
var userAgent = navigator.userAgent;
- var isSupported = false;
+ var isSupported = {
+ browser: false,
+ version: false
+ };
var VERSION = 1;
- var browserData = [ {name: 'Chrome/Chromium', regExp: /(?:chrome|crios|chromium)\/(\d+)/i, minVersion: 24},
- {name: 'Firefox', regExp: /firefox\/(\d+)/i, minVersion: 17},
- {name: 'MSIE', regExp: /msie\s(\d+)/i, minVersion: 10},
- {name: 'Safari', regExp: /version\/(\d+).*?safari/i, minVersion: 5} ];
+ var browserData = [ {name: 'Chrome/Chromium', regExp: /(?:chrome|crios|chromium)\/(\d+)/i, minVersion: 24}, //$NON-NLS-0$
+ {name: 'Firefox', regExp: /firefox\/(\d+)/i, minVersion: 17}, //$NON-NLS-0$
+ {name: 'MSIE', regExp: /msie\s(\d+)/i, minVersion: 10}, //$NON-NLS-0$
+ {name: 'Safari', regExp: /version\/(\d+).*?safari/i, minVersion: 5} ]; //$NON-NLS-0$
for (var i = 0; i < browserData.length; i++) {
var browser = browserData[i];
var matches = userAgent.match(browser.regExp);
- if (matches && matches[VERSION] >= browser.minVersion) {
- isSupported = true;
+ if (matches) {
+ isSupported.browser = true;
+ isSupported.version = matches[VERSION] >= browser.minVersion;
+ isSupported.name = browser.name;
break;
}
}
return isSupported;
}
-
- if (!isSupportedBrowser()) {
- alert("Sorry, your browser is not supported.\n\nTo use Orion, the latest version of the Chrome, Firefox, or Safari web browser is recommended.\n");
- throw 'unsupported browser';
+
+ function supportsLocalStorage() {
+ try {
+ return 'localStorage' in window && window['localStorage'] !== null; //$NON-NLS-1$ //$NON-NLS-0$
+ } catch (e) {
+ return false;
+ }
+ }
+
+ function throwBrowserAlert(message) {
+ alert(message);
+ throw 'unsupported browser'; //$NON-NLS-0$
+ }
+
+ var isSupported = isSupportedBrowser();
+
+ // Continue at your own risk for non-standard browsers
+ if (!isSupported.browser) {
+ if (supportsLocalStorage() && !localStorage["skipBrowserCheck"]) { //$NON-NLS-0$
+ if (confirm("Sorry, your browser is not supported. The latest version of Chrome, Firefox or Safari web browser is recommended.\nContinue anyway?")) { //$NON-NLS-0$
+ localStorage["skipBrowserCheck"] = 1; //$NON-NLS-0$
+ } else {
+ throw 'unsupported browser'; //$NON-NLS-0$
+ }
+ } else if (!supportsLocalStorage()) {
+ throwBrowserAlert("Sorry, your browser is not supported.\n\nTo use Orion, the latest version of the Chrome, Firefox, or Safari web browser is recommended.\n"); //$NON-NLS-0$
+ }
+ } else if (!isSupported.version) {
+ // Display an alert when the browser is supported, but falls below the min. supported version
+ throwBrowserAlert("Sorry, your browser version is not supported.\n\nTo use Orion, please upgrade to the latest version of " + isSupported.name + ".\n"); //$NON-NLS-1$ //$NON-NLS-0$
}
return {
- isSupportedBrowser: isSupportedBrowser
+ isSupportedBrowser: isSupportedBrowser,
+ supportsLocalStorage: supportsLocalStorage,
+ throwBrowserAlert: throwBrowserAlert
};
}); \ No newline at end of file