mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 674725 - Part F - .mozSms returns null if the platform doesn't have SMS supports. r=smaug
This commit is contained in:
parent
a5b38c8672
commit
5360a9e5d5
@ -70,6 +70,7 @@
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "BatteryManager.h"
|
||||
#include "SmsManager.h"
|
||||
#include "nsISmsService.h"
|
||||
|
||||
// This should not be in the namespace.
|
||||
DOMCI_DATA(Navigator, mozilla::dom::Navigator)
|
||||
@ -835,11 +836,23 @@ Navigator::IsSmsAllowed() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
Navigator::IsSmsSupported() const
|
||||
{
|
||||
nsCOMPtr<nsISmsService> smsService = do_GetService(SMSSERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(smsService, false);
|
||||
|
||||
bool result = false;
|
||||
smsService->HasSupport(&result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetMozSms(nsIDOMMozSmsManager** aSmsManager)
|
||||
{
|
||||
if (!mSmsManager) {
|
||||
if (!IsSmsAllowed()) {
|
||||
if (!IsSmsSupported() || !IsSmsAllowed()) {
|
||||
*aSmsManager = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
|
||||
private:
|
||||
bool IsSmsAllowed() const;
|
||||
bool IsSmsSupported() const;
|
||||
|
||||
static bool sDoNotTrackEnabled;
|
||||
|
||||
|
@ -37,11 +37,12 @@
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
#define NS_SMSSERVICE_CID { 0xd2d16fd7, 0x291e, 0x4dee, { 0xa2, 0xbf, 0x47, 0x75, 0xe5, 0x2e, 0xc3, 0xb3 } }
|
||||
#define NS_SMSSERVICE_CID { 0xbada3cb8, 0xa568, 0x4dff, { 0xb5, 0x43, 0x52, 0xbb, 0xb3, 0x14, 0x31, 0x21 } }
|
||||
#define SMSSERVICE_CONTRACTID "@mozilla.org/sms/smsservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, function, uuid(37bde671-23be-4713-9487-2e9e606c1ae4)]
|
||||
[scriptable, function, uuid(abc95960-c689-4985-a226-7c96d27e2cd8)]
|
||||
interface nsISmsService : nsISupports
|
||||
{
|
||||
boolean hasSupport();
|
||||
};
|
||||
|
@ -43,6 +43,13 @@ namespace sms {
|
||||
|
||||
NS_IMPL_ISUPPORTS1(SmsService, nsISmsService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsService::HasSupport(bool* aHasSupport)
|
||||
{
|
||||
*aHasSupport = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -43,6 +43,13 @@ namespace sms {
|
||||
|
||||
NS_IMPL_ISUPPORTS1(SmsService, nsISmsService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsService::HasSupport(bool* aHasSupport)
|
||||
{
|
||||
*aHasSupport = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -21,6 +21,12 @@ function checkSmsDisabled() {
|
||||
}
|
||||
|
||||
function checkSmsEnabled() {
|
||||
// WebSms is disabled on all platforms except Android for the moment.
|
||||
if (navigator.appVersion.indexOf("Android") == -1) {
|
||||
checkSmsDisabled();
|
||||
return;
|
||||
}
|
||||
|
||||
ok('mozSms' in frames[0].navigator, "navigator.mozSms should exist");
|
||||
ok(frames[0].navigator.mozSms, "navigator.mozSms returns an object");
|
||||
ok(frames[0].navigator.mozSms instanceof MozSmsManager, "navigator.mozSms is an SmsManager object");
|
||||
|
Loading…
Reference in New Issue
Block a user