Bug 952486 - backout for breaking all device and emulator builds (keeping dom reviewer to land the backout...) r=bz

This commit is contained in:
Fabrice Desré 2014-05-26 12:11:52 -07:00
parent 686821ed01
commit bed5c8c262
25 changed files with 306 additions and 142 deletions

View File

@ -1835,6 +1835,11 @@ public:
*/
static bool IsFullscreenApiContentOnly();
/**
* Returns true if the idle observers API is enabled.
*/
static bool IsIdleObserverAPIEnabled() { return sIsIdleObserverAPIEnabled; }
/*
* Returns true if the performance timing APIs are enabled.
*/
@ -2223,6 +2228,7 @@ private:
static bool sTrustedFullScreenOnly;
static bool sFullscreenApiIsContentOnly;
static uint32_t sHandlingInputTimeout;
static bool sIsIdleObserverAPIEnabled;
static bool sIsPerformanceTimingEnabled;
static bool sIsResourceTimingEnabled;

View File

@ -234,6 +234,7 @@ bool nsContentUtils::sInitialized = false;
bool nsContentUtils::sIsFullScreenApiEnabled = false;
bool nsContentUtils::sTrustedFullScreenOnly = true;
bool nsContentUtils::sFullscreenApiIsContentOnly = false;
bool nsContentUtils::sIsIdleObserverAPIEnabled = false;
bool nsContentUtils::sIsPerformanceTimingEnabled = false;
bool nsContentUtils::sIsResourceTimingEnabled = false;
@ -433,6 +434,8 @@ nsContentUtils::Init()
Preferences::AddBoolVarCache(&sTrustedFullScreenOnly,
"full-screen-api.allow-trusted-requests-only");
sIsIdleObserverAPIEnabled = Preferences::GetBool("dom.idle-observers-api.enabled", true);
Preferences::AddBoolVarCache(&sIsPerformanceTimingEnabled,
"dom.enable_performance", true);

View File

