b2g/components/test/mochitest/SandboxPromptTest.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial