@@ -17,6 +17,7 @@ const png_checkers = `${__dirname}/fixtures/checkers.png`
1717const png_clock = `${ __dirname } /fixtures/clock.png`
1818const jpg_chrome = `${ __dirname } /fixtures/chrome.jpg`
1919const jpg_face = `${ __dirname } /fixtures/face.jpeg`
20+ const svg_tree = `${ __dirname } /fixtures/tree.svg`
2021
2122describe ( 'Image' , function ( ) {
2223 it ( 'Prototype and ctor are well-shaped, don\'t hit asserts on accessors (GH-803)' , function ( ) {
@@ -81,6 +82,30 @@ describe('Image', function () {
8182 } )
8283 } )
8384
85+ it ( 'loads SVG data URL base64' , function ( ) {
86+ const base64Enc = fs . readFileSync ( svg_tree , 'base64' )
87+ const dataURL = `data:image/svg+xml;base64,${ base64Enc } `
88+ return loadImage ( dataURL ) . then ( ( img ) => {
89+ assert . strictEqual ( img . onerror , null )
90+ assert . strictEqual ( img . onload , null )
91+ assert . strictEqual ( img . width , 200 )
92+ assert . strictEqual ( img . height , 200 )
93+ assert . strictEqual ( img . complete , true )
94+ } )
95+ } )
96+
97+ it ( 'loads SVG data URL utf8' , function ( ) {
98+ const utf8Encoded = fs . readFileSync ( svg_tree , 'utf8' )
99+ const dataURL = `data:image/svg+xml;utf8,${ utf8Encoded } `
100+ return loadImage ( dataURL ) . then ( ( img ) => {
101+ assert . strictEqual ( img . onerror , null )
102+ assert . strictEqual ( img . onload , null )
103+ assert . strictEqual ( img . width , 200 )
104+ assert . strictEqual ( img . height , 200 )
105+ assert . strictEqual ( img . complete , true )
106+ } )
107+ } )
108+
84109 it ( 'calls Image#onload multiple times' , function ( ) {
85110 return loadImage ( png_clock ) . then ( ( img ) => {
86111 let onloadCalled = 0
0 commit comments