@ -661,6 +661,12 @@ Navigator::RefreshMIMEArray()
}
}
bool
Navigator::HasDesktopNotificationSupport()
{
return Preferences::GetBool("notification.feature.enabled", false);
}
namespace {
class VibrateWindowListener : public nsIDOMEventListener
@ -2097,6 +2103,41 @@ Navigator::WrapObject(JSContext* cx)
return NavigatorBinding::Wrap(cx, this);
}
/* static */
bool
Navigator::HasBatterySupport(JSContext* /* unused*/, JSObject* /*unused */)
{
return battery::BatteryManager::HasSupport();
}
/* static */
bool
Navigator::HasPowerSupport(JSContext* /* unused */, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && PowerManager::CheckPermission(win);
}
/* static */
bool
Navigator::HasPhoneNumberSupport(JSContext* /* unused */, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return CheckPermission(win, "phonenumberservice");
}
/* static */
bool
Navigator::HasIdleSupport(JSContext* /* unused */, JSObject* aGlobal)
{
if (!nsContentUtils::IsIdleObserverAPIEnabled()) {
return false;
}
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return CheckPermission(win, "idle");
}
/* static */
bool
Navigator::HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */)
@ -2134,6 +2175,23 @@ Navigator::HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal)
return true;
}
/* static */
bool
Navigator::HasTelephonySupport(JSContext* cx, JSObject* aGlobal)
{
JS::Rooted<JSObject*> global(cx, aGlobal);
// First of all, the general pref has to be turned on.
bool enabled = false;
Preferences::GetBool("dom.telephony.enabled", &enabled);
if (!enabled) {
return false;
}
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(global);
return win && CheckPermission(win, "telephony");
}
/* static */
bool
Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
@ -2142,6 +2200,65 @@ Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
return win && nsDOMCameraManager::CheckPermission(win);
}
#ifdef MOZ_B2G_RIL
/* static */
bool
Navigator::HasMobileConnectionSupport(JSContext* /* unused */,
JSObject* aGlobal)
{
// First of all, the general pref has to be turned on.
bool enabled = false;
Preferences::GetBool("dom.mobileconnection.enabled", &enabled);
NS_ENSURE_TRUE(enabled, false);
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && (CheckPermission(win, "mobileconnection") ||
CheckPermission(win, "mobilenetwork"));
}
/* static */
bool
Navigator::HasCellBroadcastSupport(JSContext* /* unused */,
JSObject* aGlobal)
{
// First of all, the general pref has to be turned on.
bool enabled = false;
Preferences::GetBool("dom.cellbroadcast.enabled", &enabled);
NS_ENSURE_TRUE(enabled, false);
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && CheckPermission(win, "cellbroadcast");
}
/* static */
bool
Navigator::HasVoicemailSupport(JSContext* /* unused */,
JSObject* aGlobal)
{
// First of all, the general pref has to be turned on.
bool enabled = false;
Preferences::GetBool("dom.voicemail.enabled", &enabled);
NS_ENSURE_TRUE(enabled, false);
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && CheckPermission(win, "voicemail");
}
/* static */
bool
Navigator::HasIccManagerSupport(JSContext* /* unused */,
JSObject* aGlobal)
{
// First of all, the general pref has to be turned on.
bool enabled = false;
Preferences::GetBool("dom.icc.enabled", &enabled);
NS_ENSURE_TRUE(enabled, false);
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && CheckPermission(win, "mobileconnection");
}
#endif // MOZ_B2G_RIL
/* static */
bool
Navigator::HasWifiManagerSupport(JSContext* /* unused */,
@ -2162,6 +2279,26 @@ Navigator::HasWifiManagerSupport(JSContext* /* unused */,
return nsIPermissionManager::ALLOW_ACTION == permission;
}
#ifdef MOZ_B2G_BT
/* static */
bool
Navigator::HasBluetoothSupport(JSContext* /* unused */, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && bluetooth::BluetoothManager::CheckPermission(win);
}
#endif // MOZ_B2G_BT
#ifdef MOZ_B2G_FM
/* static */
bool
Navigator::HasFMRadioSupport(JSContext* /* unused */, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && CheckPermission(win, "fmradio");
}
#endif // MOZ_B2G_FM
#ifdef MOZ_NFC
/* static */
bool
@ -2177,6 +2314,22 @@ Navigator::HasNFCSupport(JSContext* /* unused */, JSObject* aGlobal)
return win && (CheckPermission(win, "nfc-read") ||
CheckPermission(win, "nfc-write"));
}
/* static */
bool
Navigator::HasNFCPeerSupport(JSContext* /* unused */, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && CheckPermission(win, "nfc-write");
}
/* static */
bool
Navigator::HasNFCManagerSupport(JSContext* /* unused */, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win && CheckPermission(win, "nfc-manager");
}
#endif // MOZ_NFC
#ifdef MOZ_TIME_MANAGER
@ -2201,6 +2354,16 @@ Navigator::HasUserMediaSupport(JSContext* /* unused */,
}
#endif // MOZ_MEDIA_NAVIGATOR
/* static */
bool
Navigator::HasPushNotificationsSupport(JSContext* /* unused */,
JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return Preferences::GetBool("services.push.enabled", false) &&
win && CheckPermission(win, "push");
}
/* static */
bool
Navigator::HasInputMethodSupport(JSContext* /* unused */,
@ -2308,6 +2471,25 @@ Navigator::HasDataStoreSupport(JSContext* aCx, JSObject* aGlobal)
return HasDataStoreSupport(doc->NodePrincipal());
}
/* static */
bool
Navigator::HasDownloadsSupport(JSContext* aCx, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return win &&
CheckPermission(win, "downloads") &&
Preferences::GetBool("dom.mozDownloads.enabled");
}
/* static */
bool
Navigator::HasPermissionSettingsSupport(JSContext* /* unused */, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
return CheckPermission(win, "permissions");
}
/* static */
bool
Navigator::HasNetworkStatsSupport(JSContext* /* unused */, JSObject* aGlobal)

View File

