Sha256: 2c872aa2b4e93b6513a8eb4a256ec507f5bdd537ba194aec5f9fadfbe54418e5

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 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/prototype_test.js
Fingertips-headless-squirrel-0.3.0 test/regression/prototype/unit/tests/prototype_test.js
Fingertips-headless-squirrel-0.4.0 test/regression/prototype/unit/tests/prototype_test.js
Fingertips-headless-squirrel-0.5.0 test/regression/prototype/unit/tests/prototype_test.js
alloy-js-test-san-0.1.0 test/regression/prototype/unit/tests/prototype_test.js
alloy-js-test-san-0.1.1 test/regression/prototype/unit/tests/prototype_test.js
headless-squirrel-0.5.1 test/regression/prototype/unit/tests/prototype_test.js