Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <html> |
michael@0 | 2 | <body> |
michael@0 | 3 | <script> |
michael@0 | 4 | |
michael@0 | 5 | var actions = [ |
michael@0 | 6 | { |
michael@0 | 7 | permissions: ["video-capture"], |
michael@0 | 8 | action: function() { |
michael@0 | 9 | // invoke video-capture permission prompt |
michael@0 | 10 | navigator.mozGetUserMedia({video: true}, function () {}, function () {}); |
michael@0 | 11 | } |
michael@0 | 12 | }, |
michael@0 | 13 | { |
michael@0 | 14 | permissions: ["audio-capture", "video-capture"], |
michael@0 | 15 | action: function() { |
michael@0 | 16 | // invoke audio-capture + video-capture permission prompt |
michael@0 | 17 | navigator.mozGetUserMedia({audio: true, video: true}, function () {}, function () {}); |
michael@0 | 18 | } |
michael@0 | 19 | }, |
michael@0 | 20 | { |
michael@0 | 21 | permissions: ["audio-capture"], |
michael@0 | 22 | action: function() { |
michael@0 | 23 | // invoke audio-capture permission prompt |
michael@0 | 24 | navigator.mozGetUserMedia({audio: true}, function () {}, function () {}); |
michael@0 | 25 | } |
michael@0 | 26 | }, |
michael@0 | 27 | { |
michael@0 | 28 | permissions: ["geolocation"], |
michael@0 | 29 | action: function() { |
michael@0 | 30 | // invoke geolocation permission prompt |
michael@0 | 31 | navigator.geolocation.getCurrentPosition(function (pos) {}); |
michael@0 | 32 | } |
michael@0 | 33 | }, |
michael@0 | 34 | { |
michael@0 | 35 | permissions: ["desktop-notification"], |
michael@0 | 36 | action: function() { |
michael@0 | 37 | // invoke desktop-notification prompt |
michael@0 | 38 | Notification.requestPermission(function (perm) {}); |
michael@0 | 39 | } |
michael@0 | 40 | }, |
michael@0 | 41 | ]; |
michael@0 | 42 | |
michael@0 | 43 | // The requested permissions are specified in query string. |
michael@0 | 44 | var permissions = JSON.parse(decodeURIComponent(window.location.search.substring(1))); |
michael@0 | 45 | for (var i = 0; i < actions.length; i++) { |
michael@0 | 46 | if(permissions.length === actions[i].permissions.length && |
michael@0 | 47 | permissions.every(function(permission) { |
michael@0 | 48 | return actions[i].permissions.indexOf(permission) >= 0; |
michael@0 | 49 | })) { |
michael@0 | 50 | actions[i].action(); |
michael@0 | 51 | break; |
michael@0 | 52 | } |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | </script> |
michael@0 | 56 | </body> |
michael@0 | 57 | </html> |