From a1dff8ad9bf42e1397c95746dc9f7696eab64cbd Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 13:23:40 +0200 Subject: [PATCH] Changed OpenLayers.BROWSER_NAME to be 'chrome' for Google Chrome instead of 'safari'. Added OpenLayers.IS_WEBKIT and changed tests where necessary. --- lib/OpenLayers/Util.js | 13 ++++++++++++- tests/deprecated/Layer/MapServer.html | 4 ++-- tests/deprecated/Layer/WMS.html | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index ac598f2604..18ebe0a420 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1439,13 +1439,22 @@ OpenLayers.Util.removeTail = function(url) { return head; }; +/** + * Constant: IS_WEBKIT + * {Boolean} True if the userAgent reports the browser to use the WebKit engine + */ +OpenLayers.IS_WEBKIT = (function() { + var ua = navigator.userAgent.toLowerCase(); + return ua.indexOf("webkit") !== -1; +})(); + /** * Constant: IS_GECKO * {Boolean} True if the userAgent reports the browser to use the Gecko engine */ OpenLayers.IS_GECKO = (function() { var ua = navigator.userAgent.toLowerCase(); - return ua.indexOf("webkit") == -1 && ua.indexOf("gecko") != -1; + return !OpenLayers.IS_WEBKIT && ua.indexOf("gecko") !== -1; })(); /** @@ -1475,6 +1484,8 @@ OpenLayers.BROWSER_NAME = (function() { name = "opera"; } else if (ua.indexOf("msie") != -1) { name = "msie"; + } else if(ua.indexOf("chrome") != -1) { + name = "chrome"; } else if (ua.indexOf("safari") != -1) { name = "safari"; } else if (ua.indexOf("mozilla") != -1) { diff --git a/tests/deprecated/Layer/MapServer.html b/tests/deprecated/Layer/MapServer.html index 27ce63dd20..ec6e7a5792 100644 --- a/tests/deprecated/Layer/MapServer.html +++ b/tests/deprecated/Layer/MapServer.html @@ -18,9 +18,9 @@ (window.location.host == "localhost") || (window.location.host == "openlayers.org"); - if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") { + if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.IS_WEBKIT) { t.plan(1); - t.debug_print("Can't test google reprojection in Opera or Safari."); + t.debug_print("Can't test google reprojection in Opera or WebKit."); } else if(validkey) { t.plan(5); var map = new OpenLayers.Map('map'); diff --git a/tests/deprecated/Layer/WMS.html b/tests/deprecated/Layer/WMS.html index 523d6eef12..cca85ffc83 100644 --- a/tests/deprecated/Layer/WMS.html +++ b/tests/deprecated/Layer/WMS.html @@ -16,7 +16,7 @@ var validkey = (window.location.protocol == "file:") || (window.location.host == "localhost") || (window.location.host == "openlayers.org"); - if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") { + if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.IS_WEBKIT) { t.plan(1); t.debug_print("Can't test google reprojection in Opera or Safari."); } else if(validkey) {