Bug 701517 - Moz-prefix Battery API interfaces. rs+sr=smaug

This commit is contained in:
Mounir Lamouri 2011-11-19 11:43:57 +01:00
parent 5dc1f60bf2
commit 268955b4c5
9 changed files with 26 additions and 20 deletions

View File

@ -113,7 +113,7 @@ NS_INTERFACE_MAP_BEGIN(Navigator)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigator)
NS_INTERFACE_MAP_ENTRY(nsIDOMClientInformation)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorGeolocation)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorBattery)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozNavigatorBattery)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorDesktopNotification)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator)
NS_INTERFACE_MAP_END
@ -746,7 +746,7 @@ NS_IMETHODIMP Navigator::GetMozNotification(nsIDOMDesktopNotificationCenter** aR
//*****************************************************************************
NS_IMETHODIMP
Navigator::GetMozBattery(nsIDOMBatteryManager** aBattery)
Navigator::GetMozBattery(nsIDOMMozBatteryManager** aBattery)
{
if (!mBatteryManager) {
*aBattery = nsnull;

View File

@ -71,7 +71,7 @@ class Navigator : public nsIDOMNavigator,
public nsIDOMClientInformation,
public nsIDOMNavigatorGeolocation,
public nsIDOMNavigatorDesktopNotification,
public nsIDOMNavigatorBattery
public nsIDOMMozNavigatorBattery
{
public:
Navigator(nsIDocShell *aDocShell);
@ -82,7 +82,7 @@ public:
NS_DECL_NSIDOMCLIENTINFORMATION
NS_DECL_NSIDOMNAVIGATORGEOLOCATION
NS_DECL_NSIDOMNAVIGATORDESKTOPNOTIFICATION
NS_DECL_NSIDOMNAVIGATORBATTERY
NS_DECL_NSIDOMMOZNAVIGATORBATTERY
static void Init();

View File

@ -1385,7 +1385,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(BatteryManager, nsDOMGenericSH,
NS_DEFINE_CLASSINFO_DATA(MozBatteryManager, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
@ -2287,7 +2287,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMNavigatorDesktopNotification,
Navigator::HasDesktopNotificationSupport())
DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMNavigatorBattery,
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMMozNavigatorBattery,
battery::BatteryManager::HasSupport())
DOM_CLASSINFO_MAP_END
@ -3866,8 +3866,8 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(BatteryManager, nsIDOMBatteryManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBatteryManager)
DOM_CLASSINFO_MAP_BEGIN(MozBatteryManager, nsIDOMMozBatteryManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBatteryManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END

View File

@ -426,7 +426,7 @@ DOMCI_CLASS(GeoPositionCoords)
DOMCI_CLASS(GeoPositionAddress)
DOMCI_CLASS(GeoPositionError)
DOMCI_CLASS(BatteryManager)
DOMCI_CLASS(MozBatteryManager)
// @font-face in CSS
DOMCI_CLASS(CSSFontFaceRule)

View File

@ -52,7 +52,7 @@
#define DISCHARGINGTIMECHANGE_EVENT_NAME NS_LITERAL_STRING("dischargingtimechange")
#define CHARGINGTIMECHANGE_EVENT_NAME NS_LITERAL_STRING("chargingtimechange")
DOMCI_DATA(BatteryManager, mozilla::dom::battery::BatteryManager)
DOMCI_DATA(MozBatteryManager, mozilla::dom::battery::BatteryManager)
namespace mozilla {
namespace dom {
@ -77,8 +77,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BatteryManager,
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BatteryManager)
NS_INTERFACE_MAP_ENTRY(nsIDOMBatteryManager)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BatteryManager)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozBatteryManager)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozBatteryManager)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache)
NS_IMPL_ADDREF_INHERITED(BatteryManager, nsDOMEventTargetWrapperCache)

View File

@ -57,12 +57,12 @@ namespace dom {
namespace battery {
class BatteryManager : public nsDOMEventTargetWrapperCache
, public nsIDOMBatteryManager
, public nsIDOMMozBatteryManager
, public BatteryObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMBATTERYMANAGER
NS_DECL_NSIDOMMOZBATTERYMANAGER
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetWrapperCache::)
BatteryManager();

View File

@ -38,8 +38,8 @@
interface nsIDOMEventListener;
[scriptable, function, uuid(6dcb803b-e968-4c02-88f5-049a3f2a2efb)]
interface nsIDOMBatteryManager : nsIDOMEventTarget
[scriptable, function, uuid(98b6237b-9654-43de-97e0-acf4b091b4e7)]
interface nsIDOMMozBatteryManager : nsIDOMEventTarget
{
readonly attribute double level;
readonly attribute boolean charging;

View File

@ -36,10 +36,10 @@
#include "nsISupports.idl"
interface nsIDOMBatteryManager;
interface nsIDOMMozBatteryManager;
[scriptable, uuid(a19eedd7-6c26-4676-bd34-7ca74ca5f565)]
interface nsIDOMNavigatorBattery : nsISupports
[scriptable, uuid(c295f049-be3d-4f83-9f7c-5c3e91d6ecb9)]
interface nsIDOMMozNavigatorBattery : nsISupports
{
readonly attribute nsIDOMBatteryManager mozBattery;
readonly attribute nsIDOMMozBatteryManager mozBattery;
};

View File

@ -14,6 +14,12 @@
/** Test for Battery API **/
// Testing prefixing.
ok(!("NavigatorBattery" in window), "NavigatorBattery shouldn't be visible");
ok(("MozNavigatorBattery" in window), "MozNavigatorBattery should be visible");
ok(!("BatteryManager" in window), "BatteryManager shouldn't be visible");
ok(("MozBatteryManager" in window), "MozBatteryManager should be visible");
ok('mozBattery' in navigator, "navigator.mozBattery should exist");
var battery = navigator.mozBattery;