Browserscope

What are the Jskb Tests?

This page contains side-effect free JavaScript expressions that expose information about a browser that can be useful to JavaScript code optimizers.

Optimizers can get output in a JSON format at json?ua=….

Scores on the test summary page are not meant to be a measure of the quality of a browser, but to indicate how many features are available as a predictor of how much redundant code might be eliminated on that browser.

More About Each Test

undef OK

Is the global undefined really undefined

typeof undefined

Inf OK

Is the global Infinity set properly

Infinity === 1/0

NaN OK

Is the global NaN set properly

NaN !== NaN

window is global

Does "window" alias the global scope?

!!this.window && this === window

Can "use strict"

Is EcmaScript5 strict mode supported?

!(function () { return this; }.call(null))

Array.slice

typeof Array.slice

fn.bind

typeof Function.prototype.bind

getters

Are getters/setters supported?

(function(){try{return(!!eval("({get x() { return true; }})").x);}catch(e){return(false);}})()

eval function

Does eval differ when used as a function vs. as an operator? See ES5 sec 15.1.2.1.1.

(function (undefined) { return (0,eval)("undefined") === 1; })(1)

typeof Date.now

None

CoreFeatures

Summary of JS features independent of browser APIs

native JSON

Is JSON defined natively?

typeof JSON

typeof Object.prototype.toSource

None

typeof Object.prototype.toJSON

None

date.toISOString

typeof Date.prototype.toISOString

date.toJSON

typeof Date.prototype.toJSON

JSON.stringify with replacer

typeof JSON !== "undefined" && JSON.stringify(false, function (x) { return !this[x]; }) === "true"

typeof uneval

None

Base64 encode/decode fns

typeof atob

Serialization

JSON and serialization support

standard events

typeof addEventListener

typeof attachEvent

None

IE events

!!window.attachEvent

doc.createEvent

typeof document.createEvent

createEventObject

typeof document.createEventObject

createEventObject

!!document.createEventObject

Events

Event APIs available.

native getElementsByClassName

typeof document.getElementsByClassName

native getElementsByClassName

typeof document.documentElement.getElementsByClassName

document.all

Is document.all present?

!!document.all

extended createElement syntax

(function(){try{return(document.createElement('<input type="radio">').type === 'radio');}catch(e){return(false);}})()

compareDocumentPosition

typeof document.documentElement.compareDocumentPosition

Element.contains

typeof document.documentElement.contains

Element.contains

!!document.documentElement.contains

doc.createRange

typeof document.createRange

doScroll

typeof document.documentElement.doScroll

doScroll

!!document.documentElement.doScroll

getBoundingClientRect

typeof document.documentElement.getBoundingClientRect

getBoundingClientRect

!!document.documentElement.getBoundingClientRect

html.sourceIndex

"sourceIndex" in document.documentElement

2 param setAttribute

Does setAttribute need only the two parameters?

document.body.setAttribute.length === 2

toStaticHTML

Does window.toStaticHTML exist?

typeof toStaticHTML

DOM

DOM APIs

style.styleSheet

typeof document.createElement('style').styleSheet

cssText

typeof document.body.style.cssText

getComputedStyle

typeof getComputedStyle

currentStyle

typeof document.body.currentStyle

currentStyle

!!document.body.currentStyle

CSS

CSS

typeof XMLHttpRequest

None

XMLHttpRequest

!!window.XMLHttpRequest

ActiveXObject

typeof ActiveXObject

postMessage

typeof postMessage

Network

Network APIs

Function Junk

Do functions not leak dangerous info in negative indices?

void 0 === ((function(){})[-2])

function exprs OK

Do function expressions not muck with the local scope?

void 0 === ((function(){var b,a=function b(){};return b;})())

finally OK

Do finally blocks fire even if there's no catch on the stack.

(function () { try { throw null; } finally { return true; } })()

function scope OK

Do function scope frames for named functions not inherit from Object.prototype? http://yura.thinkweb2.com/named-function-expressions/#spidermonkey-peculiarity

0 === (function () {  var toString = 0; return (function x() { return toString; })();})()

try scope OK

Do exceptions scope properly?

(function(){var e=true;try{throw false;}catch(e){}return e;})()

typeof new RegExp('x')

Are RegExps functions or objects?

strings indexable

'a'===('a'[0])

unreachable function

Are functions declared only if reachable?

(function(){var a;if(0)function a(){}return void 0===a;})()

__proto__

Is __proto__ defined for objects?

typeof ({}).__proto__

[:Cf:]

Are format control characters lexically significant?

eval("'\u200d'").length === 1

String.split OK

Does string.split work properly -- no skipping blanks?

'a,,a'.split(',').length === 3

Trailing comma

Is a trailing comma in an array ignored?

[,].length === 1

Length DontEnum

Does the length property of an array become enumerable after being set?

(function (a) { a.length = 0; for (var _ in a) { return false; } return true; })([0])

arguments instanceof Array

Is the arguments object an instanceof Array?

(function () { return arguments instanceof Array; })()

Buggy arguments concat

Safari makes arguments an Array but breaks concat.

(function () { return arguments instanceof Array && [].concat(arguments)[0][0] !== 1; })(1, 2)

{} empty

Have enumerable keys been added to Object.prototype?

(function () { for (var _ in {}) return false; return true; })()

fn.name

Do functions have a name property?

"name" in function () {}

inherited enumerable

Are inherited properties inumerable?

(function () { function c() {} c.prototype = {p:0}; return (new c).propertyIsEnumerable("p"); })()

eval(s,f)

Does eval violate integrity of closures?

(function (x) {return eval("x",function(x) {return function() { return x * 0; };}(true));}(false))

str.replace(re,fn)

Can functions be used to generate RegExp replacements?

"-1 2.0".replace(/\S+/g, Math.abs) === "1 2"

Are E4X style for-each loops available?

(function () { for each (var k in [true]) { return k; } })()

Oddities

Bugs & Oddities

CC0 | Home | FAQ | API | UA Parser | News | Browser Resources | Code | Submit a Bug | Downloads | Mailing List | Contact