Patch by Anders Carlsson <andersca@mac.com
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2005 21:29:43 +0000 (21:29 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2005 21:29:43 +0000 (21:29 +0000)
        Reviewed by darin

        Fixes <http://bugzilla.opendarwin.org/show_bug.cgi?id=4331> dispatchEvent should raise an exception

        Test cases added:
        * layout-tests/dom/html/level2/events/createEvent01-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent01-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent02-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent03-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent04-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent05-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent06-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent07-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent09-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent11-expected.txt:
        * layout-tests/dom/html/level2/events/initEvent01-expected.txt:
        * layout-tests/dom/html/level2/events/initEvent02-expected.txt:
        * layout-tests/dom/html/level2/events/initEvent03-expected.txt:
        These tests pass now.

        * layout-tests/dom/html/level2/events/dispatchEvent08-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent10-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent12-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent13-expected.txt:
        These tests fail somplace else now.

        * khtml/dom/dom2_events.h:
        (DOM::EventException::):
        Add _EXCEPTION_OFFSET and _EXCEPTION_MAX.

        * khtml/ecma/kjs_binding.cpp:
        (KJS::setDOMException):
        Handle EventExceptions.

        * khtml/xml/dom_docimpl.cpp:
        (DocumentImpl::createEvent):
        Allow "Events" as event type.

        * khtml/xml/dom_nodeimpl.cpp:
        (DOM::NodeImpl::dispatchEvent):
        Raise exception if event is NULL, uninitialized, or if its name is the empty string.

        * kwq/DOMInternal.mm:
        (raiseDOMException):
        Handle EventExceptions.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@10109 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
LayoutTests/dom/html/level2/events/createEvent01-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent01-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent02-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent03-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent04-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent05-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent06-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent07-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent08-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent09-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent10-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent11-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent12-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent13-expected.txt
LayoutTests/dom/html/level2/events/initEvent01-expected.txt
LayoutTests/dom/html/level2/events/initEvent02-expected.txt
LayoutTests/dom/html/level2/events/initEvent03-expected.txt
WebCore/ChangeLog-2005-08-23
WebCore/khtml/dom/dom2_events.h
WebCore/khtml/ecma/kjs_binding.cpp
WebCore/khtml/xml/dom_docimpl.cpp
WebCore/khtml/xml/dom_nodeimpl.cpp
WebCore/kwq/DOMInternal.mm

index 415aa555e674b8e59ca23c01c7ec6b2687627d62..fd8376ef513996e800b1fcdbb5d008cb05935a04 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/createEvent01       
-Status:        error
-Detail:        Error: DOM exception 9
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/createEvent01
+Status:        Success
index 4241ec2609348849e469c57c79619e04ca7d8bcb..4e23791f7587dc467cc115311f73ce86970d3fb6 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent01     
-Status:        failure
-Detail:        throw_ImplException: assertTrue failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent01
+Status:        Success
index 593e34a63ab5d65b6108360d9eb8b7f8f566dbb9..0be1d2cdef30c09f4eac740eca0d3967eede5b65 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent02     
-Status:        error
-Detail:        Error: DOM exception 9
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent02
+Status:        Success
index 9c80a088613ef54912dc1f986118dc7381b5283f..cd06d61c3a7a08de2793e30d580eb9a6b6260677 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent03     
-Status:        failure
-Detail:        throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent03
+Status:        Success
index a75b8045843cc03eb5b842ff7214295670f85b5b..c44cd14dd5b3b515da22c48b881f892dbae496f9 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent04     
-Status:        failure
-Detail:        throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent04
+Status:        Success
index c1cfe382d181f5ce89cd8f6409488d1008b049bc..4e9d0fd868477a1ae4d6b9d4461d9f51d0eb962d 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent05     
-Status:        failure
-Detail:        throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent05
+Status:        Success
index 29104a5fbd550805289bc0126b71affffa49abe9..c832234e33a84882e4534173b9594a2d5a56880a 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent06     
-Status:        failure
-Detail:        throw_UNSPECIFIED_EVENT_TYPE_ERR: assertTrue failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent06
+Status:        Success
index f682fc31c2485a10814594ccd9d316b2eef881a5..f941adb564d6023e4328080f36795660e284374d 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent07     
-Status:        error
-Detail:        Error: DOM exception 9
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent07
+Status:        Success
index b36e23ad7197e2dfe0aa28858606f74db36e9014..f0d52e414ea01ae9688ad9c704b2328089c332b2 100644 (file)
@@ -1,3 +1,3 @@
 Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent08     
-Status:        error
-Detail:        Error: DOM exception 9
+Status:        failure
+Detail:        atCount: assertEquals failed, actual 0, expected 1.
index cb898b5df197bbd0669c6f67c7f1279ef2e36405..f79cf2b99d414891dd3fa1c0ca74515d16fb53fc 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent09     
-Status:        error
-Detail:        Error: DOM exception 9
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent09
+Status:        Success
index 27c70ee6068bc5b62b136a40c5a0ce126d29d81e..0903f42edacc7ad6da37821391ff32ed0ab3bf4f 100644 (file)
@@ -1,3 +1,3 @@
 Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent10     
-Status:        error
-Detail:        Error: DOM exception 9
+Status:        failure
+Detail:        atCount: assertEquals failed, actual 0, expected 1.
index 26f0bba61bd8cb72c053cf01d33b5dbd59c2f629..bfc7703cd83df93c36f21b0e229072c035b457f6 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent11     
-Status:        error
-Detail:        Error: DOM exception 9
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent11
+Status:        Success
index 3975450326ef4bf4b6330f2045253ab77a9b8877..ec930d61f0c365021fe3d7d200ab02781ffddbc7 100644 (file)
@@ -1,3 +1,3 @@
 Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent12     
-Status:        error
-Detail:        Error: DOM exception 9
+Status:        failure
+Detail:        eventCount: assertEquals failed, actual 0, expected 1.
index 56c83cb139b357c3d6957ee0df501072c3a67458..0bc9af637d49db9b06479765b82c6bcd36a801be 100644 (file)
@@ -1,3 +1,3 @@
 Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent13     
-Status:        error
-Detail:        Error: DOM exception 9
+Status:        failure
+Detail:        eventCount: assertEquals failed, actual 0, expected 1.
index ab120452f8dcc464df2ed0b0669174740c6bf3ee..7693f619a83825296d9c2ab4b3cc849acc998597 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/initEvent01 
-Status:        error
-Detail:        Error: DOM exception 9
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/initEvent01
+Status:        Success
index 0d97f89d7c566be36720f61cb5ef8f14320fa73b..18897944491cacdf852edf34ddb396fc630064cb 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/initEvent02 
-Status:        error
-Detail:        Error: DOM exception 9
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/initEvent02
+Status:        Success
index 1dcbb74932e76cd3d065dc72e4c15a7a45e466ae..85ccb1dd454e220429ff4041512730a88081e214 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/initEvent03 
-Status:        error
-Detail:        Error: DOM exception 9
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/initEvent03
+Status:        Success
index bb44e2662fa253633637635f77f858dd8946869f..639cc4f15a507b2493980db4b6bbbc612c79a61d 100644 (file)
@@ -1,3 +1,53 @@
+2005-08-09  Justin Garcia  <justin.garcia@apple.com>
+
+        Patch by Anders Carlsson <andersca@mac.com
+
+        Reviewed by darin
+        
+        Fixes <http://bugzilla.opendarwin.org/show_bug.cgi?id=4331> dispatchEvent should raise an exception
+        
+        Test cases added:
+        * layout-tests/dom/html/level2/events/createEvent01-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent01-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent02-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent03-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent04-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent05-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent06-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent07-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent09-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent11-expected.txt:
+        * layout-tests/dom/html/level2/events/initEvent01-expected.txt:
+        * layout-tests/dom/html/level2/events/initEvent02-expected.txt:
+        * layout-tests/dom/html/level2/events/initEvent03-expected.txt:
+        These tests pass now.
+       
+        * layout-tests/dom/html/level2/events/dispatchEvent08-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent10-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent12-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent13-expected.txt:
+        These tests fail somplace else now.
+
+        * khtml/dom/dom2_events.h:
+        (DOM::EventException::):
+        Add _EXCEPTION_OFFSET and _EXCEPTION_MAX.
+       
+        * khtml/ecma/kjs_binding.cpp:
+        (KJS::setDOMException):
+        Handle EventExceptions.
+       
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::createEvent):
+        Allow "Events" as event type.
+       
+        * khtml/xml/dom_nodeimpl.cpp:
+        (DOM::NodeImpl::dispatchEvent):
+        Raise exception if event is NULL, uninitialized, or if its name is the empty string.
+               
+        * kwq/DOMInternal.mm:
+        (raiseDOMException):
+        Handle EventExceptions.
+
 2005-08-09  David Hyatt  <hyatt@apple.com>
 
        Implement baseline alignment support for inline blocks.  Inline blocks are supposed to use
