github, top, Attribute Selector Tests, Detect completion of CSS loading(With Ruler), Detect completion of CSS loading, Detect completion of image loading, Clearfix, Finding the best CSS hacks for SVG fonts, Test CSS Generated Content, CSSOM, Data URI'ed Web fonts, Interaction of form components, Test Dynamic Script, フォーム部品の実装状況, アイコンとスプラッシュ画面のテスト, import hack, Javascript 実装状況と深刻なバグ, RichLinkのテスト, white space のテスト

Javascript 実装状況と深刻なバグ

IIFE

(function(){
    var a = {};
    (function(){
        print('0:' + typeof document);
        print('1:' + typeof a, typeof a === 'object');
    })();
    print('2:' + typeof a, typeof a === 'object');
    (function(){
        print('3:' + typeof a, typeof a === 'object');
    })();
})();

(function(){
    var a = {};
    (function(){
        print('1:' + typeof a, typeof a === 'object');
    })();
    (function(){
        print('2:' + typeof a, typeof a === 'object');
    })();
    if(true){
        function b(){
            print('3:' + typeof a, typeof a === 'object');
            (function(){
                print('4:' + typeof a, typeof a === 'object');
            })();
            var c=0;
        };
    };
    b();
    (function(){
        print('5:' + typeof a, typeof a === 'object');
    })();

    (function(){
        a.d = function(){
            print('6:' + typeof a, typeof a === 'object');
        };
        a.d();
        a.e = function(f){
            print('7:' + f(), f() === 'object');
        };
        a.e(
            function(){
                return typeof a;
            }
        );
        (function(){
            print('8:' + typeof a, typeof a === 'object');
        })();
    })();
})();

(function(){
    var a = {}, i = 0;
    (function b(){
        print(++i + ':' + typeof a, typeof a === 'object');
        print(++i + ':' + typeof b, typeof b === 'function');
    })();
    shouldThrowError = true;
    b();
})();

var Y, db, F = window;
(function(qa){
    (Y = function(I) {
        qa(I);
    });
    function _(){};
})(print);
Y('1 : Good!');

(function(qa){
    Y = function(I) {
        qa(I);
    };
    // function _(){};
})(print);
Y('2 : Good!');

(function(qa){
    (Y = function(I) {
        qa(I);
    });
    // function _(){};
})(print);
Y('3 : Good!');

Labeled Statement Block

a:{
    // syntax error in Opera 7.x
    print('Good!');
};

eval + comment

(function(){
    // error in Opera 7.03
    print('Good!');
})();

uneval

print('1:uneval()', typeof window.uneval === 'function');

null

print('1:' + typeof null, typeof null === 'object');

instanceof operator

print('1:' + ({} instanceof Object), {} instanceof Object);
print('2:' + (null instanceof Object), !(null instanceof Object));

try statement

try {
    print('Try!');
} catch(O_o){
    throw new Error('...');
}
print('Good!');

in operator

print('1:' + ('toString' in {}), 'toString' in {});
print('2:' + ('length' in []), 'length' in []);
print('3:' + ('length' in {}), !('length' in {}));

check null by for~in

var key;
for(key in null){};
print('Good!');

RegExp Litearl

var re = /reg/;
print('Good!');

var re = /reg/gi;
print('Good!');

var re = /reg/m;
print('Good!');

var re = /reg/y;
print('Good!');

Object

print('1: Object.prototype.__proto__', {}.__proto__ === Object.prototype);

print('1: Object.prototype.watch', typeof Object.prototype.watch === 'function');
print('2: Object.prototype.unwatch', typeof Object.prototype.unwatch === 'function');

print('1: Object.prototype.__defineGetter__', typeof Object.prototype.__defineGetter__ === 'function');
print('2: Object.prototype.__defineSetter__', typeof Object.prototype.__defineSetter__ === 'function');
print('3: Object.prototype.__lookupGetter__', typeof Object.prototype.__lookupGetter__ === 'function');
print('4: Object.prototype.__lookupSetter__', typeof Object.prototype.__lookupSetter__ === 'function');

Object Litearl

var obj = {1: 'Good!'};
print('1:' + obj[1]);

var obj = {'1': 'Good!'};
print('1:' + obj[1]);

var obj = {'': 'Good!'};
print('1:' + obj[''], obj[''] === 'Good!');
obj[''] = 'Good!';
print('2:' + obj[''], obj[''] === 'Good!');
obj= {'': 'Good!'};
print('3:' + obj[''], obj[''] === 'Good!');
for(var k in obj){
    print('4:{"' + k + '" : "' + obj[k] + '"}', k === '');
};

String

var str = 'Good!';
print('1:' + str[0] + str[1] + str[2] + str[3] + str[4], str[0] === 'G');

delete window.XX

window.__apply = Function.prototype;
print('1:' + ('' + window));
print('2:' + (typeof window.__apply), typeof window.__apply === 'function');
print('3:' + (delete window.__apply));
print('4:' + window.__apply, window.__apply === void 0);

window.frames[0].__apply = Function.prototype;
print('1:' + ('' + window.frames[0]));
print('2:' + (typeof window.frames[0].__apply), typeof window.frames[0].__apply === 'function');
print('3:' + (delete window.frames[0].__apply));
print('4:' + window.frames[0].__apply, window.frames[0].__apply === void 0);

