Bug 1156397 - some fix for webpush PushServer. r=dougt r=nsm

This commit is contained in:
Dragana Damjanovic 2015-04-24 14:55:00 +02:00
parent 92a9c5c6c7
commit 5fe45aad54
4 changed files with 22 additions and 11 deletions

View File

@ -33,7 +33,7 @@ interface nsIServiceWorkerInfo : nsISupports
readonly attribute DOMString waitingCacheName;
};
[scriptable, builtinclass, uuid(ff6e13ae-ae34-4941-a81e-a82f3e0e7b6b)]
[scriptable, builtinclass, uuid(ff13ee00-5485-4551-af6f-1ab6de843365)]
interface nsIServiceWorkerManager : nsISupports
{
/**
@ -119,7 +119,7 @@ interface nsIServiceWorkerManager : nsISupports
nsIArray getAllRegistrations();
void sendPushEvent(in ACString scope, in DOMString data);
void sendPushSubscriptionChangedEvent(in ACString scope);
void sendPushSubscriptionChangeEvent(in ACString scope);
void updateAllRegistrations();
};

View File

@ -1376,7 +1376,6 @@ this.PushService = {
"push-subscription-change",
scope
);
// TODO -- test needed. E10s support needed.
globalMM.broadcastAsyncMessage('pushsubscriptionchanged', scope);
}
resolve();

View File

@ -13,6 +13,6 @@ addMessageListener("push", function (aMessage) {
swm.sendPushEvent(aMessage.data.scope, aMessage.data.payload);
});
addMessageListener("pushsubscriptionchanged", function (aMessage) {
swm.sendPushSubscriptionChangedEvent(aMessage.data);
});
addMessageListener("pushsubscriptionchange", function (aMessage) {
swm.sendPushSubscriptionChangeEvent(aMessage.data);
});

View File

@ -1531,11 +1531,23 @@ public:
{
MOZ_ASSERT(aWorkerPrivate);
nsRefPtr<EventTarget> target = do_QueryObject(aWorkerPrivate->GlobalScope());
WorkerGlobalScope* globalScope = aWorkerPrivate->GlobalScope();
nsContentUtils::DispatchTrustedEvent(nullptr, target,
NS_LITERAL_STRING("pushsubscriptionchange"),
true, true);
nsCOMPtr<nsIDOMEvent> event;
nsresult rv =
NS_NewDOMEvent(getter_AddRefs(event), globalScope, nullptr, nullptr);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
rv = event->InitEvent(NS_LITERAL_STRING("pushsubscriptionchange"), false, false);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
event->SetTrusted(true);
globalScope->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
return true;
}
};
@ -1570,7 +1582,7 @@ ServiceWorkerManager::SendPushEvent(const nsACString& aScope, const nsAString& a
}
NS_IMETHODIMP
ServiceWorkerManager::SendPushSubscriptionChangedEvent(const nsACString& aScope)
ServiceWorkerManager::SendPushSubscriptionChangeEvent(const nsACString& aScope)
{
#ifdef MOZ_SIMPLEPUSH
return NS_ERROR_NOT_AVAILABLE;