index 4117ad4961177e4f3c35847a1240694acab040d3..54152f498b5ab752ea2627301cecbbf6aa633cbd 100644 (file)
@@ -324,7 +324,9 @@ public:
      *
      */
     enum EventExceptionCode {
-        UNSPECIFIED_EVENT_TYPE_ERR     = 0
+        UNSPECIFIED_EVENT_TYPE_ERR     = 0,
+        _EXCEPTION_OFFSET              = 3000,
+        _EXCEPTION_MAX                 = 3999
     };
 
 #if !KHTML_NO_CPLUSPLUS_DOM
index cb3bf195aa438cd67da6be3627a22cdf739d4997..af1f4ef8807905d97cb2e845f6f52e6ca0de021f 100644 (file)
@@ -39,6 +39,7 @@
 using DOM::CSSException;
 using DOM::DOMString;
 using DOM::DocumentImpl;
+using DOM::EventException;
 using DOM::NodeImpl;
 using DOM::RangeException;
 using khtml::HashMap;
@@ -341,8 +342,10 @@ void setDOMException(ExecState *exec, int DOMExceptionCode)
   } else if (code >= CSSException::_EXCEPTION_OFFSET && code <= CSSException::_EXCEPTION_MAX) {
     type = "CSS";
     code -= CSSException::_EXCEPTION_OFFSET;
+  } else if (code >= EventException::_EXCEPTION_OFFSET && code <= EventException::_EXCEPTION_MAX) {
+    type = "DOM Events";
+    code -= EventException::_EXCEPTION_OFFSET;
   }
