Emoji: Fix the diversity emoji check in Safari.

When the browser test for diversity emoji was added in [36160], it included a workaround for Chrome not being able to compare `Uint8ClampedArray` objects directly, by converting them to a string. Unfortunately, Safari doesn't support the `Uint8ClampedArray.toString()` method correctly, so the test was incorrectly failing in Safari.

Fixes #36266 for trunk.



git-svn-id: https://develop.svn.wordpress.org/trunk@37028 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2016-03-17 04:53:49 +00:00
parent 007f3b456c
commit 83080f8e43
1 changed files with 9 additions and 4 deletions

View File

@ -14,7 +14,7 @@
var canvas = document.createElement( 'canvas' ),
context = canvas.getContext && canvas.getContext( '2d' ),
stringFromCharCode = String.fromCharCode,
tone;
tonedata, tone, tone2;
if ( ! context || ! context.fillText ) {
return false;
@ -48,10 +48,15 @@
* compares if the emoji rendering has changed.
*/
context.fillText( stringFromCharCode( 55356, 57221 ), 0, 0 );
tone = context.getImageData( 16, 16, 1, 1 ).data.toString();
tonedata = context.getImageData( 16, 16, 1, 1 ).data;
context.fillText( stringFromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 );
// Chrome has issues comparing arrays, so we compare it as a string, instead.
return tone !== context.getImageData( 16, 16, 1, 1 ).data.toString();
// Chrome has issues comparing arrays, and Safari has issues converting arrays to strings.
// So, we create our own string and compare that, instead.
tonedata = context.getImageData( 16, 16, 1, 1 ).data;
tone2 = tonedata[0] + ',' + tonedata[1] + ',' + tonedata[2] + ',' + tonedata[3];
return tone !== tone2;
case 'simple':
/*
* This creates a smiling emoji, and checks to see if there is any image data in the