Permalink
Browse files

Merge pull request #419 from addyosmani/master

Pulling in feature-detection tests from modernizr-plugins
  • Loading branch information...
2 parents 1e1af83 + 5efe030 commit 75afc46fe3060f96b8cfb287bdb08ac3c5ae1170 @paulirish paulirish committed Dec 4, 2011
@@ -0,0 +1,24 @@
+// Animated PNG
+// http://en.wikipedia.org/wiki/APNG
+// By Addy Osmani
+(function () {
+
+ var image = new Image(),
+ canvas = document.createElement('canvas'),
+ ctx = canvas.getContext('2d');
+
+
+ image.onload = function () {
+ Modernizr.addTest('apng', function () {
+ if (typeof canvas.getContext == 'undefined') {
+ return false;
+ } else {
+ ctx.drawImage(image, 0, 0);
+ return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
+ }
+ });
+ };
+
+ image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACGFjVEwAAAABAAAAAcMq2TYAAAANSURBVAiZY2BgYPgPAAEEAQB9ssjfAAAAGmZjVEwAAAAAAAAAAQAAAAEAAAAAAAAAAAD6A+gBAbNU+2sAAAARZmRBVAAAAAEImWNgYGBgAAAABQAB6MzFdgAAAABJRU5ErkJggg==";
+
+}());
@@ -0,0 +1,4 @@
+// Mozilla Audio Data API
+// https://wiki.mozilla.org/Audio_Data_API
+// by Addy Osmani
+Modernizr.addTest('audiodata', !!(window.Audio));
@@ -0,0 +1,4 @@
+// classList
+// https://developer.mozilla.org/en/DOM/element.classList
+// By Addy Osmani
+Modernizr.addTest('classlist', !!('classList' in document.createElement('a')));
@@ -0,0 +1,4 @@
+// contentEditable
+// http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable
+// by Addy Osmani
+Modernizr.addTest('contenteditable', !!('isContentEditable' in document.createElement('span')));
@@ -1,9 +1,11 @@
+// http://www.w3.org/TR/html5/interactive-elements.html#context-menus
+// Demo at http://thewebrocks.com/demos/context-menu/
Modernizr.addTest(
'contextmenu',
('contextMenu' in document.body && 'HTMLMenuItemElement' in window)
);
-// Demo at http://thewebrocks.com/demos/context-menu/
+
@@ -0,0 +1,4 @@
+// DataView
+// https://developer.mozilla.org/en/JavaScript_typed_arrays/DataView
+// By Addy Osmani
+Modernizr.addTest('dataview', (typeof DataView !== 'undefined' && 'getFloat64' in DataView.prototype));
@@ -0,0 +1,4 @@
+// EventSource
+// http://dev.w3.org/html5/eventsource/
+// By Addy Osmani
+Modernizr.addTest('eventsource', !!('EventSource' in window));
@@ -0,0 +1,6 @@
+// GamePad API
+// https://wiki.mozilla.org/GamepadAPI
+// Note: this feature detection test has been confirmed with the developers
+// of the GamePad API implementation in FF
+// By Addy Osmani
+Modernizr.addTest('gamepad', !!('gamepads' in navigator));
@@ -0,0 +1,4 @@
+// getUserMedia
+// http://www.whatwg.org/specs/web-apps/current-work/multipage/video-conferencing-and-peer-to-peer-communication.html
+// By Addy Osmani
+Modernizr.addTest('getusermedia', !!('getUserMedia' in navigator));
@@ -0,0 +1,4 @@
+// Microdata support
+// http://www.w3.org/TR/html5/microdata.html
+// By Addy Osmani
+Modernizr.addTest('microdata', !!(document['getItems']));
@@ -0,0 +1,4 @@
+// <output>
+// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-output-element
+// by Addy Osmani
+Modernizr.addTest('output', !!('value' in document.createElement('output')));
@@ -0,0 +1,3 @@
+// HTML5 <progress> tag
+// By Addy Osmani
+Modernizr.addTest('progress', !!('position' in document.createElement('progress')));
@@ -0,0 +1,4 @@
+// <time> element
+// http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#the-time-element-0
+// by Addy Osmani
+Modernizr.addTest('time', !!('valueAsDate' in document.createElement('time')));
@@ -0,0 +1,4 @@
+// Track element
+// http://www.w3.org/TR/html5/video.html#the-track-element
+// By Addy Osmani
+Modernizr.addTest('track', (typeof (document.createElement('video').addTextTrack) === 'function'));
@@ -0,0 +1,4 @@
+// Web Audio API
+// https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
+// By Addy Osmani
+Modernizr.addTest('webaudio', !!(window.webkitAudioContext || window.AudioContext));

0 comments on commit 75afc46

Please sign in to comment.