14
14
var canvas = document.createElement( 'canvas' ),
15
15
context = canvas.getContext && canvas.getContext( '2d' ),
16
16
stringFromCharCode = String.fromCharCode,
17
tonedata, tone, tone2;
17
flag, flag2, tonedata, tone, tone2;
19
19
if ( ! context || ! context.fillText ) {
40
40
* to a larger image (4-5KB data URL).
42
42
context.fillText( stringFromCharCode( 55356, 56806, 55356, 56826 ), 0, 0 );
43
return canvas.toDataURL().length > 3000;
43
if ( canvas.toDataURL().length < 3000 ) {
47
context.clearRect( 0, 0, canvas.width, canvas.height );
50
* Test for rainbow flag compatibility. As the rainbow flag was added out of sequence with
51
* the usual Unicode release cycle, some browsers support it, and some don't, even if their
52
* Unicode support is up to date.
54
* To test for support, we try to render it, and compare the rendering to how it would look if
55
* the browser doesn't render it correctly (white flag emoji + rainbow emoji).
57
context.fillText( stringFromCharCode( 55356, 57331, 65039, 8205, 55356, 57096 ), 0, 0 );
58
flag = canvas.toDataURL();
60
context.clearRect( 0, 0, canvas.width, canvas.height );
62
context.fillText( stringFromCharCode( 55356, 57331, 55356, 57096 ), 0, 0 );
63
flag2 = canvas.toDataURL();
65
return flag !== flag2;
46
68
* This tests if the browser supports the Emoji Diversity specification, by rendering an
74
96
context.fillText( stringFromCharCode( 55356, 57135 ), 0, 0 );
75
97
return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0;
100
* Do Unicode 9 emoji render?
103
context.fillText( stringFromCharCode( 55358, 56631 ), 0, 0 );
104
return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0;
86
115
document.getElementsByTagName( 'head' )[0].appendChild( script );
89
tests = Array( 'simple', 'flag', 'unicode8', 'diversity' );
118
tests = Array( 'simple', 'flag', 'unicode8', 'diversity', 'unicode9' );
91
120
settings.supports = {