Diff
Modified: trunk/LayoutTests/ChangeLog (94146 => 94147)
--- trunk/LayoutTests/ChangeLog 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/LayoutTests/ChangeLog 2011-08-31 04:04:06 UTC (rev 94147)
@@ -1,3 +1,21 @@
+2011-08-30 Sam Weinig <[email protected]>
+
+ Add constructor for CustomEvent
+ https://bugs.webkit.org/show_bug.cgi?id=67248
+
+ Reviewed by Dan Bernstein.
+
+ * fast/events/constructors/custom-event-constructor-expected.txt: Added.
+ * fast/events/constructors/custom-event-constructor.html: Added.
+ New test.
+
+ * fast/dom/constructed-objects-prototypes-expected.txt:
+ * platform/mac/fast/dom/Window/window-properties-expected.txt:
+ * platform/mac/fast/dom/Window/window-property-descriptors-expected.txt:
+ * platform/mac/fast/dom/prototype-inheritance-expected.txt:
+ * platform/mac/fast/js/global-constructors-expected.txt:
+ Updated for add window.CustomEvent.
+
2011-08-30 David Levin <[email protected]>
[chromium] New baselines due to r94109.
Modified: trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt (94146 => 94147)
--- trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt 2011-08-31 04:04:06 UTC (rev 94147)
@@ -5,6 +5,8 @@
PASS (new inner.Audio()).isInner is true
PASS (new inner.Audio()).constructor.isInner is true
+PASS (new inner.CustomEvent()).isInner is true
+PASS (new inner.CustomEvent()).constructor.isInner is true
PASS (new inner.DOMParser()).isInner is true
PASS (new inner.DOMParser()).constructor.isInner is true
PASS (new inner.Event()).isInner is true
Added: trunk/LayoutTests/fast/events/constructors/custom-event-constructor-expected.txt (0 => 94147)
--- trunk/LayoutTests/fast/events/constructors/custom-event-constructor-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/custom-event-constructor-expected.txt 2011-08-31 04:04:06 UTC (rev 94147)
@@ -0,0 +1,21 @@
+This tests the constructor for the CustomEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new CustomEvent('eventType').bubbles is false
+PASS new CustomEvent('eventType').cancelable is false
+PASS new CustomEvent('eventType').detail is null
+PASS new CustomEvent('eventType', { bubbles: true, cancelable: true }).bubbles is true
+PASS new CustomEvent('eventType', { bubbles: true, cancelable: true }).cancelable is true
+PASS new CustomEvent('eventType', { bubbles: true, cancelable: true }).detail is null
+PASS new CustomEvent('eventType', { detail: 10 }).detail is 10
+PASS new CustomEvent('eventType', { detail: 'string' }).detail is 'string'
+PASS new CustomEvent('eventType', { detail: detailObject }).detail is detailObject
+PASS new CustomEvent('eventType', { detail: document }).detail is document
+PASS new CustomEvent('eventType', { get detail() { return true; } }).detail is true
+PASS new CustomEvent('eventType', { get detail() { throw 'Custom Error'; } }) threw exception Custom Error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/events/constructors/custom-event-constructor.html (0 => 94147)
--- trunk/LayoutTests/fast/events/constructors/custom-event-constructor.html (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/custom-event-constructor.html 2011-08-31 04:04:06 UTC (rev 94147)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("This tests the constructor for the CustomEvent DOM class.");
+
+// No initializer passed.
+shouldBe("new CustomEvent('eventType').bubbles", "false");
+shouldBe("new CustomEvent('eventType').cancelable", "false");
+shouldBeNull("new CustomEvent('eventType').detail");
+
+// Bubbles and cancelable true, details is missing.
+shouldBe("new CustomEvent('eventType', { bubbles: true, cancelable: true }).bubbles", "true");
+shouldBe("new CustomEvent('eventType', { bubbles: true, cancelable: true }).cancelable", "true");
+shouldBeNull("new CustomEvent('eventType', { bubbles: true, cancelable: true }).detail");
+
+// Detail is a number
+shouldBe("new CustomEvent('eventType', { detail: 10 }).detail", "10");
+
+// Detail is a string
+shouldBe("new CustomEvent('eventType', { detail: \'string\' }).detail", "'string'");
+
+// Detail is an object
+var detailObject = { };
+shouldBe("new CustomEvent('eventType', { detail: detailObject }).detail", "detailObject");
+
+// Detail is a DOM object
+shouldBe("new CustomEvent('eventType', { detail: document }).detail", "document");
+
+// Detail is a getter.
+shouldBe("new CustomEvent('eventType', { get detail() { return true; } }).detail", "true");
+
+// Detail throws an exeception.
+shouldThrow("new CustomEvent('eventType', { get detail() { throw 'Custom Error'; } })");
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt (94146 => 94147)
--- trunk/LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt 2011-08-31 04:04:06 UTC (rev 94147)
@@ -509,6 +509,32 @@
window.Comment.prototype [printed above as window.CharacterData.prototype]
window.Counter [object CounterConstructor]
window.Counter.prototype [object CounterPrototype]
+window.CustomEvent [object CustomEventConstructor]
+window.CustomEvent.prototype [object CustomEventPrototype]
+window.CustomEvent.prototype.AT_TARGET [number]
+window.CustomEvent.prototype.BLUR [number]
+window.CustomEvent.prototype.BUBBLING_PHASE [number]
+window.CustomEvent.prototype.CAPTURING_PHASE [number]
+window.CustomEvent.prototype.CHANGE [number]
+window.CustomEvent.prototype.CLICK [number]
+window.CustomEvent.prototype.DBLCLICK [number]
+window.CustomEvent.prototype.DRAGDROP [number]
+window.CustomEvent.prototype.FOCUS [number]
+window.CustomEvent.prototype.KEYDOWN [number]
+window.CustomEvent.prototype.KEYPRESS [number]
+window.CustomEvent.prototype.KEYUP [number]
+window.CustomEvent.prototype.MOUSEDOWN [number]
+window.CustomEvent.prototype.MOUSEDRAG [number]
+window.CustomEvent.prototype.MOUSEMOVE [number]
+window.CustomEvent.prototype.MOUSEOUT [number]
+window.CustomEvent.prototype.MOUSEOVER [number]
+window.CustomEvent.prototype.MOUSEUP [number]
+window.CustomEvent.prototype.SELECT [number]
+window.CustomEvent.prototype.initCustomEvent [function]
+window.CustomEvent.prototype.initEvent [function]
+window.CustomEvent.prototype.preventDefault [function]
+window.CustomEvent.prototype.stopImmediatePropagation [function]
+window.CustomEvent.prototype.stopPropagation [function]
window.DOMException [object DOMExceptionConstructor]
window.DOMException.ABORT_ERR [number]
window.DOMException.DATA_CLONE_ERR [number]
Modified: trunk/LayoutTests/platform/mac/fast/dom/Window/window-property-descriptors-expected.txt (94146 => 94147)
--- trunk/LayoutTests/platform/mac/fast/dom/Window/window-property-descriptors-expected.txt 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/LayoutTests/platform/mac/fast/dom/Window/window-property-descriptors-expected.txt 2011-08-31 04:04:06 UTC (rev 94147)
@@ -33,6 +33,7 @@
PASS typeof Object.getOwnPropertyDescriptor(window, 'CloseEvent') is 'object'
PASS typeof Object.getOwnPropertyDescriptor(window, 'Comment') is 'object'
PASS typeof Object.getOwnPropertyDescriptor(window, 'Counter') is 'object'
+PASS typeof Object.getOwnPropertyDescriptor(window, 'CustomEvent') is 'object'
PASS typeof Object.getOwnPropertyDescriptor(window, 'DOMException') is 'object'
PASS typeof Object.getOwnPropertyDescriptor(window, 'DOMImplementation') is 'object'
PASS typeof Object.getOwnPropertyDescriptor(window, 'DOMParser') is 'object'
Modified: trunk/LayoutTests/platform/mac/fast/dom/prototype-inheritance-expected.txt (94146 => 94147)
--- trunk/LayoutTests/platform/mac/fast/dom/prototype-inheritance-expected.txt 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/LayoutTests/platform/mac/fast/dom/prototype-inheritance-expected.txt 2011-08-31 04:04:06 UTC (rev 94147)
@@ -63,6 +63,8 @@
PASS inner.Comment.constructor.isInner is true
PASS inner.Counter.isInner is true
PASS inner.Counter.constructor.isInner is true
+PASS inner.CustomEvent.isInner is true
+PASS inner.CustomEvent.constructor.isInner is true
PASS inner.DOMException.isInner is true
PASS inner.DOMException.constructor.isInner is true
PASS inner.DOMImplementation.isInner is true
Modified: trunk/LayoutTests/platform/mac/fast/js/global-constructors-expected.txt (94146 => 94147)
--- trunk/LayoutTests/platform/mac/fast/js/global-constructors-expected.txt 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/LayoutTests/platform/mac/fast/js/global-constructors-expected.txt 2011-08-31 04:04:06 UTC (rev 94147)
@@ -31,6 +31,7 @@
PASS CloseEvent.toString() is '[object CloseEventConstructor]'
PASS Comment.toString() is '[object CommentConstructor]'
PASS Counter.toString() is '[object CounterConstructor]'
+PASS CustomEvent.toString() is '[object CustomEventConstructor]'
PASS DOMException.toString() is '[object DOMExceptionConstructor]'
PASS DOMImplementation.toString() is '[object DOMImplementationConstructor]'
PASS DOMParser.toString() is '[object DOMParserConstructor]'
Modified: trunk/Source/WebCore/ChangeLog (94146 => 94147)
--- trunk/Source/WebCore/ChangeLog 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/Source/WebCore/ChangeLog 2011-08-31 04:04:06 UTC (rev 94147)
@@ -1,3 +1,31 @@
+2011-08-30 Sam Weinig <[email protected]>
+
+ Add constructor for CustomEvent
+ https://bugs.webkit.org/show_bug.cgi?id=67248
+
+ Reviewed by Dan Bernstein.
+
+ Test: fast/events/constructors/custom-event-constructor.html
+
+ * bindings/generic/EventConstructors.h:
+ Add definition for CustomEvent constructor.
+
+ * bindings/js/JSEventConstructors.cpp:
+ Add CustomEvent #includes.
+
+ * dom/CustomEvent.cpp:
+ (WebCore::CustomEventInit::CustomEventInit):
+ (WebCore::CustomEvent::CustomEvent):
+ * dom/CustomEvent.h:
+ (WebCore::CustomEvent::create):
+ Add Initializer./
+
+ * dom/CustomEvent.idl:
+ Make constructible.
+
+ * page/DOMWindow.idl:
+ Add CustomEvent attribute.
+
2011-08-30 Ryosuke Niwa <[email protected]>
Get rid of toInputElement()
Modified: trunk/Source/WebCore/bindings/generic/EventConstructors.h (94146 => 94147)
--- trunk/Source/WebCore/bindings/generic/EventConstructors.h 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/Source/WebCore/bindings/generic/EventConstructors.h 2011-08-31 04:04:06 UTC (rev 94147)
@@ -35,9 +35,17 @@
FILL_PROPERTY(cancelable) \
DICTIONARY_END(Event)
+#define INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_CUSTOM_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
+ \
+ DICTIONARY_START(CustomEvent) \
+ FILL_PARENT_PROPERTIES(Event) \
+ FILL_PROPERTY(detail) \
+ DICTIONARY_END(CustomEvent)
+
#define INSTANTIATE_ALL_EVENT_INITIALIZING_CONSTRUCTORS(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
+ INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_CUSTOM_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp (94146 => 94147)
--- trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp 2011-08-31 04:04:06 UTC (rev 94147)
@@ -26,7 +26,9 @@
#include "config.h"
#include "EventConstructors.h"
+#include "CustomEvent.h"
#include "Event.h"
+#include "JSCustomEvent.h"
#include "JSDictionary.h"
#include "JSEvent.h"
#include <runtime/Error.h>
Modified: trunk/Source/WebCore/dom/CustomEvent.cpp (94146 => 94147)
--- trunk/Source/WebCore/dom/CustomEvent.cpp 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/Source/WebCore/dom/CustomEvent.cpp 2011-08-31 04:04:06 UTC (rev 94147)
@@ -26,14 +26,23 @@
#include "config.h"
#include "CustomEvent.h"
-#include "EventNames.h"
-
namespace WebCore {
+CustomEventInit::CustomEventInit()
+{
+}
+
+
CustomEvent::CustomEvent()
{
}
+CustomEvent::CustomEvent(const AtomicString& type, const CustomEventInit& initializer)
+ : Event(type, initializer)
+ , m_detail(initializer.detail)
+{
+}
+
CustomEvent::~CustomEvent()
{
}
Modified: trunk/Source/WebCore/dom/CustomEvent.h (94146 => 94147)
--- trunk/Source/WebCore/dom/CustomEvent.h 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/Source/WebCore/dom/CustomEvent.h 2011-08-31 04:04:06 UTC (rev 94147)
@@ -28,10 +28,15 @@
#include "Event.h"
#include "ScriptValue.h"
-#include <wtf/text/AtomicString.h>
namespace WebCore {
+struct CustomEventInit : public EventInit {
+ CustomEventInit();
+
+ ScriptValue detail;
+};
+
class CustomEvent : public Event {
public:
virtual ~CustomEvent();
@@ -41,6 +46,11 @@
return adoptRef(new CustomEvent);
}
+ static PassRefPtr<CustomEvent> create(const AtomicString& type, const CustomEventInit& initializer)
+ {
+ return adoptRef(new CustomEvent(type, initializer));
+ }
+
void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue detail);
virtual bool isCustomEvent() const;
@@ -49,6 +59,7 @@
private:
CustomEvent();
+ CustomEvent(const AtomicString& type, const CustomEventInit& initializer);
ScriptValue m_detail;
};
Modified: trunk/Source/WebCore/dom/CustomEvent.idl (94146 => 94147)
--- trunk/Source/WebCore/dom/CustomEvent.idl 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/Source/WebCore/dom/CustomEvent.idl 2011-08-31 04:04:06 UTC (rev 94147)
@@ -27,7 +27,10 @@
#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
// Introduced in DOM Level 3:
- interface CustomEvent : Event {
+ interface [
+ CanBeConstructed,
+ CustomConstructFunction
+ ] CustomEvent : Event {
readonly attribute DOMObject detail;
Modified: trunk/Source/WebCore/page/DOMWindow.idl (94146 => 94147)
--- trunk/Source/WebCore/page/DOMWindow.idl 2011-08-31 02:48:01 UTC (rev 94146)
+++ trunk/Source/WebCore/page/DOMWindow.idl 2011-08-31 04:04:06 UTC (rev 94147)
@@ -519,6 +519,8 @@
attribute [Conditional=WEB_AUDIO] AudioPannerNodeConstructor webkitAudioPannerNode; // Needed for panning model constants
attribute EventConstructor Event;
+ attribute CustomEventConstructor CustomEvent;
+
attribute BeforeLoadEventConstructor BeforeLoadEvent;
attribute HashChangeEventConstructor HashChangeEvent;
attribute KeyboardEventConstructor KeyboardEvent;