Created
December 4, 2011 23:35
-
-
Save paulirish/1431660 to your computer and use it in GitHub Desktop.
detects for testling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
trying out some datalist detects for https://github.com/Modernizr/Modernizr/issues/146 | |
curl -u xxx@xxx \ | |
-sSNT datalist.js 'testling.com/?browsers=iexplore/6.0,iexplore/7.0,iexplore/8.0,iexplore/9.0,chrome/4.0,chrome/5.0,chrome/6.0,chrome/7.0,chrome/8.0,chrome/9.0,chrome/10.0,chrome/11.0,chrome/12.0,chrome/13.0,chrome/14.0,chrome/15.0,firefox/4.0,firefox/5.0,firefox/6.0,firefox/7.0,firefox/8.0,opera/10.0,opera/10.5,opera/11.0,opera/11.5,safari/5.0.5,safari/5.1,firefox/nightly,opera/next,chrome/canary' | |
*/ | |
var test = require('testling'); | |
test('datalist', function (t) { | |
var options = 'options' in document.createElement('datalist') | |
var listoptions = ('list' in document.createElement('input') && 'options' in document.createElement('datalist')) | |
var globalobj = !!window.HTMLDataListElement; | |
var shivglobobj = !!(document.createElement('datalist') && window.HTMLDataListElement) | |
t.log(['basic `"options" in` check :', options ]) | |
t.log(['also checking `"list" in`..:', listoptions ]) | |
t.log(['window.HTMLDataListElement :', globalobj ]); | |
t.log(['shiv + constructor ^ :', shivglobobj ]); | |
t.end(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
trying out some detects for https://developer.mozilla.org/en/HTML_in_XMLHttpRequest | |
curl -u xxx@xxx \ | |
-sSNT responsetype.js 'testling.com/?browsers=iexplore/6.0,iexplore/7.0,iexplore/8.0,iexplore/9.0,chrome/4.0,chrome/5.0,chrome/6.0,chrome/7.0,chrome/8.0,chrome/9.0,chrome/10.0,chrome/11.0,chrome/12.0,chrome/13.0,chrome/14.0,chrome/15.0,firefox/4.0,firefox/5.0,firefox/6.0,firefox/7.0,firefox/8.0,opera/10.0,opera/10.5,opera/11.0,opera/11.5,safari/5.0.5,safari/5.1,firefox/nightly,opera/next,chrome/canary' | |
*/ | |
/* | |
# Results: | |
False positive in IE9, FF<=5, Opera <=11.5 | |
Good in FF6+, Chrome15+, Safari 5+, Opera 12 | |
So.. Looks like the more robust detect from the MDN article is needed. | |
I wonder if the data uri trick is possible though.. | |
*/ | |
var test = require('testling'); | |
test('responsetypedocument', function (t) { | |
var xhr; | |
if (window.XMLHttpRequest) | |
xhr = new window.XMLHttpRequest(); | |
else | |
{ | |
t.log(['XHR? herp derp']); | |
t.end(); | |
return; | |
} | |
t.log(['xhr object exists..', xhr.toString() ]); | |
try { | |
xhr.responseType = "document"; | |
t.log(['Totally fine! ', xhr.responseType.toString() ]); | |
t.log([navigator.userAgent]); | |
} catch(e){ | |
t.log(['responseType = document threw!' ]); | |
} | |
t.end(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
trying out some XHR2 detects for https://github.com/Modernizr/Modernizr/issues/385 | |
testling is awwwesome. | |
curl -u xxx@xxx \ | |
-sSNT XHR2.js 'testling.com/?browsers=iexplore/6.0,iexplore/7.0,iexplore/8.0,iexplore/9.0,chrome/4.0,chrome/5.0,chrome/6.0,chrome/7.0,chrome/8.0,chrome/9.0,chrome/10.0,chrome/11.0,chrome/12.0,chrome/13.0,chrome/14.0,chrome/15.0,firefox/4.0,firefox/5.0,firefox/6.0,firefox/7.0,firefox/8.0,opera/10.0,opera/10.5,opera/11.0,opera/11.5,safari/5.0.5,safari/5.1,firefox/nightly,opera/next,chrome/canary' | |
*/ | |
var test = require('testling'); | |
test('XHR2', function (t) { | |
var progEv = !!(window.ProgressEvent); | |
var fdata = !!(window.FormData); | |
var wCreds = window.XMLHttpRequest && "withCredentials" in new XMLHttpRequest; | |
t.log(['window.ProgressEvent:', progEv]) | |
t.log(['window.FormData:', fdata]) | |
t.log(['WithCredentials:', wCreds]); | |
progEv && fdata && wCreds && t.log('XHR2 ALL THE things') | |
t.end(); | |
}); |
Author
paulirish
commented
Dec 4, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment