Merge b2g to m-c

This commit is contained in:
Wes Kocher 2014-05-08 19:06:08 -07:00
commit 8429138f06
41 changed files with 94 additions and 627 deletions

View File

@ -144,8 +144,7 @@ let AlertsHelper = {
lang: listener.lang,
dir: listener.dir,
id: listener.id,
tag: listener.tag,
timestamp: listener.timestamp
tag: listener.tag
},
Services.io.newURI(listener.target, null, null),
Services.io.newURI(listener.manifestURL, null, null)
@ -195,7 +194,7 @@ let AlertsHelper = {
},
showNotification: function(imageURL, title, text, textClickable, cookie,
uid, bidi, lang, manifestURL, timestamp) {
uid, bidi, lang, manifestURL) {
function send(appName, appIcon) {
SystemAppProxy._sendCustomEvent(kMozChromeNotificationEvent, {
type: kDesktopNotification,
@ -207,8 +206,7 @@ let AlertsHelper = {
lang: lang,
appName: appName,
appIcon: appIcon,
manifestURL: manifestURL,
timestamp: timestamp
manifestURL: manifestURL
});
}
@ -250,13 +248,12 @@ let AlertsHelper = {
lang: details.lang || undefined,
id: details.id || undefined,
dir: details.dir || undefined,
tag: details.tag || undefined,
timestamp: details.timestamp || undefined
tag: details.tag || undefined
};
this.registerAppListener(data.uid, listener);
this.showNotification(data.imageURL, data.title, data.text,
details.textClickable, null, data.uid, details.dir,
details.lang, details.manifestURL, details.timestamp);
details.lang, details.manifestURL);
},
closeAlert: function(name) {

View File

@ -43,7 +43,6 @@ const kMessageAlertNotificationSend = "alert-notification-send";
const kMessageAlertNotificationClose = "alert-notification-close";
const kTopicAlertFinished = "alertfinished";
const kTopicAlertClickCallback = "alertclickcallback";
function AlertsService() {
Services.obs.addObserver(this, "xpcom-shutdown", false);
@ -104,8 +103,7 @@ AlertsService.prototype = {
id: aDetails.id || undefined,
dbId: aDetails.dbId || undefined,
dir: aDetails.dir || undefined,
tag: aDetails.tag || undefined,
timestamp: aDetails.timestamp || undefined
tag: aDetails.tag || undefined
};
cpmm.sendAsyncMessage(kMessageAppNotificationSend, {
@ -137,7 +135,6 @@ AlertsService.prototype = {
// the notification so the app get a change to react.
if (data.target) {
gSystemMessenger.sendMessage(kNotificationSystemMessageName, {
clicked: (topic === kTopicAlertClickCallback),
title: listener.title,
body: listener.text,
imageURL: listener.imageURL,
@ -145,8 +142,7 @@ AlertsService.prototype = {
dir: listener.dir,
id: listener.id,
tag: listener.tag,
dbId: listener.dbId,
timestamp: listener.timestamp
dbId: listener.dbId
},
Services.io.newURI(data.target, null, null),
Services.io.newURI(listener.manifestURL, null, null)

View File

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="ca283b9db2b151d465cfd2e19346cf58fe89e413"/>

View File

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="3691614d0045f7968addce45d4140fb360c3ceaf"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="65fba428f8d76336b33ddd9e15900357953600ba">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>

View File

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="ca283b9db2b151d465cfd2e19346cf58fe89e413"/>

View File

@ -18,7 +18,7 @@
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="3691614d0045f7968addce45d4140fb360c3ceaf"/>

View File

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "fbf868517b3026b39be4afac45883ddf76f6bc9d",
"revision": "5476e49adf00cafde6cb68e876f0514dac4b993d",
"repo_path": "/integration/gaia-central"
}

View File

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -15,7 +15,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="3691614d0045f7968addce45d4140fb360c3ceaf"/>

View File

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f4eb209f9c425692cda9230a9fd669f8f76a1c68"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="15ac34804eb8b3c9b2582d7cf754c57e23182df6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f313e6d3aaaefe8c82eaed15912a09b120fb7260"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>

View File

@ -336,8 +336,6 @@
@BINPATH@/components/zipwriter.xpt
; JavaScript components
@BINPATH@/components/ChromeNotifications.js
@BINPATH@/components/ChromeNotifications.manifest
@BINPATH@/components/ConsoleAPI.manifest
@BINPATH@/components/ConsoleAPIStorage.js
@BINPATH@/components/BrowserElementParent.manifest

View File

@ -344,8 +344,6 @@
@BINPATH@/components/telemetry.xpt
; JavaScript components
@BINPATH@/components/ChromeNotifications.js
@BINPATH@/components/ChromeNotifications.manifest
@BINPATH@/components/ConsoleAPI.manifest
@BINPATH@/components/ConsoleAPIStorage.js
@BINPATH@/components/BrowserElementParent.manifest

View File

@ -14,7 +14,6 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/Assertions.h"
#include "mozilla/Preferences.h"
#include "AccessCheck.h"
#include "jsfriendapi.h"
@ -2156,10 +2155,6 @@ ConvertJSValueToByteString(JSContext* cx, JS::Handle<JS::Value> v,
bool
IsInPrivilegedApp(JSContext* aCx, JSObject* aObj)
{
if (Preferences::GetBool("dom.ignore_webidl_scope_checks", false)) {
return true;
}
using mozilla::dom::workers::GetWorkerPrivateFromContext;
if (!NS_IsMainThread()) {
return GetWorkerPrivateFromContext(aCx)->IsInPrivilegedApp();
@ -2174,10 +2169,6 @@ IsInPrivilegedApp(JSContext* aCx, JSObject* aObj)
bool
IsInCertifiedApp(JSContext* aCx, JSObject* aObj)
{
if (Preferences::GetBool("dom.ignore_webidl_scope_checks", false)) {
return true;
}
using mozilla::dom::workers::GetWorkerPrivateFromContext;
if (!NS_IsMainThread()) {
return GetWorkerPrivateFromContext(aCx)->IsInCertifiedApp();

View File

@ -39,7 +39,7 @@ interface nsINotificationStorageCallback : nsISupports
/**
* Interface for notification persistence layer.
*/
[scriptable, uuid(cc4656d7-2a2a-47f1-8016-55891e833d64)]
[scriptable, uuid(b177b080-2a23-11e3-8224-0800200c9a66)]
interface nsINotificationStorage : nsISupports
{
@ -55,10 +55,6 @@ interface nsINotificationStorage : nsISupports
* @param body: the notification body
* @param tag: notification tag, will replace any existing
* notifications with same origin/tag pair
* @param alertName: the alert identifier as used by system app.
* Stored in the database to avoid re-computing
* it. Built from origin and tag or id depending
* whether there is a tag defined.
*/
void put(in DOMString origin,
in DOMString id,
@ -67,8 +63,7 @@ interface nsINotificationStorage : nsISupports
in DOMString lang,
in DOMString body,
in DOMString tag,
in DOMString icon,
in DOMString alertName);
in DOMString icon);
/**
* Retrieve a list of notifications.

View File

@ -1,113 +0,0 @@
/* 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";
const DEBUG = false;
function debug(s) {
dump("-*- ChromeNotifications.js: " + s + "\n");
}
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
XPCOMUtils.defineLazyServiceGetter(this, "appNotifier",
"@mozilla.org/system-alerts-service;1",
"nsIAppNotificationService");
const CHROMENOTIFICATIONS_CID = "{74f94093-8b37-497e-824f-c3b250a911da}";
const CHROMENOTIFICATIONS_CONTRACTID = "@mozilla.org/mozChromeNotifications;1";
function ChromeNotifications() {
this.innerWindowID = null;
this.resendCallback = null;
}
ChromeNotifications.prototype = {
init: function(aWindow) {
let util = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
this.innerWindowID = util.currentInnerWindowID;
Services.obs.addObserver(this, "inner-window-destroyed", false);
cpmm.addMessageListener("Notification:GetAllCrossOrigin:Return:OK", this);
},
performResend: function(notifications) {
let resentNotifications = 0;
notifications.forEach(function(notification) {
appNotifier.showAppNotification(
notification.icon,
notification.title,
notification.body,
null,
{
manifestURL: notification.origin,
id: notification.alertName,
dir: notification.dir,
lang: notification.lang,
tag: notification.tag,
dbId: notification.id,
timestamp: notification.timestamp
}
);
resentNotifications++;
});
try {
this.resendCallback && this.resendCallback(resentNotifications);
} catch (ex) {
if (DEBUG) debug("Content sent exception: " + ex);
}
},
mozResendAllNotifications: function(resendCallback) {
this.resendCallback = resendCallback;
cpmm.sendAsyncMessage("Notification:GetAllCrossOrigin", {});
},
receiveMessage: function(message) {
switch (message.name) {
case "Notification:GetAllCrossOrigin:Return:OK":
this.performResend(message.data.notifications);
break;
default:
if (DEBUG) { debug("Unrecognized message: " + message.name); }
break;
}
},
observe: function(aSubject, aTopic, aData) {
if (DEBUG) debug("Topic: " + aTopic);
if (aTopic == "inner-window-destroyed") {
let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
if (wId != this.innerWindowID) {
return;
}
Services.obs.removeObserver(this, "inner-window-destroyed");
cpmm.removeMessageListener("Notification:GetAllCrossOrigin:Return:OK", this);
}
},
classID : Components.ID(CHROMENOTIFICATIONS_CID),
contractID : CHROMENOTIFICATIONS_CONTRACTID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIChromeNotifications,
Ci.nsIDOMGlobalPropertyInitializer,
Ci.nsIObserver,
Ci.nsIMessageListener]),
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ChromeNotifications]);

View File

@ -1,3 +0,0 @@
# ChromeNotifications.js
component {74f94093-8b37-497e-824f-c3b250a911da} ChromeNotifications.js
contract @mozilla.org/mozChromeNotifications;1 {74f94093-8b37-497e-824f-c3b250a911da}

View File

@ -423,22 +423,6 @@ Notification::Notification(const nsAString& aID, const nsAString& aTitle, const
mID(aID), mTitle(aTitle), mBody(aBody), mDir(aDir), mLang(aLang),
mTag(aTag), mIconUrl(aIconUrl), mIsClosed(false)
{
nsAutoString alertName;
DebugOnly<nsresult> rv = GetOrigin(GetOwner(), alertName);
MOZ_ASSERT(NS_SUCCEEDED(rv), "GetOrigin should not have failed");
// Get the notification name that is unique per origin + tag/ID.
// The name of the alert is of the form origin#tag/ID.
alertName.AppendLiteral("#");
if (!mTag.IsEmpty()) {
alertName.Append(NS_LITERAL_STRING("tag:"));
alertName.Append(mTag);
} else {
alertName.Append(NS_LITERAL_STRING("notag:"));
alertName.Append(mID);
}
mAlertName = alertName;
}
// static
@ -478,10 +462,6 @@ Notification::Constructor(const GlobalObject& aGlobal,
nsString id;
notification->GetID(id);
nsString alertName;
notification->GetAlertName(alertName);
aRv = notificationStorage->Put(origin,
id,
aTitle,
@ -489,8 +469,7 @@ Notification::Constructor(const GlobalObject& aGlobal,
aOptions.mLang,
aOptions.mBody,
aOptions.mTag,
aOptions.mIcon,
alertName);
aOptions.mIcon);
if (aRv.Failed()) {
return nullptr;
}
@ -578,6 +557,10 @@ Notification::ShowInternal()
nsCOMPtr<nsIObserver> observer = new NotificationObserver(this);
nsString alertName;
rv = GetAlertName(alertName);
NS_ENSURE_SUCCESS_VOID(rv);
#ifdef MOZ_B2G
nsCOMPtr<nsIAppNotificationService> appNotifier =
do_GetService("@mozilla.org/system-alerts-service;1");
@ -595,7 +578,7 @@ Notification::ShowInternal()
AppNotificationServiceOptions ops;
ops.mTextClickable = true;
ops.mManifestURL = manifestUrl;
ops.mId = mAlertName;
ops.mId = alertName;
ops.mDbId = mID;
ops.mDir = DirectionToString(mDir);
ops.mLang = mLang;
@ -619,7 +602,7 @@ Notification::ShowInternal()
nsString uniqueCookie = NS_LITERAL_STRING("notification:");
uniqueCookie.AppendInt(sCount++);
alertService->ShowAlertNotification(absoluteUrl, mTitle, mBody, true,
uniqueCookie, observer, mAlertName,
uniqueCookie, observer, alertName,
DirectionToString(mDir), mLang,
GetPrincipal());
}
@ -788,8 +771,10 @@ Notification::CloseInternal()
nsCOMPtr<nsIAlertsService> alertService =
do_GetService(NS_ALERTSERVICE_CONTRACTID);
if (alertService) {
nsString alertName;
rv = GetAlertName(alertName);
if (NS_SUCCEEDED(rv)) {
alertService->CloseAlert(mAlertName, GetPrincipal());
alertService->CloseAlert(alertName, GetPrincipal());
}
}
}
@ -827,6 +812,24 @@ Notification::GetOrigin(nsPIDOMWindow* aWindow, nsString& aOrigin)
return NS_OK;
}
nsresult
Notification::GetAlertName(nsString& aAlertName)
{
// Get the notification name that is unique per origin + tag/ID.
// The name of the alert is of the form origin#tag/ID.
nsresult rv = GetOrigin(GetOwner(), aAlertName);
NS_ENSURE_SUCCESS(rv, rv);
aAlertName.AppendLiteral("#");
if (!mTag.IsEmpty()) {
aAlertName.Append(NS_LITERAL_STRING("tag:"));
aAlertName.Append(mTag);
} else {
aAlertName.Append(NS_LITERAL_STRING("notag:"));
aAlertName.Append(mID);
}
return NS_OK;
}
} // namespace dom
} // namespace mozilla

View File

@ -133,10 +133,7 @@ protected:
static nsresult GetOrigin(nsPIDOMWindow* aWindow, nsString& aOrigin);
void GetAlertName(nsAString& aRetval)
{
aRetval = mAlertName;
}
nsresult GetAlertName(nsString& aAlertName);
nsString mID;
nsString mTitle;
@ -146,8 +143,6 @@ protected:
nsString mTag;
nsString mIconUrl;
nsString mAlertName;
bool mIsClosed;
static uint32_t sCount;

View File

@ -16,9 +16,6 @@ const Ci = Components.interfaces;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageListenerManager");
@ -36,23 +33,8 @@ const NOTIFICATION_STORE_DIR = OS.Constants.Path.profileDir;
const NOTIFICATION_STORE_PATH =
OS.Path.join(NOTIFICATION_STORE_DIR, "notificationstore.json");
const kMessages = [
"Notification:Save",
"Notification:Delete",
"Notification:GetAll",
"Notification:GetAllCrossOrigin"
];
let NotificationDB = {
// Ensure we won't call init() while xpcom-shutdown is performed
_shutdownInProgress: false,
init: function() {
if (this._shutdownInProgress) {
return;
}
this.notifications = {};
this.byTag = {};
this.loaded = false;
@ -60,29 +42,9 @@ let NotificationDB = {
this.tasks = []; // read/write operation queue
this.runningTask = false;
Services.obs.addObserver(this, "xpcom-shutdown", false);
this.registerListeners();
},
registerListeners: function() {
for (let message of kMessages) {
ppmm.addMessageListener(message, this);
}
},
unregisterListeners: function() {
for (let message of kMessages) {
ppmm.removeMessageListener(message, this);
}
},
observe: function(aSubject, aTopic, aData) {
if (DEBUG) debug("Topic: " + aTopic);
if (aTopic == "xpcom-shutdown") {
this._shutdownInProgress = true;
Services.obs.removeObserver(this, "xpcom-shutdown");
this.unregisterListeners();
}
ppmm.addMessageListener("Notification:Save", this);
ppmm.addMessageListener("Notification:Delete", this);
ppmm.addMessageListener("Notification:GetAll", this);
},
// Attempt to read notification file, if it's not there we will create it.
@ -198,15 +160,6 @@ let NotificationDB = {
});
break;
case "Notification:GetAllCrossOrigin":
this.queueTask("getallaccrossorigin", message.data,
function(notifications) {
returnMessage("Notification:GetAllCrossOrigin:Return:OK", {
notifications: notifications
});
});
break;
case "Notification:Save":
this.queueTask("save", message.data, function() {
returnMessage("Notification:Save:Return:OK", {
@ -240,14 +193,14 @@ let NotificationDB = {
// Only run immediately if we aren't currently running another task.
if (!this.runningTask) {
if (DEBUG) { debug("Task queue was not running, starting now..."); }
if (DEBUG) { dump("Task queue was not running, starting now..."); }
this.runNextTask();
}
},
runNextTask: function() {
if (this.tasks.length === 0) {
if (DEBUG) { debug("No more tasks to run, queue depleted"); }
if (DEBUG) { dump("No more tasks to run, queue depleted"); }
this.runningTask = false;
return;
}
@ -270,10 +223,6 @@ let NotificationDB = {
this.taskGetAll(task.data, wrappedCallback);
break;
case "getallaccrossorigin":
this.taskGetAllCrossOrigin(wrappedCallback);
break;
case "save":
this.taskSave(task.data, wrappedCallback);
break;
@ -296,27 +245,6 @@ let NotificationDB = {
callback(notifications);
},
taskGetAllCrossOrigin: function(callback) {
if (DEBUG) { debug("Task, getting all whatever origin"); }
var notifications = [];
for (var origin in this.notifications) {
for (var i in this.notifications[origin]) {
var notification = this.notifications[origin][i];
// Notifications without the alertName field cannot be resent by
// mozResendAllNotifications, so we just skip them. They will
// still be available to applications via Notification.get()
if (!('alertName' in notification)) {
continue;
}
notification.origin = origin;
notifications.push(notification);
}
}
callback(notifications);
},
taskSave: function(data, callback) {
if (DEBUG) { debug("Task, saving"); }
var origin = data.origin;

View File

@ -36,7 +36,7 @@ function NotificationStorage() {
NotificationStorage.prototype = {
put: function(origin, id, title, dir, lang, body, tag, icon, alertName) {
put: function(origin, id, title, dir, lang, body, tag, icon) {
if (DEBUG) { debug("PUT: " + id + ": " + title); }
var notification = {
id: id,
@ -45,9 +45,7 @@ NotificationStorage.prototype = {
lang: lang,
body: body,
tag: tag,
icon: icon,
alertName: alertName,
timestamp: new Date().getTime()
icon: icon
};
this._notifications[id] = notification;

View File

@ -5,8 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_COMPONENTS += [
'ChromeNotifications.js',
'ChromeNotifications.manifest',
'NotificationStorage.js',
'NotificationStorage.manifest',
]

View File

@ -336,116 +336,3 @@ add_test(function test_send_two_get_two() {
requestID: (requestID + 1) // 21
});
});
// Cleanup previous notification
add_test(function test_delete_previous() {
let requestID = 25;
let msgReply = "Notification:Delete:Return:OK";
let msgHandler = function(message) {
do_check_eq(requestID, message.data.requestID);
};
addAndSend("Notification:Delete", msgReply, msgHandler, {
origin: systemNotification.origin,
id: "{8ef9a628-f0f4-44b4-820d-c117573c33e3}",
requestID: requestID
});
});
// Store two notifications, one without alertName and one with
add_test(function test_send_two_alertName() {
let requestID = 30;
let notifications = [
{
origin: "app://system.gaiamobile.org/manifest.webapp",
id: "{27ead857-4f43-457f-a770-93b82fbfc223}",
title: "Notification title",
dir: "auto",
lang: "",
body: "Notification body",
tag: "",
icon: "icon.png",
timestamp: new Date().getTime()
}, {
origin: "app://system.gaiamobile.org/manifest.webapp",
id: "{40275e04-58d0-47be-8cc7-540578f793a4}",
title: "Notification title",
dir: "auto",
lang: "",
body: "Notification body",
tag: "",
icon: "icon.png",
alertName: "alertName",
timestamp: new Date().getTime()
}
];
let origin = notifications[0].origin;
let msgGetCrossOriginReply = "Notification:GetAllCrossOrigin:Return:OK";
let msgGetCrossOriginHandler = {
receiveMessage: function(message) {
if (message.name === msgGetCrossOriginReply) {
cpmm.removeMessageListener(
msgGetCrossOriginReply, msgGetCrossOriginHandler);
let gotNotifications = message.data.notifications;
// we expect to have one notification
do_check_eq(1, gotNotifications.length);
// compare the only notification we should have got back
compareNotification(gotNotifications[0], notifications[1]);
run_next_test();
}
}
};
cpmm.addMessageListener(msgGetCrossOriginReply, msgGetCrossOriginHandler);
let msgGetReply = "Notification:GetAll:Return:OK";
let msgGetHandler = {
receiveMessage: function(message) {
if (message.name === msgGetReply) {
cpmm.removeMessageListener(msgGetReply, msgGetHandler);
let gotNotifications = message.data.notifications;
// we expect to have two notifications
do_check_eq(2, gotNotifications.length);
// compare each notification
for (let i = 0; i < gotNotifications.length; i++) {
compareNotification(gotNotifications[i], notifications[i]);
}
run_next_test();
}
}
};
cpmm.addMessageListener(msgGetReply, msgGetHandler);
let msgSaveReply = "Notification:Save:Return:OK";
let msgSaveCalls = 0;
let msgSaveHandler = {
receiveMessage: function(message) {
if (message.name === msgSaveReply) {
msgSaveCalls++;
if (msgSaveCalls === 2) {
cpmm.removeMessageListener(msgSaveReply, msgSaveHandler);
// Trigger getall
cpmm.sendAsyncMessage("Notification:GetAll", {
origin: origin
});
}
}
}
};
cpmm.addMessageListener(msgSaveReply, msgSaveHandler);
notifications.forEach(function(n) {
cpmm.sendAsyncMessage("Notification:Save", {
origin: origin,
notification: n
});
});
});

View File

@ -12,66 +12,41 @@ var MockServices = (function () {
var registrar = SpecialPowers.wrap(SpecialPowers.Components).manager
.QueryInterface(SpecialPowers.Ci.nsIComponentRegistrar);
var activeAlertNotifications = Object.create(null);
var activeAppNotifications = Object.create(null);
var activeNotifications = Object.create(null);
var mockAlertsService = {
showAlertNotification: function(imageUrl, title, text, textClickable,
cookie, alertListener, name) {
var listener = SpecialPowers.wrap(alertListener);
activeAlertNotifications[name] = {
activeNotifications[name] = {
listener: listener,
cookie: cookie
};
// fake async alert show event
if (listener) {
setTimeout(function () {
listener.observe(null, "alertshow", cookie);
}, 100);
}
setTimeout(function () {
listener.observe(null, "alertshow", cookie);
}, 100);
// ?? SpecialPowers.wrap(alertListener).observe(null, "alertclickcallback", cookie);
},
showAppNotification: function(aImageUrl, aTitle, aText, aAlertListener, aDetails) {
var listener = aAlertListener || (activeAlertNotifications[aDetails.id] ? activeAlertNotifications[aDetails.id].listener : undefined);
activeAppNotifications[aDetails.id] = {
observer: listener,
title: aTitle,
text: aText,
manifestURL: aDetails.manifestURL,
imageURL: aImageUrl,
lang: aDetails.lang || undefined,
id: aDetails.id || undefined,
dbId: aDetails.dbId || undefined,
dir: aDetails.dir || undefined,
tag: aDetails.tag || undefined,
timestamp: aDetails.timestamp || undefined
};
this.showAlertNotification(aImageUrl, aTitle, aText, true, "", listener, aDetails.id);
showAppNotification: function(imageUrl, title, text, textClickable,
manifestURL, alertListener, name) {
this.showAlertNotification(imageUrl, title, text, textClickable, "", alertListener, name);
},
closeAlert: function(name) {
var alertNotification = activeAlertNotifications[name];
if (alertNotification) {
if (alertNotification.listener) {
alertNotification.listener.observe(null, "alertfinished", alertNotification.cookie);
}
delete activeAlertNotifications[name];
}
var appNotification = activeAppNotifications[name];
if (appNotification) {
delete activeAppNotifications[name];
var notification = activeNotifications[name];
if (notification) {
notification.listener.observe(null, "alertfinished", notification.cookie);
delete activeNotifications[name];
}
},
QueryInterface: function(aIID) {
if (SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsISupports) ||
SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsIAlertsService) ||
SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsIAppNotificationService)) {
SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsIAlertsService)) {
return this;
}
throw SpecialPowers.Components.results.NS_ERROR_NO_INTERFACE;
@ -102,8 +77,5 @@ var MockServices = (function () {
registrar.unregisterFactory(MOCK_ALERTS_CID, mockAlertsService);
registrar.unregisterFactory(MOCK_SYSTEM_ALERTS_CID, mockAlertsService);
},
activeAlertNotifications: activeAlertNotifications,
activeAppNotifications: activeAppNotifications,
};
})();

View File

@ -9,4 +9,3 @@ support-files =
skip-if = (toolkit == 'gonk' && debug) #debug-only timeout
[test_bug931307.html]
skip-if = (toolkit == 'gonk' && debug) #debug-only timeout
[test_notification_resend.html]

View File

@ -13,17 +13,15 @@
<script type="application/javascript"><!--
SimpleTest.waitForExplicitFinish();
var notification = new Notification("");
new Notification("");
var promise = Notification.get();
promise.then(
function onSuccess() {
ok(true, "No crash!");
notification.close();
SimpleTest.finish();
},
function onFailure() {
ok(false, "Should not get an error in promise callback");
notification.close();
}
);

View File

@ -103,7 +103,7 @@
};
notification.close();
}
},
];
MockServices.register();

View File

@ -1,170 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Testing mozResendAllNotifications() resend behavior</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="MockServices.js"></script>
<script type="text/javascript" src="NotificationTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=967475">Bug 967475</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
<script type="text/javascript">
var info = NotificationTest.info;
var now = new Date().getTime();
var notifications = [];
var manifestURL;
var steps = [
function (done) {
if (window.Notification) {
SpecialPowers.pushPrefEnv({"set": [
["dom.ignore_webidl_scope_checks", true],
]}, done);
} else {
ok(true, "Notifications are not enabled on the platform.");
done();
}
},
function (done) {
info("Set manifestURL");
var request = window.navigator.mozApps.getSelf();
request.onsuccess = function() {
if (request.result) {
manifestURL = request.result.manifestURL;
} else {
manifestURL = window.location.origin;
}
info("Value of manifestURL is: " + manifestURL);
done();
};
},
function (done) {
info("Test that we have mozChromeNotifications API");
ok(('mozChromeNotifications' in navigator), "should have mozChromeNotifications API");
ok(('mozResendAllNotifications' in navigator.mozChromeNotifications), "should have mozResendAllNotifications()");
done();
},
function (done) {
info("Making sure we have no previous notification pending");
var promise = Notification.get();
promise.then(function (notifications) {
is(notifications.length, 0, "notifications are all cleaned");
done();
});
},
function (done) {
info("Sending one notification");
var notif = new Notification("title");
ok(notif, "Notification object is valid");
notifications.push(notif);
var promise = Notification.get();
promise.then(function (notifications) {
is(notifications.length, 1, "one notification has been sent");
done();
});
},
function (done) {
info("Trying to resend the notification");
var notif = notifications.pop();
notif.onclose = function() {
done();
};
navigator.mozChromeNotifications.mozResendAllNotifications(function(number) {
is(number, 1, "One notification resent");
notif.close();
});
},
function (done) {
info("Sending two notifications, closing one");
var notif1 = new Notification("title1");
ok(notif1, "Notification object is valid");
notif1.onclose = function() {
done();
};
var payload = {
body: "Body",
tag: "fakeTag",
icon: "icon.jpg",
lang: "en-US",
dir: "ltr"
};
var notif2 = new Notification("Title2", payload);
ok(notif2, "Notification object is valid");
notifications.push(notif2);
var promise = Notification.get();
promise.then(function (notifications) {
is(notifications.length, 2, "two notifications have been sent");
notif1.close();
});
},
function (done) {
info("Checking if only notif2 is resent");
navigator.mozChromeNotifications.mozResendAllNotifications(function(number) {
is(number, 1, "One notification resent");
var promise = Notification.get();
promise.then(function (notifications) {
is(notifications.length, 1, "one notification still available");
is(notifications[0].title, "Title2", "notification title is 'Title2'");
done();
});
});
},
function (done) {
info("Checking ShowAppNotification behavior");
var notif2 = notifications.pop();
notif2.onclose = function() {
done();
};
navigator.mozChromeNotifications.mozResendAllNotifications(function(number) {
is(number, 1, "One notification resent");
var appNotifs = MockServices.activeAppNotifications;
var alertNotifs = MockServices.activeAlertNotifications;
var nbAppNotifs = Object.keys(appNotifs).length;
var nbAlertNotifs = Object.keys(alertNotifs).length;
is(nbAppNotifs, 1, "AlertsServices has one app notification");
is(nbAlertNotifs, 1, "AlertsServices has one alert notification");
var uuidRegEx = /[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/;
var notif = appNotifs[Object.keys(appNotifs)[0]];
ok(notif, "Notification object is valid");
ok((typeof notif.observer === "object"), "Notification observer is valid");
is(notif.title, "Title2", "Notification title is valid: " + notif.title);
is(notif.text, "Body", "Notification body is valid: " + notif.text);
is(notif.manifestURL, manifestURL, "Notification manifest URL is valid: " + notif.manifestURL);
is(notif.imageURL, "icon.jpg", "Notification icon URL is valid: " + notif.imageURL);
is(notif.lang, "en-US", "Notification lang is valid: " + notif.lang);
is(notif.id, notif.manifestURL + "#tag:" + notif.tag, "Notification id is valid: " + notif.id);
ok(notif.dbId.match(uuidRegEx), "Notification dbId is valid: " + notif.dbId);
is(notif.dir, "ltr", "Notification dir is valid: " + notif.dir);
is(notif.tag, "fakeTag", "Notification tag is valid: " + notif.tag);
ok((notif.timestamp > now), "Notification timestamp is valid: " + notif.timestamp);
notif2.close();
});
}
];
MockServices.register();
NotificationTest.run(steps, function () {
MockServices.unregister();
});
</script>
</body>
</html>

View File

@ -117,12 +117,10 @@
var n3 = new Notification("title3");
var promise = Notification.get();
promise.then(function (notifications) {
is(notifications.length, 3, "should return 3 notifications");
is(notifications.length, 3, "should return 2 notifications");
done();
});
},
deleteAllNotifications
}
];
MockServices.register();

View File

@ -1,14 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*/
[JSImplementation="@mozilla.org/mozChromeNotifications;1",
NavigatorProperty="mozChromeNotifications",
AvailableIn="CertifiedApps"]
interface ChromeNotifications {
void mozResendAllNotifications(ResendCallback resendCallback);
};
callback ResendCallback = void (long count);

View File

@ -52,7 +52,6 @@ WEBIDL_FILES = [
'ChannelSplitterNode.webidl',
'CharacterData.webidl',
'ChildNode.webidl',
'ChromeNotifications.webidl',
'ClipboardEvent.webidl',
'CommandEvent.webidl',
'Comment.webidl',

View File

@ -47,6 +47,8 @@ class TestActorPunningPunnedParent :
public:
TestActorPunningPunnedParent() {}
virtual ~TestActorPunningPunnedParent() {}
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
};
class TestActorPunningSubParent :
@ -55,6 +57,8 @@ class TestActorPunningSubParent :
public:
TestActorPunningSubParent() {}
virtual ~TestActorPunningSubParent() {}
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
};

View File

@ -51,6 +51,7 @@ public:
virtual ~TestBadActorSubParent() { }
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
virtual bool RecvPing();
};

View File

@ -80,8 +80,8 @@ public:
virtual ~TestDescSubParent() { }
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
virtual PTestDescSubsubParent* AllocPTestDescSubsubParent() MOZ_OVERRIDE;
virtual bool DeallocPTestDescSubsubParent(PTestDescSubsubParent* actor) MOZ_OVERRIDE;
};
@ -108,6 +108,9 @@ class TestDescSubsubParent :
public:
TestDescSubsubParent() { }
virtual ~TestDescSubsubParent() { }
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
};
class TestDescSubsubChild :

View File

@ -18,6 +18,9 @@ class TestHandleParent :
public:
TestHandleParent() { }
virtual ~TestHandleParent() { }
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
};
class TestJSONParent :

View File

@ -72,6 +72,7 @@ public:
virtual ~TestManyChildAllocsSubParent() { }
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
virtual bool RecvHello() MOZ_OVERRIDE { return true; }
};

View File

@ -25,6 +25,9 @@ class TestMultiMgrsBottomParent :
public:
TestMultiMgrsBottomParent() { }
virtual ~TestMultiMgrsBottomParent() { }
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
};
class TestMultiMgrsLeftParent :
@ -40,6 +43,8 @@ public:
}
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
virtual PTestMultiMgrsBottomParent* AllocPTestMultiMgrsBottomParent() MOZ_OVERRIDE
{
return new TestMultiMgrsBottomParent();
@ -65,6 +70,8 @@ public:
}
protected:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {}
virtual PTestMultiMgrsBottomParent* AllocPTestMultiMgrsBottomParent() MOZ_OVERRIDE
{
return new TestMultiMgrsBottomParent();

View File

@ -282,8 +282,6 @@
@BINPATH@/components/zipwriter.xpt
; JavaScript components
@BINPATH@/components/ChromeNotifications.js
@BINPATH@/components/ChromeNotifications.manifest
@BINPATH@/components/ConsoleAPI.manifest
@BINPATH@/components/ConsoleAPIStorage.js
@BINPATH@/components/ContactManager.js