@ -132,6 +132,8 @@ public:
void RefreshMIMEArray();
static bool HasDesktopNotificationSupport();
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
/**
@ -264,15 +266,44 @@ public:
void GetAcceptLanguages(nsTArray<nsString>& aLanguages);
// WebIDL helper methods
static bool HasBatterySupport(JSContext* /* unused*/, JSObject* /*unused */);
static bool HasPowerSupport(JSContext* /* unused */, JSObject* aGlobal);
static bool HasPhoneNumberSupport(JSContext* /* unused */, JSObject* aGlobal);
static bool HasIdleSupport(JSContext* /* unused */, JSObject* aGlobal);
static bool HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */);
static bool HasDesktopNotificationSupport(JSContext* /* unused*/,
JSObject* /*unused */)
{
return HasDesktopNotificationSupport();
}
static bool HasMobileMessageSupport(JSContext* /* unused */,
JSObject* aGlobal);
static bool HasTelephonySupport(JSContext* cx,
JSObject* aGlobal);
static bool HasCameraSupport(JSContext* /* unused */,
JSObject* aGlobal);
#ifdef MOZ_B2G_RIL
static bool HasMobileConnectionSupport(JSContext* /* unused */,
JSObject* aGlobal);
static bool HasCellBroadcastSupport(JSContext* /* unused */,
JSObject* aGlobal);
static bool HasVoicemailSupport(JSContext* /* unused */,
JSObject* aGlobal);
static bool HasIccManagerSupport(JSContext* /* unused */,
JSObject* aGlobal);
#endif // MOZ_B2G_RIL
static bool HasWifiManagerSupport(JSContext* /* unused */,
JSObject* aGlobal);
#ifdef MOZ_B2G_BT
static bool HasBluetoothSupport(JSContext* /* unused */, JSObject* aGlobal);
#endif // MOZ_B2G_BT
#ifdef MOZ_B2G_FM
static bool HasFMRadioSupport(JSContext* /* unused */, JSObject* aGlobal);
#endif // MOZ_B2G_FM
#ifdef MOZ_NFC
static bool HasNFCSupport(JSContext* /* unused */, JSObject* aGlobal);
static bool HasNFCPeerSupport(JSContext* /* unused */, JSObject* aGlobal);
static bool HasNFCManagerSupport(JSContext* /* unused */, JSObject* aGlobal);
#endif // MOZ_NFC
#ifdef MOZ_TIME_MANAGER
static bool HasTimeSupport(JSContext* /* unused */, JSObject* aGlobal);
@ -282,12 +313,19 @@ public:
JSObject* /* unused */);
#endif // MOZ_MEDIA_NAVIGATOR
static bool HasPushNotificationsSupport(JSContext* /* unused */,
JSObject* aGlobal);
static bool HasInputMethodSupport(JSContext* /* unused */, JSObject* aGlobal);
static bool HasDataStoreSupport(nsIPrincipal* aPrincipal);
static bool HasDataStoreSupport(JSContext* cx, JSObject* aGlobal);
static bool HasDownloadsSupport(JSContext* aCx, JSObject* aGlobal);
static bool HasPermissionSettingsSupport(JSContext* aCx, JSObject* aGlobal);
static bool HasNetworkStatsSupport(JSContext* aCx, JSObject* aGlobal);
static bool HasFeatureDetectionSupport(JSContext* aCx, JSObject* aGlobal);

View File

@ -339,7 +339,6 @@ public:
// public methods
nsPIDOMWindow* GetPrivateParent();
// callback for close event
void ReallyCloseWindow();

View File

@ -8,6 +8,7 @@
#include "Constants.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/Hal.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/BatteryManagerBinding.h"
#include "nsIDOMClassInfo.h"
@ -132,6 +133,12 @@ BatteryManager::Notify(const hal::BatteryInformation& aBatteryInfo)
}
}
/* static */ bool
BatteryManager::HasSupport()
{
return Preferences::GetBool("dom.battery.enabled", true);
}
} // namespace battery
} // namespace dom
} // namespace mozilla

View File

@ -35,6 +35,12 @@ public:
// For IObserver.
void Notify(const hal::BatteryInformation& aBatteryInfo);
/**
* Returns whether the battery api is supported (ie. not disabled by the user)
* @return whether the battery api is supported.
*/
static bool HasSupport();
/**
* WebIDL Interface
*/

View File

