Skip to content

Commit

Permalink
All tests now have metadata – whoop!
Browse files Browse the repository at this point in the history
  • Loading branch information
stucox committed Jun 10, 2013
1 parent a6e108a commit 74374d7
Show file tree
Hide file tree
Showing 30 changed files with 800 additions and 87 deletions.
20 changes: 20 additions & 0 deletions feature-detects/applicationcache.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*!
{
"name": "Application Cache",
"property": "applicationcache",
"caniuse": "offline-apps",
"tags": ["storage", "offline"],
"notes": [{
"name": "MDN documentation",
"href": "https://developer.mozilla.org/en/docs/HTML/Using_the_application_cache"
}],
"polyfills": ["html5gears"]
}
!*/
/* DOC
Detects support for the Application Cache, for storing data to enable web-based applications run offline.
The API has been [heavily criticized](http://alistapart.com/article/application-cache-is-a-douchebag) and discussions are underway to address this.
*/
define(['Modernizr'], function( Modernizr ) {
Modernizr.addTest('applicationcache', !!window.applicationCache);
});
21 changes: 18 additions & 3 deletions feature-detects/battery.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
/*!
{
"name": "Battery API",
"property": "batteryapi",
"aliases": ["battery-api"],
"tags": ["device", "media"],
"authors": ["Paul Sayre"],
"notes": [{
"name": "MDN documentation",
"href": "https://developer.mozilla.org/en/DOM/window.navigator.mozBattery"
}]
}
!*/
/* DOC
Detect support for the Battery API, for accessing information about the system's battery charge level.
*/
define(['Modernizr', 'prefixed'], function( Modernizr, prefixed ) {
// Battery API
// https://developer.mozilla.org/en/DOM/window.navigator.mozBattery
// By: Paul Sayre
Modernizr.addTest('batteryapi', !!prefixed('battery', navigator), { aliases: ['battery-api'] });
});
21 changes: 18 additions & 3 deletions feature-detects/blob.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
define(['Modernizr'], function( Modernizr ) {
// Blob constructor
// http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob
/*!
{
"name": "Blob constructor",
"property": "blobconstructor",
"aliases": ["blob-constructor"],
"caniuse": "blobbuilder",
"notes": [{
"name": "W3C spec",
"href": "http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob"
}],
"polyfills": ["blobjs"]
}
!*/
/* DOC
Detects support for the Blob constructor, for creating file-like objects of immutable, raw data.
*/
define(['Modernizr'], function( Modernizr ) {
Modernizr.addTest('blobconstructor', function () {
try {
return !!new Blob();
Expand Down
16 changes: 14 additions & 2 deletions feature-detects/canvas.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
/*!
{
"name": "Canvas",
"property": "canvas",
"caniuse": "canvas",
"tags": ["canvas", "graphics"],
"polyfills": ["flashcanvas", "excanvas", "slcanvas", "fxcanvas"]
}
!*/
/* DOC
Detects support for the `<canvas>` element for 2D drawing.
*/
define(['Modernizr', 'createElement'], function( Modernizr, createElement ) {
// Canvas
// On the S60 and BB Storm, getContext exists, but always returns undefined
// so we actually have to call getContext() to verify
// github.com/Modernizr/Modernizr/issues/issue/97/

Modernizr.addTest('canvas', function() {
var elem = createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
Expand Down
14 changes: 14 additions & 0 deletions feature-detects/canvastext.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*!
{
"name": "Canvas text",
"property": "canvastext",
"caniuse": "canvas-text",
"tags": ["canvas", "graphics"],
"polyfills": ["canvastext"]
}
!*/
/* DOC
Detects support for the text APIs for `<canvas>` elements.
*/
define(['Modernizr', 'createElement', 'test/canvas'], function( Modernizr, createElement ) {
Modernizr.addTest('canvastext', function() {
if (Modernizr.canvas === false) return false;
Expand Down
23 changes: 17 additions & 6 deletions feature-detects/contenteditable.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
define(['Modernizr', 'docElement'], function( Modernizr, docElement ) {
// contentEditable
// http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable
/*!
{
"name": "Content Editable",
"property": "contenteditable",
"caniuse": "contenteditable",
"knownBugs": ["This is known to false positive in some mobile browsers. Here is a whitelist of verified working browsers: http://bit.ly/15RIQ9A"],
"notes": [{
"name": "WHATWG spec",
"href": "http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable"
}]
}
!*/
/* DOC
Detects support for the `contenteditable` attribute of elements, allowing their DOM text contents to be edited directly by the user.
// this is known to false positive in some mobile browsers
// here is a whitelist of verified working browsers:
// https://github.com/NielsLeenheer/html5test/blob/549f6eac866aa861d9649a0707ff2c0157895706/scripts/engine.js#L2083
*/
define(['Modernizr', 'docElement'], function( Modernizr, docElement ) {
Modernizr.addTest('contenteditable', 'contentEditable' in docElement);
});
29 changes: 20 additions & 9 deletions feature-detects/contentsecuritypolicy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
define(['Modernizr'], function( Modernizr ) {
// Test for (experimental) Content Security Policy 1.1 support.
//
// This feature is still quite experimental, but is available now in Chrome 22.
// If the `SecurityPolicy` property is available, you can be sure the browser
// supports CSP. If it's not available, the browser still might support an
// earlier version of the CSP spec.
//
// Editor's Draft: https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html
/*!
{
"name": "Content Security Policy",
"property": "contentsecuritypolicy",
"caniuse": "contentsecuritypolicy",
"tags": ["security"],
"notes": [{
"name": "W3C spec",
"href": "http://www.w3.org/TR/CSP/"
},{
"name": "MDN documentation",
"href": "https://developer.mozilla.org/en-US/docs/Security/CSP"
}]
}
!*/
/* DOC
Detects support for the Content Security Policy protocol for mitigating and reporting security attacks.
*/
define(['Modernizr'], function( Modernizr ) {
Modernizr.addTest('contentsecuritypolicy', 'SecurityPolicy' in document);
});
22 changes: 20 additions & 2 deletions feature-detects/contextmenu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
/*!
{
"name": "Context menus",
"property": "contextmenu",
"caniuse": "menu",
"notes": [{
"name": "W3C spec",
"href": "http://www.w3.org/TR/html5/interactive-elements.html#context-menus"
},{
"name": "thewebrocks.com Demo",
"href": "http://thewebrocks.com/demos/context-menu/"
}],
"polyfills": ["jquery-contextmenu"]
}
!*/
/* DOC
Detects support for custom context menus.
*/
define(['Modernizr', 'docElement'], function( Modernizr, docElement ) {
// http://www.w3.org/TR/html5/interactive-elements.html#context-menus
// Demo at http://thewebrocks.com/demos/context-menu/
Modernizr.addTest(
'contextmenu',
('contextMenu' in docElement && 'HTMLMenuItemElement' in window)
Expand Down
14 changes: 13 additions & 1 deletion feature-detects/cookies.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
/*!
{
"name": "Cookies",
"property": "cookies",
"tags": ["storage"],
"authors": ["tauren"]
}
!*/
/* DOC
Detects whether cookie support is enabled.
*/
define(['Modernizr'], function( Modernizr ) {
// by tauren
// https://github.com/Modernizr/Modernizr/issues/191

Modernizr.addTest('cookies', function () {
Expand Down
20 changes: 18 additions & 2 deletions feature-detects/cors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
/*!
{
"name": "Cross-Origin Resource Sharing",
"property": "cors",
"caniuse": "cors",
"authors": ["Theodoor van Donge"],
"notes": [{
"name": "MDN documentation",
"href": "https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS"
}],
"polyfills": ["pmxdr", "ppx", "flxhr"]
}
!*/
/* DOC
Detects support for Cross-Origin Resource Sharing: method of performing XMLHttpRequests across domains.
*/
define(['Modernizr'], function( Modernizr ) {
// cors
// By Theodoor van Donge
Modernizr.addTest('cors', !!(window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()));
});
26 changes: 21 additions & 5 deletions feature-detects/custom-protocol-handler.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
/*!
{
"name": "Custom protocol handler",
"property": "customprotocolhandler",
"authors": ["Ben Schwarz"],
"notes": [{
"name": "WHATWG overview",
"href": "http://developers.whatwg.org/timers.html#custom-handlers"
},{
"name": "MDN documentation",
"href": "https://developer.mozilla.org/en-US/docs/Web/API/navigator.registerProtocolHandler"
}],
"warnings": [],
"polyfills": []
}
!*/
/* DOC
Detects support for the `window.registerProtocolHandler()` API to allow web sites to register themselves as possible handlers for particular protocols.
*/
define(['Modernizr'], function( Modernizr ) {
/*
Custom protocol handler support
http://developers.whatwg.org/timers.html#custom-handlers
Added by @benschwarz
*/
Modernizr.addTest('customprotocolhandler', !!navigator.registerProtocolHandler);
});
20 changes: 16 additions & 4 deletions feature-detects/dart.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
define(['Modernizr', 'prefixed'], function( Modernizr, prefixed ) {
// Dart
// By Theodoor van Donge
// https://chromiumcodereview.appspot.com/9232049/
/*!
{
"name": "Dart",
"property": "dart",
"authors": ["Theodoor van Donge"],
"notes": [{
"name": "Language website",
"href": "http://www.dartlang.org/"
}]
}
!*/
/* DOC
Detects native support for the Dart programming language.
*/
define(['Modernizr', 'prefixed'], function( Modernizr, prefixed ) {
Modernizr.addTest('dart', !!prefixed('startDart', navigator));
});
20 changes: 17 additions & 3 deletions feature-detects/dataview-api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
/*!
{
"name": "DataView",
"property": "dataview",
"authors": ["Addy Osmani"],
"notes": [{
"name": "MDN documentation",
"href": "https://developer.mozilla.org/en/JavaScript_typed_arrays/DataView"
}],
"polyfills": ["jdataview"]
}
!*/
/* DOC
Detects support for the DataView interface for reading data from an ArrayBuffer as part of the Typed Array spec.
*/
define(['Modernizr'], function( Modernizr ) {
// DataView
// https://developer.mozilla.org/en/JavaScript_typed_arrays/DataView
// By Addy Osmani
Modernizr.addTest('dataview', (typeof DataView !== 'undefined' && 'getFloat64' in DataView.prototype));
});
19 changes: 17 additions & 2 deletions feature-detects/draganddrop.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
define(['Modernizr', 'createElement'], function( Modernizr, createElement ) {
// http://dev.w3.org/html5/spec/dnd.html
/*!
{
"name": "Drag & Drop",
"property": "draganddrop",
"caniuse": "dragndrop",
"notes": [{
"name": "W3C spec",
"href": "http://www.w3.org/TR/2010/WD-html5-20101019/dnd.html"
}],
"polyfills": ["dropfile", "moxie", "fileapi"]
}
!*/
/* DOC
Detects support for native drag & drop of elements.
*/
define(['Modernizr', 'createElement'], function( Modernizr, createElement ) {
Modernizr.addTest('draganddrop', function() {
var div = createElement('div');
return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div);
Expand Down
13 changes: 11 additions & 2 deletions feature-detects/emoji.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
/*!
{
"name": "Emoji",
"property": "emoji"
}
!*/
/* DOC
Detects support for emoji character sets.
*/
define(['Modernizr', 'createElement', 'test/canvastext'], function( Modernizr, createElement ) {
// Requires a Modernizr build with `canvastext` included
// http://www.modernizr.com/download/#-canvas-canvastext
Modernizr.addTest('emoji', function() {
if (!Modernizr.canvastext) return false;
var node = createElement('canvas'),
Expand Down

0 comments on commit 74374d7

Please sign in to comment.