Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/util/utf8.js

Issue 2546853003: Add W3C encrypted-media tests (Closed)
Patch Set: rebase now that content files landed Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 if ( typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined" )
2 {
3 utf8encoder = new TextEncoder('utf-8');
4 utf8decoder = new TextDecoder('utf-8');
5 }
6 else
7 {
8 utf8encoder = { encode: function( text )
9 {
10 var result = new Uint8Array(text.length);
11 for(var i = 0; i < text.length; i++) { result[i] = text.charCodeAt(i); }
12 return result;
13 } };
14
15 utf8decoder = { decode: function( buffer )
16 {
17 return String.fromCharCode.apply(null, new Uint8Array(buffer));
18 } };
19 }
20
21 toUtf8 = function( o ) { return utf8encoder.encode( JSON.stringify( o ) ); }
22 fromUtf8 = function( t ) { return JSON.parse( utf8decoder.decode( t ) ); }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698