@ -20,9 +20,7 @@
#include "jsfriendapi.h"
#include "js/OldDebugAPI.h"
#include "nsContentUtils.h"
#include "nsGlobalWindow.h"
#include "nsIDOMGlobalPropertyInitializer.h"
#include "nsIPermissionManager.h"
#include "nsIPrincipal.h"
#include "nsIXPConnect.h"
#include "WrapperFactory.h"
@ -2230,28 +2228,6 @@ EnumerateGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj)
return JS_EnumerateStandardClasses(aCx, aObj);
}
bool
CheckPermissions(JSContext* aCx, JSObject* aObj, const char* const aPermissions[])
{
JS::Rooted<JSObject*> rootedObj(aCx, aObj);
nsPIDOMWindow* window = xpc::WindowGlobalOrNull(rootedObj);
if (!window) {
return false;
}
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
do {
uint32_t permission = nsIPermissionManager::DENY_ACTION;
permMgr->TestPermissionFromWindow(window, *aPermissions, &permission);
if (permission == nsIPermissionManager::ALLOW_ACTION) {
return true;
}
} while (*(++aPermissions));
return false;
}
bool
GenericBindingGetter(JSContext* cx, unsigned argc, JS::Value* vp)
{

View File

@ -2828,11 +2828,6 @@ AssertReturnTypeMatchesJitinfo(const JSJitInfo* aJitinfo,
JS::Handle<JS::Value> aValue);
#endif
// Returns true if aObj's global has any of the permissions named in aPermissions
// set to nsIPermissionManager::ALLOW_ACTION. aPermissions must be null-terminated.
bool
CheckPermissions(JSContext* aCx, JSObject* aObj, const char* const aPermissions[]);
} // namespace dom
} // namespace mozilla

View File

