diff options
author | xue <> | 2006-09-30 18:40:40 +0000 |
---|---|---|
committer | xue <> | 2006-09-30 18:40:40 +0000 |
commit | 1c32172efb18e8d08ea483e2460813670ebfe1a5 (patch) | |
tree | 8420f9e53eaba35d7b4822fac823197254f0d131 /tests/test_tools/selenium/core/scripts/selenium-browserdetect.js | |
parent | 6b1d87352911e43672b46b7a65a3c90dd8e5b8b1 (diff) |
merge from 3.0 branch till 1451.
Diffstat (limited to 'tests/test_tools/selenium/core/scripts/selenium-browserdetect.js')
-rw-r--r-- | tests/test_tools/selenium/core/scripts/selenium-browserdetect.js | 95 |
1 files changed, 44 insertions, 51 deletions
diff --git a/tests/test_tools/selenium/core/scripts/selenium-browserdetect.js b/tests/test_tools/selenium/core/scripts/selenium-browserdetect.js index 137a1518..d97e5a58 100644 --- a/tests/test_tools/selenium/core/scripts/selenium-browserdetect.js +++ b/tests/test_tools/selenium/core/scripts/selenium-browserdetect.js @@ -1,30 +1,30 @@ /* -* Copyright 2004 ThoughtWorks, Inc -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ + * Copyright 2004 ThoughtWorks, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ -// Although it's generally better web development practice not to use browser-detection -// (feature detection is better), the subtle browser differences that Selenium has to -// work around seem to make it necessary. Maybe as we learn more about what we need, -// we can do this in a more "feature-centric" rather than "browser-centric" way. +// Although it's generally better web development practice not to use +// browser-detection (feature detection is better), the subtle browser +// differences that Selenium has to work around seem to make it +// necessary. Maybe as we learn more about what we need, we can do this in +// a more "feature-centric" rather than "browser-centric" way. -BrowserVersion = function() { +var BrowserVersion = function() { this.name = navigator.appName; - if (window.opera != null) - { + if (window.opera != null) { this.browser = BrowserVersion.OPERA; this.isOpera = true; return; @@ -33,66 +33,60 @@ BrowserVersion = function() { var self = this; var checkChrome = function() { - var loc = window.document.location.href; - try { - loc = window.top.document.location.href; - } catch (e) { - // can't see the top (that means we might be chrome, but it's impossible to be sure) - self.isChromeDetectable = "no, top location couldn't be read in this window"; - } - - if (/^chrome:\/\//.test(loc)) { - self.isChrome = true; - } else { - self.isChrome = false; - } + var loc = window.document.location.href; + try { + loc = window.top.document.location.href; + } catch (e) { + // can't see the top (that means we might be chrome, but it's impossible to be sure) + self.isChromeDetectable = "no, top location couldn't be read in this window"; + } + + if (/^chrome:\/\//.test(loc)) { + self.isChrome = true; + } else { + self.isChrome = false; + } } - if (this.name == "Microsoft Internet Explorer") - { + if (this.name == "Microsoft Internet Explorer") { this.browser = BrowserVersion.IE; this.isIE = true; if (window.top.SeleniumHTARunner && window.top.document.location.pathname.match(/.hta$/i)) { - this.isHTA = true; + this.isHTA = true; } if ("0" == navigator.appMinorVersion) { - this.preSV1 = true; + this.preSV1 = true; } return; } - if (navigator.userAgent.indexOf('Safari') != -1) - { + if (navigator.userAgent.indexOf('Safari') != -1) { this.browser = BrowserVersion.SAFARI; this.isSafari = true; this.khtml = true; return; } - if (navigator.userAgent.indexOf('Konqueror') != -1) - { + if (navigator.userAgent.indexOf('Konqueror') != -1) { this.browser = BrowserVersion.KONQUEROR; this.isKonqueror = true; this.khtml = true; return; } - if (navigator.userAgent.indexOf('Firefox') != -1) - { + if (navigator.userAgent.indexOf('Firefox') != -1) { this.browser = BrowserVersion.FIREFOX; this.isFirefox = true; this.isGecko = true; var result = /.*Firefox\/([\d\.]+).*/.exec(navigator.userAgent); - if (result) - { + if (result) { this.firefoxVersion = result[1]; } checkChrome(); return; } - if (navigator.userAgent.indexOf('Gecko') != -1) - { + if (navigator.userAgent.indexOf('Gecko') != -1) { this.browser = BrowserVersion.MOZILLA; this.isMozilla = true; this.isGecko = true; @@ -111,5 +105,4 @@ BrowserVersion.FIREFOX = "Firefox"; BrowserVersion.MOZILLA = "Mozilla"; BrowserVersion.UNKNOWN = "Unknown"; -browserVersion = new BrowserVersion(); - +var browserVersion = new BrowserVersion(); |