From 9280e0f730f42cbf69415dcdf493c2e8cb2caa0c Mon Sep 17 00:00:00 2001 From: Stephen K Date: Sun, 28 Jun 2015 11:42:15 -0700 Subject: [PATCH 1/3] Added test for Notification API --- detect/notification.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 detect/notification.js 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 From f8d1be75bfa556882295b882c9c11505006800ef Mon Sep 17 00:00:00 2001 From: Stephen K Date: Sun, 28 Jun 2015 11:42:48 -0700 Subject: [PATCH 2/3] Added test for Dialog element --- detect/dialog.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 detect/dialog.js 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 From efbbb95de0a55632c437dc5502f43c96f5f32d2b Mon Sep 17 00:00:00 2001 From: Stephen K Date: Sun, 28 Jun 2015 22:29:35 -0700 Subject: [PATCH 3/3] Added test for URL feature --- detect/url.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 detect/url.js 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