Skip to content

Commit

Permalink
Added tests for transparent Webp images
Browse files Browse the repository at this point in the history
Related issue #1023
  • Loading branch information
Krister Kari committed Dec 10, 2013
1 parent 26f64a2 commit f39fcbf
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions feature-detects/img/webp-alpha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*!
{
"name": "Webp Alpha",
"async": true,
"property": "webpalpha",
"aliases": ["webp-alpha"],
"tags": ["image"],
"authors": ["Krister Kari", "Rich Bradshaw", "Ryan Seddon", "Paul Irish"],
"notes": [{
"name": "WebP Info",
"href": "http://code.google.com/speed/webp/"
},{
"name": "Article about WebP support on Android browsers",
"href": "http://www.wope-framework.com/en/2013/06/24/webp-support-on-android-browsers/"
},{
"name": "Chormium WebP announcement",
"href": "http://blog.chromium.org/2011/11/lossless-and-transparency-encoding-in.html?m=1"
}]
}
!*/
/* DOC
Tests for transparent webp support.
*/
define(['Modernizr', 'addTest'], function( Modernizr, addTest ) {
Modernizr.addAsyncTest(function(){
var image = new Image();

image.onerror = function() {
addTest('webpalpha', false, { aliases: ['webp-alpha'] });
};

image.onload = function() {
addTest('webpalpha', image.width == 1, { aliases: ['webp-alpha'] });
};

image.src = 'data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA==';
});
});
1 change: 1 addition & 0 deletions lib/config-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"test/iframe/srcdoc",
"test/img/apng",
"test/img/webp-lossless",
"test/img/webp-alpha",
"test/img/webp",
"test/indexedDB",
"test/input",
Expand Down

0 comments on commit f39fcbf

Please sign in to comment.