summaryrefslogtreecommitdiffstats
path: root/b2g/components/test/mochitest/test_sandbox_permission.html
diff options
context:
space:
mode:
Diffstat (limited to 'b2g/components/test/mochitest/test_sandbox_permission.html')
-rw-r--r--b2g/components/test/mochitest/test_sandbox_permission.html104
1 files changed, 0 insertions, 104 deletions
diff --git a/b2g/components/test/mochitest/test_sandbox_permission.html b/b2g/components/test/mochitest/test_sandbox_permission.html
deleted file mode 100644
index cd13599a3..000000000
--- a/b2g/components/test/mochitest/test_sandbox_permission.html
+++ /dev/null
@@ -1,104 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=951997
--->
-<head>
- <meta charset="utf-8">
- <title>Permission Prompt Test</title>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=951997">Permission prompt web content test</a>
-<script type="application/javascript;version=1.8">
-
-"use strict";
-
-const APP_URL = "SandboxPromptTest.html";
-
-var iframe;
-var gUrl = SimpleTest.getTestFileURL("permission_handler_chrome.js");
-var gScript = SpecialPowers.loadChromeScript(gUrl);
-var gResult = [
- {
- "video-capture": ["back"],
- },
- {
- "audio-capture": [""],
- "video-capture": ["back"],
- },
- {
- "audio-capture": [""],
- },
- {
- "geolocation": [],
- },
- {
- "desktop-notification": [],
- }
-];
-
-function runNext() {
- if (gResult.length > 0) {
- // Put the requested permission in query string
- let requestedPermission = JSON.stringify(Object.keys(gResult[0]));
- info('request permissions for ' + requestedPermission);
- iframe.src = APP_URL + '?' + encodeURIComponent(requestedPermission);
- } else {
- info('test finished, teardown');
- gScript.sendAsyncMessage("teardown", "");
- gScript.destroy();
- SimpleTest.finish();
- }
-}
-
-// Create a sanbox iframe.
-function loadBrowser() {
- iframe = document.createElement("iframe");
- SpecialPowers.wrap(iframe).mozbrowser = true;
- iframe.src = 'about:blank';
- document.body.appendChild(iframe);
-
- iframe.addEventListener("load", function onLoad() {
- iframe.removeEventListener("load", onLoad);
- runNext();
- });
-}
-
-gScript.addMessageListener("permission-request", function (detail) {
- let permissions = detail.permissions;
- let expectedValue = gResult.shift();
- let permissionTypes = Object.keys(permissions);
-
- is(permissionTypes.length, Object.keys(expectedValue).length, "expected number of permissions");
-
- for (let type of permissionTypes) {
- ok(expectedValue.hasOwnProperty(type), "expected permission type");
- for (let i in permissions[type]) {
- is(permissions[type][i], expectedValue[type][i], "expected permission option");
- }
- }
- runNext();
-});
-
-// Add permissions to this app. We use ALLOW_ACTION here. The ContentPermissionPrompt
-// should prompt for permission, not allow it without prompt.
-SpecialPowers.pushPrefEnv({"set": [["media.navigator.permission.disabled", false]]},
- function() {
- SpecialPowers.addPermission('video-capture',
- SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION, document);
- SpecialPowers.addPermission('audio-capture',
- SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION, document);
- SpecialPowers.addPermission('geolocation',
- SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION, document);
- SpecialPowers.addPermission('desktop-notification',
- SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION, document);
- loadBrowser();
- });
-
-SimpleTest.waitForExplicitFinish();
-</script>
-</pre>
-</body>
-</html>