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
-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
-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
-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
-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
-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
-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
-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
-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
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.
-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
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.
-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
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.
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.
-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
-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
-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
+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
*
*/
enum EventExceptionCode {
- UNSPECIFIED_EVENT_TYPE_ERR = 0
+ UNSPECIFIED_EVENT_TYPE_ERR = 0,
+ _EXCEPTION_OFFSET = 3000,
+ _EXCEPTION_MAX = 3999
};
#if !KHTML_NO_CPLUSPLUS_DOM
using DOM::CSSException;
using DOM::DOMString;
using DOM::DocumentImpl;
+using DOM::EventException;
using DOM::NodeImpl;
using DOM::RangeException;
using khtml::HashMap;
} 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);
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;
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;
}
#import "css_stylesheet.h"
#import "dom2_range.h"
+#import "dom2_events.h"
#import "dom_exception.h"
#import "dom_string.h"
#import "dom_docimpl.h"
using DOM::CSSException;
using DOM::DOMString;
using DOM::DOMStringImpl;
+using DOM::EventException;
using DOM::NodeImpl;
using DOM::RangeException;
NSString * const DOMException = @"DOMException";
NSString * const DOMRangeException = @"DOMRangeException";
NSString * const DOMCSSException = @"DOMCSSException";
+NSString * const DOMEventException = @"DOMEventException";
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];