@ -1797,11 +1797,10 @@ class MemberCondition:
None, they should be strings that have the pref name (for "pref")
or function name (for "func" and "available").
"""
def __init__(self, pref, func, available=None, checkPermissions=None):
def __init__(self, pref, func, available=None):
assert pref is None or isinstance(pref, str)
assert func is None or isinstance(func, str)
assert available is None or isinstance(available, str)
assert checkPermissions is None or isinstance(checkPermissions, int)
self.pref = pref
def toFuncPtr(val):
@ -1810,15 +1809,10 @@ class MemberCondition:
return "&" + val
self.func = toFuncPtr(func)
self.available = toFuncPtr(available)
if checkPermissions is None:
self.checkPermissions = "nullptr"
else:
self.checkPermissions = "permissions_%i" % checkPermissions
def __eq__(self, other):
return (self.pref == other.pref and self.func == other.func and
self.available == other.available and
self.checkPermissions == other.checkPermissions)
self.available == other.available)
def __ne__(self, other):
return not self.__eq__(other)
@ -1881,13 +1875,12 @@ class PropertyDefiner:
return attr[0]
@staticmethod
def getControllingCondition(interfaceMember, descriptor):
def getControllingCondition(interfaceMember):
return MemberCondition(PropertyDefiner.getStringAttr(interfaceMember,
"Pref"),
PropertyDefiner.getStringAttr(interfaceMember,
"Func"),
getAvailableInTestFunc(interfaceMember),
descriptor.checkPermissionsIndicesForMembers.get(interfaceMember.identifier.name))
getAvailableInTestFunc(interfaceMember))
def generatePrefableArray(self, array, name, specTemplate, specTerminator,
specType, getCondition, getDataTuple, doIdArrays):
@ -1919,12 +1912,12 @@ class PropertyDefiner:
# pref control is added to members while still allowing us to define all
# the members in the smallest number of JSAPI calls.
assert len(array) != 0
lastCondition = getCondition(array[0], self.descriptor) # So we won't put a specTerminator
# at the very front of the list.
lastCondition = getCondition(array[0]) # So we won't put a specTerminator
# at the very front of the list.
specs = []
prefableSpecs = []
prefableTemplate = ' { true, %s, %s, %s, &%s[%d] }'
prefableTemplate = ' { true, %s, %s, &%s[%d] }'
prefCacheTemplate = '&%s[%d].enabled'
def switchToCondition(props, condition):
@ -1938,13 +1931,12 @@ class PropertyDefiner:
prefableSpecs.append(prefableTemplate %
(condition.func,
condition.available,
condition.checkPermissions,
name + "_specs", len(specs)))
switchToCondition(self, lastCondition)
for member in array:
curCondition = getCondition(member, self.descriptor)
curCondition = getCondition(member)
if lastCondition != curCondition:
# Terminate previous list
specs.append(specTerminator)
@ -2057,7 +2049,7 @@ class MethodDefiner(PropertyDefiner):
"methodInfo": not m.isStatic(),
"length": methodLength(m),
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(m, descriptor),
"condition": PropertyDefiner.getControllingCondition(m),
"allowCrossOriginThis": m.getExtendedAttribute("CrossOriginCallable"),
"returnsPromise": m.returnsPromise()
}
@ -2085,7 +2077,7 @@ class MethodDefiner(PropertyDefiner):
"nativeName": stringifier.identifier.name,
"length": 0,
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(stringifier, descriptor)
"condition": PropertyDefiner.getControllingCondition(stringifier)
}
if isChromeOnly(stringifier):
self.chrome.append(toStringDesc)
@ -2098,7 +2090,7 @@ class MethodDefiner(PropertyDefiner):
"nativeName": jsonifier.identifier.name,
"length": 0,
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(jsonifier, descriptor)
"condition": PropertyDefiner.getControllingCondition(jsonifier)
}
if isChromeOnly(jsonifier):
self.chrome.append(toJSONDesc)
@ -2128,7 +2120,7 @@ class MethodDefiner(PropertyDefiner):
if len(array) == 0:
return ""
def condition(m, d):
def condition(m):
return m["condition"]
def specData(m):
@ -2720,9 +2712,6 @@ class CGConstructorEnabled(CGAbstractMethod):
availableIn = getAvailableInTestFunc(iface)
if availableIn:
conditions.append("%s(aCx, aObj)" % availableIn)
checkPermissions = self.descriptor.checkPermissionsIndex
if checkPermissions is not None:
conditions.append("CheckPermissions(aCx, aObj, permissions_%i)" % checkPermissions)
# We should really have some conditions
assert len(conditions)
return CGWrapper(CGList((CGGeneric(cond) for cond in conditions),
@ -10279,15 +10268,6 @@ class CGDescriptor(CGThing):
# wants a custom hook.
cgThings.append(CGClassFinalizeHook(descriptor))
if len(descriptor.permissions):
for (k, v) in sorted(descriptor.permissions.items()):
perms = CGList((CGGeneric('"%s",' % p) for p in k), joiner="\n")
perms.append(CGGeneric("nullptr"))
cgThings.append(CGWrapper(CGIndenter(perms),
pre="static const char* const permissions_%i[] = {\n" % v,
post="\n};\n",
defineOnly=True))
properties = PropertyArrays(descriptor)
cgThings.append(CGGeneric(define=str(properties)))
cgThings.append(CGNativeProperties(descriptor, properties))

View File

@ -420,34 +420,6 @@ class Descriptor(DescriptorProvider):
if '__stringifier' not in self.binaryNames:
self.binaryNames["__stringifier"] = "Stringify"
if not self.interface.isExternal():
self.permissions = dict()
# Adds a permission list to this descriptor and returns the index to use.
def addPermissions(ifaceOrMember):
checkPermissions = ifaceOrMember.getExtendedAttribute("CheckPermissions")
if checkPermissions is None:
return None
# It's a list of whitespace-separated strings
assert(len(checkPermissions) is 1)
assert(checkPermissions[0] is not None)
checkPermissions = checkPermissions[0]
permissionsList = checkPermissions.split()
if len(permissionsList) == 0:
raise TypeError("Need at least one permission name for CheckPermissions")
permissionsList = tuple(sorted(set(permissionsList)))
return self.permissions.setdefault(permissionsList, len(self.permissions))
self.checkPermissionsIndex = addPermissions(self.interface)
self.checkPermissionsIndicesForMembers = dict()
for m in self.interface.members:
permissionsIndex = addPermissions(m)
if permissionsIndex is not None:
self.checkPermissionsIndicesForMembers[m.identifier.name] = permissionsIndex
# Build the prototype chain.
self.prototypeChain = []
parent = interface
@ -524,8 +496,7 @@ class Descriptor(DescriptorProvider):
return (self.interface.getExtendedAttribute("Pref") or
self.interface.getExtendedAttribute("ChromeOnly") or
self.interface.getExtendedAttribute("Func") or
self.interface.getExtendedAttribute("AvailableIn") or
self.interface.getExtendedAttribute("CheckPermissions"))
self.interface.getExtendedAttribute("AvailableIn"))
def needsXrayResolveHooks(self):
"""