-
   char buffer[100]; // needs to fit 20 characters, plus an integer in ASCII, plus a null character
   sprintf(buffer, "%s exception %d", type, code);
 
index 4efa946e2e40e480d616479d28a328f56baaeceb..4da5abfb0473be579ba2968bde8b6c6eeae9f055 100644 (file)
@@ -2319,7 +2319,7 @@ EventImpl *DocumentImpl::createEvent(const DOMString &eventType, int &exceptionc
         return new MutationEventImpl();
     else if (eventType == "KeyboardEvents" || eventType == "KeyboardEvent")
         return new KeyboardEventImpl();
-    else if (eventType == "HTMLEvents" || eventType == "Event")
+    else if (eventType == "HTMLEvents" || eventType == "Event" || eventType == "Events")
         return new EventImpl();
     else {
         exceptioncode = DOMException::NOT_SUPPORTED_ERR;
index ee480b2e0bcc9c46fd36758e98d7227ba967496c..2df1fef8955f92716693101a3a354a6752681a6d 100644 (file)
@@ -475,8 +475,8 @@ EventListener *NodeImpl::getHTMLEventListener(int id)
 
 bool NodeImpl::dispatchEvent(EventImpl *evt, int &exceptioncode, bool tempEvent)
 {
-    if (!evt) {
-        exceptioncode = 0;
+    if (!evt || evt->type().isEmpty()) { 
+        exceptioncode = EventException::_EXCEPTION_OFFSET + EventException::UNSPECIFIED_EVENT_TYPE_ERR;
         return false;
     }
 
index 0dba6cfd91d9bdb2a75701a07c59ed73a1ef9c63..9b800f237d84a8470cc13d98b0a972fcb105aecf 100644 (file)
@@ -27,6 +27,7 @@
 
 #import "css_stylesheet.h"
 #import "dom2_range.h"
+#import "dom2_events.h"
 #import "dom_exception.h"
 #import "dom_string.h"
 #import "dom_docimpl.h"
@@ -44,6 +45,7 @@
 using DOM::CSSException;
 using DOM::DOMString;
 using DOM::DOMStringImpl;
+using DOM::EventException;
 using DOM::NodeImpl;
 using DOM::RangeException;
 
@@ -88,6 +90,7 @@ void removeDOMWrapper(DOMObjectInternal *impl)
 NSString * const DOMException = @"DOMException";
 NSString * const DOMRangeException = @"DOMRangeException";
 NSString * const DOMCSSException = @"DOMCSSException";
+NSString * const DOMEventException = @"DOMEventException";
 
 void raiseDOMException(int code)
 {
@@ -101,6 +104,9 @@ void raiseDOMException(int code)
     } else if (code >= CSSException::_EXCEPTION_OFFSET && code <= CSSException::_EXCEPTION_MAX) {
         name = DOMCSSException;
         code -= CSSException::_EXCEPTION_OFFSET;
+    } else if (code >= EventException::_EXCEPTION_OFFSET && code<= EventException::_EXCEPTION_MAX) {
+        name = DOMEventException;
+        code -= EventException::_EXCEPTION_OFFSET;
     }
 
     NSString *reason = [NSString stringWithFormat:@"*** Exception received from DOM API: %d", code];