document.__apply = Function.prototype;
print('1:' + ('' + document));
print('2:' + (typeof document.__apply), typeof document.__apply === 'function');
print('3:' + (delete document.__apply));
print('4:' + document.__apply, document.__apply === void 0);

(function(){
var element = document.createElement('span');
element.__apply = Function.prototype;
print('1:' + ('' + element));
print('2:' + (typeof element.__apply), typeof element.__apply === 'function');
print('3:' + (delete element.__apply));
print('4:' + element.__apply, element.__apply === void 0);
})();

atob, btoa

print('1:atob', !!window.atob);
print('2:btoa', !!window.btoa);

encodeURI, decodeURI, encodeURIComponent, decodeURIComponent

print('1:encodeURI', !!window.encodeURI);
print('2:decodeURI', !!window.decodeURI);
print('3:encodeURIComponent', !!window.encodeURIComponent);
print('4:decodeURIComponent', !!window.decodeURIComponent);

JSON

print('1:JSON', !!window.JSON);

Function

Function.prototype();
print('Good!');

print('1:Function.prototype.apply', typeof Function.prototype.apply === 'function');
print('1:Function.prototype.call', typeof Function.prototype.call === 'function');

Array

print('1:Array.prototype.push', typeof Array.prototype.push === 'function');
print('1:Array.prototype.pop', typeof Array.prototype.pop === 'function');
print('1:Array.prototype.shift', typeof Array.prototype.shift === 'function');
print('1:Array.prototype.unshift', typeof Array.prototype.unshift === 'function');
print('1:Array.prototype.splice', typeof Array.prototype.splice === 'function');
print('1:Array.prototype.indexOf', typeof Array.prototype.indexOf === 'function');

var a = [];
shouldThrowError = true;
--a.length;
print('1:(--a.length)=' + a.length, a.length=== 0);

document scroll position

print('document.compatMode:' + document.compatMode);
print('window.scrollY:' + window.scrollY);
print('window.pageYOffset:' + window.pageYOffset);
var html = document.documentElement || document.getElementsByTagName('html');
print('html.scrollTop:' + html.scrollTop);
print('body.scrollTop:' + document.body.scrollTop);

Viewport height

print('document.compatMode:' + document.compatMode);
print('window.innerHeight:' + window.innerHeight);
var html = document.documentElement || document.getElementsByTagName('html');
print('html.offsetHeight:' + html.offsetHeight);
print('body.offsetHeight:' + document.body.offsetHeight);

Document height

print('document.compatMode:' + document.compatMode);
var html = document.documentElement || document.getElementsByTagName('html');
var body = document.body;
print('html.offsetHeight:' + html.offsetHeight);
print('html.scrollHeight:' + html.scrollHeight);
print('body.offsetHeight:' + document.body.offsetHeight);
print('body.scrollHeight:' + document.body.scrollHeight);
if( body.getBoundingClientRect ){
    var rect = html.getBoundingClientRect();
    print('html:' + (rect.bottom - rect.top));
    var rect = body.getBoundingClientRect();
    print('body:' + (rect.bottom - rect.top));
};

Extend

(function(){
function extend(a){
a.__apply = Function.prototype;
print('- ' + a);
print('1:' + a.__apply, a.__apply === void 0);
print('2: delete a.__apply', delete a.__apply === true);
print('3:' + a.__apply, a.__apply === void 0);
};
extend(0);
extend('A');
extend(NaN);
extend(Infinity);
})();

(function(){
function extend(a){
a.constructor.prototype.__apply = Function.prototype;
print('- ' + a);
print('1:' + (typeof a.__apply), typeof a.__apply === 'function');
print('2: delete a.__apply', delete a.__apply === true);
print('3:' + a.__apply, ('' + a.__apply).split('\n').join('').split('\r').join('').split(' ').join('') === 'function(){[nativecode]}');
print('4: delete a.constructor.prototype.__apply', (delete a.constructor.prototype.__apply) === true);
print('5:' + a.__apply, a.__apply === void 0);
};
extend(0);
extend('A');
extend(NaN);
extend(Infinity);
})();

delete

(function(){
var a = {};
a.__apply = Function.prototype;
print('- ' + a);
print('1: delete a.__bad__', delete a.__bad__ === true);
print('2: delete a.__apply', delete a.__apply === true);
})();

addEventListener

print('1:' + window.addEventListener);
print('2:' + document.addEventListener);
print('3:' + document.body.addEventListener);

child, sibling

print('1:' + document.body.firstChild);
print('2:' + document.body.lastChild);
print('3:' + document.body.previousSibling);
print('4:' + document.body.nextSibling);
print('5:' + document.body.parentNode);
print('6:' + document.body.parentElement);
print('7:' + document.body.lastChild.previousSibling);
print('8:' + document.body.childNodes);
print('9:' + document.body.children);

noscript

(function(){
var noscripts = document.getElementsByTagName('noscript');
var noscript = noscripts[noscripts.length-1];
print('1:' + noscript.innerHTML);
print('2:' + noscript.innerText);
print('3:' + noscript.textContent);
print('4:' + (noscript.firstChild ? noscript.firstChild.data : ''));
print('5:' + (noscript.firstChild ? noscript.firstChild.textContent : ''));
print('6:' + (noscript.firstChild ? noscript.firstChild.nodeValue : ''));
print('7:' + (noscript.firstChild ? noscript.firstChild.wholeText : ''));
})();

Links