diff --git a/detect/dialog.js b/detect/dialog.js new file mode 100644 index 0000000..b17fd12 --- /dev/null +++ b/detect/dialog.js @@ -0,0 +1,30 @@ +(function(has, addtest){ + + var toString = {}.toString, + FUNCTION_CLASS = "[object Function]"; + + if(!has("dom")){ return; } + + var dialog = document.createElement("dialog"); + + addtest("dialog", function(){ + return toString.call(dialog.show) == FUNCTION_CLASS; + }); + + addtest("dialog-open", function(){ + return ("open" in dialog); + }); + + addtest("dialog-show", function(){ + return toString.call(dialog.show) == FUNCTION_CLASS; + }); + + addtest("dialog-show-modal", function(){ + return toString.call(dialog.showModal) == FUNCTION_CLASS; + }); + + addtest("dialog-close", function(){ + return toString.call(dialog.close) == FUNCTION_CLASS; + }); + +})(has, has.add); \ No newline at end of file diff --git a/detect/notification.js b/detect/notification.js new file mode 100644 index 0000000..564c81a --- /dev/null +++ b/detect/notification.js @@ -0,0 +1,23 @@ +(function(has, addtest){ + + var toString = {}.toString, + FUNCTION_CLASS = "[object Function]"; + + if(!has("dom")){ return; } + + addtest("notification", function(){ + return toString.call(window.Notification) === FUNCTION_CLASS || + toString.call(window.webkitNotifications) === FUNCTION_CLASS; + }); + + has.add("notification-checkpermission", function () { + return toString.call(window.Notification.permission) === FUNCTION_CLASS || + toString.call(window.webkitNotifications.checkPermission) === FUNCTION_CLASS; + }); + + has.add("notification-requestpermission", function () { + return toString.call(window.Notification.requestPermission) === FUNCTION_CLASS || + toString.call(window.webkitNotifications.requestPermission) === FUNCTION_CLASS; + }); + +})(has, has.add); \ No newline at end of file diff --git a/detect/url.js b/detect/url.js new file mode 100644 index 0000000..e7580d5 --- /dev/null +++ b/detect/url.js @@ -0,0 +1,20 @@ +(function (has, addtest) { + + var toString = {}.toString, + FUNCTION_CLASS = "[object Function]"; + + // See if URL is available + addtest("native-url", function (g) { + return has.isHostType(g, "URL"); + }); + + // Test for URL's methods + addtest("url-create-object-url", function () { + return toString.call(URL.createObjectURL) == FUNCTION_CLASS; + }); + + addtest("url-revoke-object-url", function () { + return toString.call(URL.revokeObjectURL) == FUNCTION_CLASS; + }); + +})(has, has.add); \ No newline at end of file