Skip to content

Instantly share code, notes, and snippets.

@paulirish
Created December 4, 2011 23:35
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paulirish/1431660 to your computer and use it in GitHub Desktop.
Save paulirish/1431660 to your computer and use it in GitHub Desktop.
detects for testling
/*
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();
});
/*
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();
});
/*
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();
});
@paulirish
Copy link
Author


Bundling...  done

firefox/4.0         0/0    0 % ok
  Log: ["window.ProgressEvent:",true]
  Log: ["window.FormData:",true]
  Log: XHR2 ALL THE things
  Log: ["WithCredentials:",true]
firefox/5.0         0/0    0 % ok
  Log: ["window.ProgressEvent:",true]
  Log: ["window.FormData:",true]
  Log: XHR2 ALL THE things
  Log: ["WithCredentials:",true]
firefox/6.0         0/0    0 % ok
  Log: ["window.ProgressEvent:",true]
  Log: ["window.FormData:",true]
  Log: ["WithCredentials:",true]
  Log: XHR2 ALL THE things
firefox/7.0         0/0    0 % ok
  Log: ["window.ProgressEvent:",true]
  Log: ["window.FormData:",true]
  Log: ["WithCredentials:",true]
  Log: XHR2 ALL THE things
firefox/8.0         0/0    0 % ok
  Log: ["window.ProgressEvent:",true]
  Log: ["window.FormData:",true]
  Log: ["WithCredentials:",true]
  Log: XHR2 ALL THE things
opera/10.0          0/0    0 % ok
  Log: ["window.FormData:",false]
  Log: ["window.ProgressEvent:",false]
  Log: ["WithCredentials:",false]
opera/10.5          0/0    0 % ok
  Log: ["window.ProgressEvent:",false]
  Log: ["WithCredentials:",false]
  Log: ["window.FormData:",false]
opera/11.0          0/0    0 % ok
  Log: ["window.ProgressEvent:",false]
  Log: ["WithCredentials:",false]
  Log: ["window.FormData:",false]
opera/11.5          0/0    0 % ok
  Log: ["WithCredentials:",false]
  Log: ["window.FormData:",false]
  Log: ["window.ProgressEvent:",false]
safari/5.0.5        0/0    0 % ok
  Log: ["window.FormData:",true]
  Log: XHR2 ALL THE things
  Log: ["window.ProgressEvent:",true]
  Log: ["WithCredentials:",true]
safari/5.1          0/0    0 % ok
  Log: ["window.FormData:",true]
  Log: XHR2 ALL THE things
  Log: ["window.ProgressEvent:",true]
  Log: ["WithCredentials:",true]
firefox/nightly        0/0    0 % ok
  Log: ["window.ProgressEvent:",true]
  Log: ["window.FormData:",true]
  Log: ["WithCredentials:",true]
  Log: XHR2 ALL THE things
opera/next          0/0    0 % ok
  Log: ["window.ProgressEvent:",false]
  Log: ["WithCredentials:",true]
  Log: ["window.FormData:",true]
chrome/canary        0/0    0 % ok
  Log: ["window.ProgressEvent:",true]
  Log: ["window.FormData:",true]
  Log: XHR2 ALL THE things
  Log: ["WithCredentials:",true]

total               0/0    0 % ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment