[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

abarth at webkit.org abarth at webkit.org
Thu Apr 8 00:28:00 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit e3da2374f7ab8c77703a879c9a8aae7c42a858b5
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Dec 8 18:44:57 2009 +0000

    2009-12-08  John Gregg  <johnnyg at google.com>
    
            Reviewed by Adam Barth.
    
            https://bugs.webkit.org/show_bug.cgi?id=31886
    
            Test for accessing the notificationCenter of a window after it's closed.
    
            * fast/notifications/notification-after-close-expected.txt: Added.
            * fast/notifications/notification-after-close.html: Added.
    2009-12-08  John Gregg  <johnnyg at google.com>
    
            Reviewed by Adam Barth.
    
            Inform the NotificationCenter when its window goes away in the same
            manner as other DOMWindow fields, and prevent invalid operations on
            it after that happens.
    
            As part of this, change the V8 bindings for notifications to call
            through the NotificationCenter rather than doing those operations
            itself.
    
            https://bugs.webkit.org/show_bug.cgi?id=31886
    
            Test: fast/notifications/notification-after-close.html
    
            * bindings/v8/custom/V8NotificationCenterCustom.cpp:
            (WebCore::CALLBACK_FUNC_DECL):
            * notifications/Notification.cpp:
            (WebCore::Notification::Notification):
            * notifications/NotificationCenter.cpp:
            (WebCore::NotificationCenter::checkPermission):
            (WebCore::NotificationCenter::requestPermission):
            * notifications/NotificationCenter.h:
            (WebCore::NotificationCenter::createHTMLNotification):
            (WebCore::NotificationCenter::createNotification):
            (WebCore::NotificationCenter::disconnectFrame):
            * page/DOMWindow.cpp:
            (WebCore::DOMWindow::clear):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51865 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 485d731..65ad50a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2009-12-08  John Gregg  <johnnyg at google.com>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=31886
+
+        Test for accessing the notificationCenter of a window after it's closed.
+
+        * fast/notifications/notification-after-close-expected.txt: Added.
+        * fast/notifications/notification-after-close.html: Added.
+
 2009-12-08  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by John Sullivan.
diff --git a/LayoutTests/fast/dom/beforeload/video-before-load-expected.txt b/LayoutTests/fast/notifications/notification-after-close-expected.txt
similarity index 100%
copy from LayoutTests/fast/dom/beforeload/video-before-load-expected.txt
copy to LayoutTests/fast/notifications/notification-after-close-expected.txt
diff --git a/LayoutTests/fast/notifications/notification-after-close.html b/LayoutTests/fast/notifications/notification-after-close.html
new file mode 100644
index 0000000..fbf4d62
--- /dev/null
+++ b/LayoutTests/fast/notifications/notification-after-close.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script type="text/javascript">
+        function log(message)
+        {
+            document.getElementById("result").innerHTML += message + "<br>";
+        }
+        
+        function runTests()
+        {
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.waitUntilDone();
+                layoutTestController.setCanOpenWindows();
+            }
+
+            win = window.open('about:blank');
+            if (win.webkitNotifications === undefined) {
+                log("PASS");
+            } else {
+                notificationCenter=win.webkitNotifications;
+                win.close();
+                try { 
+                    n=notificationCenter.createNotification(''); 
+                } catch (e) {}
+                // Just make sure we don't crash.
+                log("PASS");
+            }
+
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }
+    </script>
+</head>
+<body>
+<div id="result"></div>    
+    
+<script type="text/javascript">
+runTests();
+</script>
+
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7787aff..63cc665 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2009-12-08  John Gregg  <johnnyg at google.com>
+
+        Reviewed by Adam Barth.
+
+        Inform the NotificationCenter when its window goes away in the same
+        manner as other DOMWindow fields, and prevent invalid operations on
+        it after that happens.
+
+        As part of this, change the V8 bindings for notifications to call
+        through the NotificationCenter rather than doing those operations
+        itself.
+
+        https://bugs.webkit.org/show_bug.cgi?id=31886
+
+        Test: fast/notifications/notification-after-close.html
+
+        * bindings/v8/custom/V8NotificationCenterCustom.cpp:
+        (WebCore::CALLBACK_FUNC_DECL):
+        * notifications/Notification.cpp:
+        (WebCore::Notification::Notification):
+        * notifications/NotificationCenter.cpp:
+        (WebCore::NotificationCenter::checkPermission):
+        (WebCore::NotificationCenter::requestPermission):
+        * notifications/NotificationCenter.h:
+        (WebCore::NotificationCenter::createHTMLNotification):
+        (WebCore::NotificationCenter::createNotification):
+        (WebCore::NotificationCenter::disconnectFrame):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::clear):
+
 2009-12-08  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by John Sullivan.
