Bug 916893 - Patch 3 - Walk up worker chain to find correct window for WorkerNotificationObserver. r=khuey

In case of child workers.

--HG--
extra : transplant_source : %29Y%8B%3C%F0%14%E6%95D%0B%FDa%9AeD%EB%82%C3F%FE
This commit is contained in:
Nikhil Marathe 2015-06-25 18:53:02 -07:00
parent 95c8d0e8a4
commit b2e80f822b

View File

@ -981,7 +981,7 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
MOZ_ASSERT(notification);
if (!strcmp("alertclickcallback", aTopic)) {
nsCOMPtr<nsPIDOMWindow> window = notification->GetOwner();
if (!window || !window->IsCurrentInnerWindow()) {
if (NS_WARN_IF(!window || !window->IsCurrentInnerWindow())) {
// Window has been closed, this observer is not valid anymore
return NS_ERROR_FAILURE;
}
@ -1017,7 +1017,7 @@ WorkerNotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
// runnables, see the Notification class comment.
Notification* notification = mNotificationRef->GetNotification();
// We can't assert notification here since the feature could've unset it.
if (!notification) {
if (NS_WARN_IF(!notification)) {
return NS_ERROR_FAILURE;
}
@ -1025,8 +1025,13 @@ WorkerNotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
nsRefPtr<WorkerRunnable> r;
if (!strcmp("alertclickcallback", aTopic)) {
nsCOMPtr<nsPIDOMWindow> window = notification->mWorkerPrivate->GetWindow();
if (!window || !window->IsCurrentInnerWindow()) {
WorkerPrivate* top = notification->mWorkerPrivate;
while (top->GetParent()) {
top = top->GetParent();
}
nsPIDOMWindow* window = top->GetWindow();
if (NS_WARN_IF(!window || !window->IsCurrentInnerWindow())) {
// Window has been closed, this observer is not valid anymore
return NS_ERROR_FAILURE;
}