Sha256: 7893d777e7a776d9eb45231e83b762a42232ba5458d6b7caaa1d5b35fb32ecbb

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

new Test.Unit.Runner({
  testBrowserDetection: function() {
    var results = $H(Prototype.Browser).map(function(engine){
      return engine;
    }).partition(function(engine){
      return engine[1] === true
    });
    var trues = results[0], falses = results[1];
    
    this.info('User agent string is: ' + navigator.userAgent);
    
    this.assert(trues.size() == 0 || trues.size() == 1, 
      'There should be only one or no browser detected.');
    
    // we should have definite trues or falses here
    trues.each(function(result) {
      this.assert(result[1] === true);
    }, this);
    falses.each(function(result) {
      this.assert(result[1] === false);
    }, this);
    
    if(navigator.userAgent.indexOf('AppleWebKit/') > -1) {
      this.info('Running on WebKit');
      this.assert(Prototype.Browser.WebKit);
    }
    
    if(!!window.opera) {
      this.info('Running on Opera');
      this.assert(Prototype.Browser.Opera);
    }
    
    if(!!(window.attachEvent && !window.opera)) {
      this.info('Running on IE');
      this.assert(Prototype.Browser.IE);
    }
    
    if(navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1) {
      this.info('Running on Gecko');
      this.assert(Prototype.Browser.Gecko);
    } 
  }  
});

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
Fingertips-headless-squirrel-0.2.0 test/regression/prototype/unit/tests/base_test.js
Fingertips-headless-squirrel-0.3.0 test/regression/prototype/unit/tests/base_test.js
Fingertips-headless-squirrel-0.4.0 test/regression/prototype/unit/tests/base_test.js
Fingertips-headless-squirrel-0.5.0 test/regression/prototype/unit/tests/base_test.js
alloy-js-test-san-0.1.0 test/regression/prototype/unit/tests/base_test.js
alloy-js-test-san-0.1.1 test/regression/prototype/unit/tests/base_test.js
headless-squirrel-0.5.1 test/regression/prototype/unit/tests/base_test.js