b2g/components/test/mochitest/SandboxPromptTest.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/b2g/components/test/mochitest/SandboxPromptTest.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +<html>
     1.5 +<body>
     1.6 +<script>
     1.7 +
     1.8 +var actions = [
     1.9 +  {
    1.10 +    permissions: ["video-capture"],
    1.11 +    action: function() {
    1.12 +      // invoke video-capture permission prompt
    1.13 +      navigator.mozGetUserMedia({video: true}, function () {}, function () {});
    1.14 +    }
    1.15 +  },
    1.16 +  {
    1.17 +    permissions: ["audio-capture", "video-capture"],
    1.18 +    action: function() {
    1.19 +      // invoke audio-capture + video-capture permission prompt
    1.20 +      navigator.mozGetUserMedia({audio: true, video: true}, function () {}, function () {});
    1.21 +    }
    1.22 +  },
    1.23 +  {
    1.24 +    permissions: ["audio-capture"],
    1.25 +    action: function() {
    1.26 +      // invoke audio-capture permission prompt
    1.27 +      navigator.mozGetUserMedia({audio: true}, function () {}, function () {});
    1.28 +    }
    1.29 +  },
    1.30 +  {
    1.31 +    permissions: ["geolocation"],
    1.32 +    action: function() {
    1.33 +      // invoke geolocation permission prompt
    1.34 +      navigator.geolocation.getCurrentPosition(function (pos) {});
    1.35 +    }
    1.36 +  },
    1.37 +  {
    1.38 +    permissions: ["desktop-notification"],
    1.39 +    action: function() {
    1.40 +      // invoke desktop-notification prompt
    1.41 +      Notification.requestPermission(function (perm) {});
    1.42 +    }
    1.43 +  },
    1.44 +];
    1.45 +
    1.46 +// The requested permissions are specified in query string.
    1.47 +var permissions = JSON.parse(decodeURIComponent(window.location.search.substring(1)));
    1.48 +for (var i = 0; i < actions.length; i++) {
    1.49 +  if(permissions.length === actions[i].permissions.length &&
    1.50 +     permissions.every(function(permission) {
    1.51 +                         return actions[i].permissions.indexOf(permission) >= 0;
    1.52 +                       })) {
    1.53 +    actions[i].action();
    1.54 +    break;
    1.55 +  }
    1.56 +}
    1.57 +
    1.58 +</script>
    1.59 +</body>
    1.60 +</html>

mercurial