View File

@ -38,9 +38,6 @@ typedef bool
JS::Handle<JSObject*> obj,
JS::AutoIdVector& props);
bool
CheckPermissions(JSContext* aCx, JSObject* aObj, const char* const aPermissions[]);
struct ConstantSpec
{
const char* name;
@ -55,7 +52,7 @@ struct Prefable {
if (!enabled) {
return false;
}
if (!enabledFunc && !availableFunc && !checkPermissions) {
if (!enabledFunc && !availableFunc) {
return true;
}
// Just go ahead and root obj, in case enabledFunc GCs
@ -68,11 +65,6 @@ struct Prefable {
!availableFunc(cx, js::GetGlobalForObjectCrossCompartment(rootedObj))) {
return false;
}
if (checkPermissions &&
!CheckPermissions(cx, js::GetGlobalForObjectCrossCompartment(rootedObj),
checkPermissions)) {
return false;
}
return true;
}
@ -87,7 +79,6 @@ struct Prefable {
// is basically a hack to avoid having to codegen PropertyEnabled
// implementations in case when we need to do two separate checks.
PropertyEnabled availableFunc;
const char* const* checkPermissions;
// Array of specs, terminated in whatever way is customary for T.
// Null to indicate a end-of-array for Prefable, when such an
// indicator is needed.

View File

@ -1001,8 +1001,7 @@ class IDLInterface(IDLObjectWithScope):
identifier == "HeaderFile" or
identifier == "NavigatorProperty" or
identifier == "AvailableIn" or
identifier == "Func" or
identifier == "CheckPermissions"):
identifier == "Func"):
# Known extended attributes that take a string value
if not attr.hasValue():
raise WebIDLError("[%s] must have a value" % identifier,
@ -2944,8 +2943,7 @@ class IDLAttribute(IDLInterfaceMember):
identifier == "Func" or
identifier == "Frozen" or
identifier == "AvailableIn" or
identifier == "NewObject" or
identifier == "CheckPermissions"):
identifier == "NewObject"):
# Known attributes that we don't need to do anything with here
pass
else:
@ -3522,8 +3520,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
identifier == "AvailableIn" or
identifier == "Pure" or
identifier == "CrossOriginCallable" or
identifier == "WebGLHandlesContextLoss" or
identifier == "CheckPermissions"):
identifier == "WebGLHandlesContextLoss"):
# Known attributes that we don't need to do anything with here
pass
else:

View File

@ -24,4 +24,4 @@ skip-if = toolkit == 'android'
[test_input-manage.html]
skip-if = toolkit == 'android'
[test_wifi-manage.html]
skip-if = (buildapp != 'b2g') || (buildapp == 'b2g' && toolkit != 'gonk') #b2g-desktop(Bug 931116, b2g desktop specific, initial triage)
skip-if = (buildapp != 'b2g') || (buildapp == 'b2g' && toolkit != 'gonk') #b2g-desktop(Bug 931116, b2g desktop specific, initial triage)

View File

@ -22,7 +22,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=674720
"use strict";
var mozPhoneNumberService = window.navigator.mozPhoneNumberService;
ise(mozPhoneNumberService, undefined, "mozPhoneNumberService should not be accessible");
if (mozPhoneNumberService) {
is(mozPhoneNumberService.fuzzyMatch, undefined, "Fuzzy Match should not be accesible");
is(mozPhoneNumberService.normalize, undefined, "Normalize should not be accessible");
}
</script>
</pre>
</body>

View File

