This commit is contained in:
Wes Kocher 2014-01-02 19:53:58 -08:00
Родитель c569071be2 b0474a321c
Коммит 594ca9fa1e
9 изменённых файлов: 183 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,16 @@
<html>
<body>
<script>
// invoke audio-capture permission prompt
navigator.mozGetUserMedia({audio: true}, function () {}, function () {});
// invoke geolocation permission prompt
navigator.geolocation.getCurrentPosition(function (pos) {});
// invoke desktop-notification prompt
Notification.requestPermission(function (perm) {});
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,7 @@
[DEFAULT]
run-if = toolkit == "gonk"
support-files =
permission_handler_chrome.js
SandboxPromptTest.html
[test_sandbox_permission.html]

Просмотреть файл

@ -0,0 +1,76 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
function debug(str) {
dump("CHROME PERMISSON HANDLER -- " + str + "\n");
}
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const { Services } = Cu.import("resource://gre/modules/Services.jsm");
let browser = Services.wm.getMostRecentWindow("navigator:browser");
let shell;
let test_counts = 0;
function loadShell() {
if (!browser) {
debug("no browser");
return false;
}
shell = browser.shell;
return true;
}
function getContentWindow() {
return shell.contentBrowser.contentWindow;
}
function addChromeEventListener(type, listener) {
let content = getContentWindow();
content.addEventListener("mozChromeEvent", function chromeListener(evt) {
if (!evt.detail || evt.detail.type !== type) {
return;
}
let remove = listener(evt);
if (remove) {
content.removeEventListener("mozChromeEvent", chromeListener);
}
});
}
function checkPromptEvent(prompt_evt) {
let detail = prompt_evt.detail;
if (detail.permission == "audio-capture") {
sendAsyncMessage("permission.granted", "audio-capture");
test_counts--;
} else if (detail.permission == "desktop-notification") {
sendAsyncMessage("permission.granted", "desktop-notification");
test_counts--;
} else if (detail.permission == "geolocation") {
sendAsyncMessage("permission.granted", "geolocation");
test_counts--;
}
if (!test_counts) {
debug("remove prompt event listener.");
return true;
}
return false;
}
if (loadShell()) {
addMessageListener("test.counts", function (counts) {
test_counts = counts;
});
addChromeEventListener("permission-prompt", checkPromptEvent);
}

Просмотреть файл

@ -0,0 +1,78 @@
<!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">
"use strict";
const APP_URL = "SandboxPromptTest.html";
var gUrl = SimpleTest.getTestFileURL("permission_handler_chrome.js");
var gScript = SpecialPowers.loadChromeScript(gUrl);
var gResult = [
{
type: "audio-capture",
prompt: false
},
{
type: "geolocation",
prompt: false
},
{
type: "desktop-notification",
prompt: false
}
];
// Create a sanbox iframe.
function loadBrowser() {
var iframe = document.createElement("iframe");
SpecialPowers.wrap(iframe).mozbrowser = true;
iframe.src = APP_URL;
document.body.appendChild(iframe);
}
// send test counts to chrome script.
gScript.sendAsyncMessage("test.counts", gResult.length);
gScript.addMessageListener("permission.granted", function (aName) {
gResult.forEach(function(aType, aIndex) {
if (aType.type == aName) {
aType.prompt = true;
}
});
if(gResult.every(function(aType) { return aType.prompt; })) {
ok(true, "Get all permission prompts");
gScript.destroy();
SimpleTest.finish();
}});
// 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('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>

Просмотреть файл

@ -5,3 +5,4 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
MOCHITEST_MANIFESTS += ['mochitest/mochitest.ini']

Просмотреть файл

@ -234,7 +234,8 @@ FMRadio::Enabled()
bool
FMRadio::AntennaAvailable() const
{
return mHasInternalAntenna ? true : mHeadphoneState != SWITCH_STATE_OFF;
return mHasInternalAntenna ? true : (mHeadphoneState != SWITCH_STATE_OFF) &&
(mHeadphoneState != SWITCH_STATE_UNKNOWN);
}
Nullable<double>

Просмотреть файл

@ -1,5 +1,6 @@
{
"runtests": {
"b2g": "",
"caps": "",
"content": "",
"docshell": "",

Просмотреть файл

@ -1,5 +1,6 @@
{
"runtests": {
"b2g": "",
"caps": "",
"content": "",
"docshell": "",

Просмотреть файл

@ -1,5 +1,6 @@
{
"runtests": {
"b2g": "",
"caps": "",
"content": "",
"docshell": "",