diff --git a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
index bd5fb4a..a1f20cc 100644
--- a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
@@ -82,15 +82,15 @@ CALLBACK_FUNC_DECL(NotificationCenterCreateHTMLNotification)
 {
     INC_STATS(L"DOM.NotificationCenter.CreateHTMLNotification()");
     NotificationCenter* notificationCenter = V8DOMWrapper::convertToNativeObject<NotificationCenter>(V8ClassIndex::NOTIFICATIONCENTER, args.Holder());
-    ScriptExecutionContext* context = notificationCenter->context();
+
     ExceptionCode ec = 0;
     String url = toWebCoreString(args[0]);
-    RefPtr<Notification> notification = Notification::create(url, context, ec, notificationCenter->presenter());
+    RefPtr<Notification> notification = notificationCenter->createHTMLNotification(url, ec);
 
     if (ec)
         return throwError(ec);
 
-    if (context->isWorkerContext())
+    if (notificationCenter->context()->isWorkerContext())
         return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
 
     return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
@@ -100,16 +100,14 @@ CALLBACK_FUNC_DECL(NotificationCenterCreateNotification)
 {
     INC_STATS(L"DOM.NotificationCenter.CreateNotification()");
     NotificationCenter* notificationCenter = V8DOMWrapper::convertToNativeObject<NotificationCenter>(V8ClassIndex::NOTIFICATIONCENTER, args.Holder());
-    NotificationContents contents(toWebCoreString(args[0]), toWebCoreString(args[1]), toWebCoreString(args[2]));
 
-    ScriptExecutionContext* context = notificationCenter->context();
     ExceptionCode ec = 0;
-    RefPtr<Notification> notification = Notification::create(contents, context, ec, notificationCenter->presenter());
+    RefPtr<Notification> notification = notificationCenter->createNotification(toWebCoreString(args[0]), toWebCoreString(args[1]), toWebCoreString(args[2]), ec);
 
     if (ec)
         return throwError(ec);
 
-    if (context->isWorkerContext())
+    if (notificationCenter->context()->isWorkerContext())
         return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
 
     return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get());
diff --git a/WebCore/notifications/Notification.cpp b/WebCore/notifications/Notification.cpp
index 8dd168f..ecb5799 100644
--- a/WebCore/notifications/Notification.cpp
+++ b/WebCore/notifications/Notification.cpp
@@ -48,6 +48,7 @@ Notification::Notification(const String& url, ScriptExecutionContext* context, E
     , m_isShowing(false)
     , m_presenter(provider)
 {
+    ASSERT(m_presenter);
     if (m_presenter->checkPermission(context->securityOrigin()) != NotificationPresenter::PermissionAllowed) {
         ec = SECURITY_ERR;
         return;
@@ -67,6 +68,7 @@ Notification::Notification(const NotificationContents& contents, ScriptExecution
     , m_isShowing(false)
     , m_presenter(provider)
 {
+    ASSERT(m_presenter);
     if (m_presenter->checkPermission(context->securityOrigin()) != NotificationPresenter::PermissionAllowed) {
         ec = SECURITY_ERR;
         return;
diff --git a/WebCore/notifications/NotificationCenter.cpp b/WebCore/notifications/NotificationCenter.cpp
index 94976a2..45d29cf 100644
--- a/WebCore/notifications/NotificationCenter.cpp
+++ b/WebCore/notifications/NotificationCenter.cpp
@@ -47,11 +47,15 @@ NotificationCenter::NotificationCenter(ScriptExecutionContext* context, Notifica
 
 int NotificationCenter::checkPermission() 
 {
+    if (!presenter())
+        return NotificationPresenter::PermissionDenied;
     return m_notificationPresenter->checkPermission(m_scriptExecutionContext->securityOrigin());
 }
 
 void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback)
 {
+    if (!presenter())
+        return;
     m_notificationPresenter->requestPermission(m_scriptExecutionContext->securityOrigin(), callback);
 }
 
diff --git a/WebCore/notifications/NotificationCenter.h b/WebCore/notifications/NotificationCenter.h
index ef59414..ae3dc02 100644
--- a/WebCore/notifications/NotificationCenter.h
+++ b/WebCore/notifications/NotificationCenter.h
@@ -51,11 +51,19 @@ namespace WebCore {
 
         Notification* createHTMLNotification(const String& URI, ExceptionCode& ec)
         {
+            if (!presenter()) {
+                ec = INVALID_STATE_ERR;
+                return 0;
+            }
             return Notification::create(KURL(ParsedURLString, URI), context(), ec, presenter());
         }
 
         Notification* createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode& ec)
         {
+            if (!presenter()) {
+                ec = INVALID_STATE_ERR;
+                return 0;
+            }
             NotificationContents contents(iconURI, title, body);
             return Notification::create(contents, context(), ec, presenter());
         }
@@ -66,6 +74,8 @@ namespace WebCore {
         int checkPermission();
         void requestPermission(PassRefPtr<VoidCallback> callback);
 
+        void disconnectFrame() { m_notificationPresenter = 0; }
+
     private:
         NotificationCenter(ScriptExecutionContext*, NotificationPresenter*);
 
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index 8bb70e0..757e32f 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -460,6 +460,8 @@ void DOMWindow::clear()
 #endif
 
 #if ENABLE(NOTIFICATIONS)
+    if (m_notifications)
+        m_notifications->disconnectFrame();
     m_notifications = 0;
 #endif
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list