@ -182,6 +182,19 @@ PowerManager::SetCpuSleepAllowed(bool aAllowed)
hal::SetCpuSleepAllowed(aAllowed);
}
bool
PowerManager::CheckPermission(nsPIDOMWindow* aWindow)
{
nsCOMPtr<nsIPermissionManager> permMgr =
services::GetPermissionManager();
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission = nsIPermissionManager::DENY_ACTION;
permMgr->TestPermissionFromWindow(aWindow, "power", &permission);
return permission == nsIPermissionManager::ALLOW_ACTION;
}
already_AddRefed<PowerManager>
PowerManager::CreateInstance(nsPIDOMWindow* aWindow)
{

View File

@ -36,6 +36,8 @@ public:
nsresult Init(nsIDOMWindow *aWindow);
nsresult Shutdown();
static bool CheckPermission(nsPIDOMWindow*);
static already_AddRefed<PowerManager> CreateInstance(nsPIDOMWindow*);
// WebIDL

View File

@ -777,7 +777,7 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "PermissionSettings", b2g: true, permission: "permissions"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "PhoneNumberService", permission: "phonenumberservice"},
"PhoneNumberService",
// IMPORTANT: Do not change this list without review from a DOM peer!
"Plugin",
// IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -5,8 +5,7 @@
*/
[Constructor(DOMString type, optional DownloadEventInit eventInitDict),
Pref="dom.mozDownloads.enabled",
CheckPermissions="downloads"]
Func="Navigator::HasDownloadsSupport"]
interface DownloadEvent : Event
{
readonly attribute DOMDownload? download;

View File

@ -19,8 +19,8 @@ enum DownloadState {
//
// XXXTODO: When we have a generic way to do feature detection in marketplace
// we will *STOP* using the pref and use CheckPermissions like
// DOMDownload and DownloadEvent.
// we will *STOP* using the pref and use the function like DOMDownload
// and DownloadEvent.
//
[NoInterfaceObject,
NavigatorProperty="mozDownloadManager",
@ -43,8 +43,7 @@ interface DOMDownloadManager : EventTarget {
};
[JSImplementation="@mozilla.org/downloads/download;1",
Pref="dom.mozDownloads.enabled",
CheckPermissions="downloads"]
Func="Navigator::HasDownloadsSupport"]
interface DOMDownload : EventTarget {
// The full size of the resource.
readonly attribute long long totalBytes;

View File

@ -5,7 +5,7 @@
/* Copyright © 2013 Deutsche Telekom, Inc. */
[NoInterfaceObject,
CheckPermissions="nfc-manager"]
Func="Navigator::HasNFCManagerSupport"]
interface MozNFCManager {
/**
* API to check if the given application's manifest
@ -49,9 +49,9 @@ interface MozNFC : EventTarget {
MozNFCTag getNFCTag(DOMString sessionId);
MozNFCPeer getNFCPeer(DOMString sessionId);
[CheckPermissions="nfc-write"]
[Func="Navigator::HasNFCPeerSupport"]
attribute EventHandler onpeerready;
[CheckPermissions="nfc-write"]
[Func="Navigator::HasNFCPeerSupport"]
attribute EventHandler onpeerlost;
};

View File

@ -114,7 +114,7 @@ Navigator implements NavigatorGeolocation;
interface NavigatorBattery {
// XXXbz Per spec this should be non-nullable, but we return null in
// torn-down windows. See bug 884925.
[Throws, Pref="dom.battery.enabled"]
[Throws, Func="Navigator::HasBatterySupport"]
readonly attribute BatteryManager? battery;
};
Navigator implements NavigatorBattery;
@ -165,7 +165,7 @@ partial interface Navigator {
readonly attribute boolean cookieEnabled;
[Throws]
readonly attribute DOMString buildID;
[Throws, CheckPermissions="power"]
[Throws, Func="Navigator::HasPowerSupport"]
readonly attribute MozPowerManager mozPower;
// WebKit/Blink/Trident/Presto support this.
@ -175,13 +175,13 @@ partial interface Navigator {
/**
* Navigator requests to add an idle observer to the existing window.
*/
[Throws, CheckPermissions="idle", Pref="dom.idle-observers-api.enabled"]
[Throws, Func="Navigator::HasIdleSupport"]
void addIdleObserver(MozIdleObserver aIdleObserver);
/**
* Navigator requests to remove an idle observer from the existing window.
*/
[Throws, CheckPermissions="idle", Pref="dom.idle-observers-api.enabled"]
[Throws, Func="Navigator::HasIdleSupport"]
void removeIdleObserver(MozIdleObserver aIdleObserver);
/**
@ -226,7 +226,7 @@ partial interface Navigator {
// nsIDOMNavigatorDesktopNotification
partial interface Navigator {
[Throws, Pref="notification.feature.enabled"]
[Throws, Func="Navigator::HasDesktopNotificationSupport"]
readonly attribute DesktopNotificationCenter mozNotification;
};
@ -267,30 +267,30 @@ partial interface Navigator {
#ifdef MOZ_B2G_RIL
partial interface Navigator {
[Throws, Pref="dom.mobileconnection.enabled", CheckPermissions="mobileconnection mobilenetwork"]
[Throws, Func="Navigator::HasMobileConnectionSupport"]
readonly attribute MozMobileConnectionArray mozMobileConnections;
};
partial interface Navigator {
[Throws, Pref="dom.cellbroadcast.enabled", CheckPermissions="cellbroadcast"]
[Throws, Func="Navigator::HasCellBroadcastSupport"]
readonly attribute MozCellBroadcast mozCellBroadcast;
};
partial interface Navigator {
[Throws, Pref="dom.voicemail.enabled", CheckPermissions="voicemail"]
[Throws, Func="Navigator::HasVoicemailSupport"]
readonly attribute MozVoicemail mozVoicemail;
};
partial interface Navigator {
[Throws, Pref="dom.icc.enabled", CheckPermissions="mobileconnection"]
[Throws, Func="Navigator::HasIccManagerSupport"]
readonly attribute MozIccManager? mozIccManager;
};
#endif // MOZ_B2G_RIL
partial interface Navigator {
[Throws, Pref="dom.telephony.enabled", CheckPermissions="telephony"]
[Throws, Func="Navigator::HasTelephonySupport"]
readonly attribute Telephony? mozTelephony;
};
#endif // MOZ_B2G_RIL
#ifdef MOZ_GAMEPAD
// https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
@ -302,14 +302,14 @@ partial interface Navigator {
#ifdef MOZ_B2G_BT
partial interface Navigator {
[Throws, CheckPermissions="bluetooth"]
[Throws, Func="Navigator::HasBluetoothSupport"]
readonly attribute BluetoothManager mozBluetooth;
};
#endif // MOZ_B2G_BT
#ifdef MOZ_B2G_FM
partial interface Navigator {
[Throws, CheckPermissions="fmradio"]
[Throws, Func="Navigator::HasFMRadioSupport"]
readonly attribute FMRadio mozFMRadio;
};
#endif // MOZ_B2G_FM

View File

@ -3,7 +3,7 @@
* You can obtain at http://mozilla.org/MPL/2.0/. */
[JSImplementation="@mozilla.org/permissionSettings;1",
CheckPermissions="permissions",
Func="Navigator::HasPermissionSettingsSupport",
Pref="dom.mozPermissionSettings.enabled",
NavigatorProperty="mozPermissionSettings"]
interface PermissionSettings

View File

@ -4,12 +4,13 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[JSImplementation="@mozilla.org/phoneNumberService;1",
NavigatorProperty="mozPhoneNumberService",
CheckPermissions="phonenumberservice"]
[JSImplementation="@mozilla.org/phoneNumberService;1", NavigatorProperty="mozPhoneNumberService"]
interface PhoneNumberService {
[Func="Navigator::HasPhoneNumberSupport"]
DOMRequest fuzzyMatch([TreatNullAs=EmptyString] optional DOMString number1 = "",
[TreatNullAs=EmptyString] optional DOMString number2= "");
[Func="Navigator::HasPhoneNumberSupport"]
DOMString normalize(DOMString number);
};

View File

@ -4,11 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[NoInterfaceObject,
NavigatorProperty="push",
JSImplementation="@mozilla.org/push/PushManager;1",
CheckPermissions="push",
Pref="services.push.enabled"]
[NoInterfaceObject, NavigatorProperty="push", JSImplementation="@mozilla.org/push/PushManager;1", Func="Navigator::HasPushNotificationsSupport"]
interface PushManager {
DOMRequest register();
DOMRequest unregister(DOMString pushEndpoint);