Title: [97324] trunk
Revision
97324
Author
[email protected]
Date
2011-10-12 17:35:15 -0700 (Wed, 12 Oct 2011)

Log Message

Implement a BeforeLoadEvent constructor for JSC
https://bugs.webkit.org/show_bug.cgi?id=69893

Reviewed by Adam Barth.

Source/WebCore:

There is no spec for the BeforeLoadEvent constructor
since it is WebKit-specific. However, judging from the current
IDL of initBeforeLoadEvent(), the constructor IDL
should be as follows.

[Constructor(DOMString type, optional BeforeLoadEventInit eventInitDict)]
interface BeforeLoadEvent : Event {
    ...;
}

dictionary BeforeLoadEventInit : EventInit {
    DOMString url;
}

Test: fast/events/constructors/before-load-event-constructor.html

* bindings/generic/EventConstructors.h: Added a definition for the BeforeLoadEvent constructor.
* bindings/js/JSEventConstructors.cpp: Added #includes for BeforeLoadEvent.
* dom/BeforeLoadEvent.h: Added a definition for BeforeLoadEventInit.
(WebCore::BeforeLoadEventInit::BeforeLoadEventInit):
(WebCore::BeforeLoadEvent::create):
(WebCore::BeforeLoadEvent::initBeforeLoadEvent):
(WebCore::BeforeLoadEvent::BeforeLoadEvent):
* dom/BeforeLoadEvent.idl: Makes BeforeLoadEvent constructible.

LayoutTests:

before-load-event-constructor.html checks the behavior of the BeforeLoadEvent constructor.

* fast/dom/constructed-objects-prototypes-expected.txt: Added inner.BeforeLoadEvent().
* fast/events/constructors/before-load-event-constructor-expected.txt: Added.
* fast/events/constructors/before-load-event-constructor.html: Added.
* platform/chromium/test_expectations.txt: Skipped before-load-event-constructor.html, since V8 does not yet have the BeforeLoadEvent constructor.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97323 => 97324)


--- trunk/LayoutTests/ChangeLog	2011-10-13 00:34:35 UTC (rev 97323)
+++ trunk/LayoutTests/ChangeLog	2011-10-13 00:35:15 UTC (rev 97324)
@@ -1,3 +1,17 @@
+2011-10-12  Kentaro Hara  <[email protected]>
+
+        Implement a BeforeLoadEvent constructor for JSC
+        https://bugs.webkit.org/show_bug.cgi?id=69893
+
+        Reviewed by Adam Barth.
+
+        before-load-event-constructor.html checks the behavior of the BeforeLoadEvent constructor.
+
+        * fast/dom/constructed-objects-prototypes-expected.txt: Added inner.BeforeLoadEvent().
+        * fast/events/constructors/before-load-event-constructor-expected.txt: Added.
+        * fast/events/constructors/before-load-event-constructor.html: Added.
+        * platform/chromium/test_expectations.txt: Skipped before-load-event-constructor.html, since V8 does not yet have the BeforeLoadEvent constructor.
+
 2011-10-12  Ben Wells  <[email protected]>
 
         Incorrect rendering with one-sided thick border and border-radius

Modified: trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt (97323 => 97324)


--- trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt	2011-10-13 00:34:35 UTC (rev 97323)
+++ trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt	2011-10-13 00:35:15 UTC (rev 97324)
@@ -5,6 +5,8 @@
 
 PASS (new inner.Audio()).isInner is true
 PASS (new inner.Audio()).constructor.isInner is true
+PASS (new inner.BeforeLoadEvent()).isInner is true
+PASS (new inner.BeforeLoadEvent()).constructor.isInner is true
 PASS (new inner.CloseEvent()).isInner is true
 PASS (new inner.CloseEvent()).constructor.isInner is true
 PASS (new inner.CustomEvent()).isInner is true

Added: trunk/LayoutTests/fast/events/constructors/before-load-event-constructor-expected.txt (0 => 97324)


--- trunk/LayoutTests/fast/events/constructors/before-load-event-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/before-load-event-constructor-expected.txt	2011-10-13 00:35:15 UTC (rev 97324)
@@ -0,0 +1,32 @@
+This tests the constructor for the BeforeLoadEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new BeforeLoadEvent('eventType').bubbles is false
+PASS new BeforeLoadEvent('eventType').cancelable is false
+PASS new BeforeLoadEvent('eventType').url is ""
+PASS new BeforeLoadEvent('eventType', { bubbles: false }).bubbles is false
+PASS new BeforeLoadEvent('eventType', { bubbles: true }).bubbles is true
+PASS new BeforeLoadEvent('eventType', { cancelable: false }).cancelable is false
+PASS new BeforeLoadEvent('eventType', { cancelable: true }).cancelable is true
+PASS new BeforeLoadEvent('eventType', { url: 'doremi' }).url is "doremi"
+PASS new BeforeLoadEvent('eventType', { url: '' }).url is ""
+PASS new BeforeLoadEvent('eventType', { url: undefined }).url is "undefined"
+PASS new BeforeLoadEvent('eventType', { url: null }).url is "null"
+PASS new BeforeLoadEvent('eventType', { url: false }).url is "false"
+PASS new BeforeLoadEvent('eventType', { url: true }).url is "true"
+PASS new BeforeLoadEvent('eventType', { url: 12345 }).url is "12345"
+PASS new BeforeLoadEvent('eventType', { url: 18446744073709551615 }).url is "18446744073709552000"
+PASS new BeforeLoadEvent('eventType', { url: NaN }).url is "NaN"
+PASS new BeforeLoadEvent('eventType', { url: [] }).url is ""
+PASS new BeforeLoadEvent('eventType', { url: [1, 2, 3] }).url is "1,2,3"
+PASS new BeforeLoadEvent('eventType', { url: {doremi: 12345} }).url is "[object Object]"
+PASS new BeforeLoadEvent('eventType', { url: {valueOf: function () { return 'doremi'; } } }).url is "[object Object]"
+PASS new BeforeLoadEvent('eventType', { bubbles: true, cancelable: true, url: 'doremi' }).bubbles is true
+PASS new BeforeLoadEvent('eventType', { bubbles: true, cancelable: true, url: 'doremi' }).cancelable is true
+PASS new BeforeLoadEvent('eventType', { bubbles: true, cancelable: true, url: 'doremi' }).url is 'doremi'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/constructors/before-load-event-constructor.html (0 => 97324)


--- trunk/LayoutTests/fast/events/constructors/before-load-event-constructor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/before-load-event-constructor.html	2011-10-13 00:35:15 UTC (rev 97324)
@@ -0,0 +1,54 @@
+<!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 BeforeLoadEvent DOM class.");
+
+// No initializer is passed.
+shouldBe("new BeforeLoadEvent('eventType').bubbles", "false");
+shouldBe("new BeforeLoadEvent('eventType').cancelable", "false");
+shouldBeEqualToString("new BeforeLoadEvent('eventType').url", "");
+
+// bubbles is passed.
+shouldBe("new BeforeLoadEvent('eventType', { bubbles: false }).bubbles", "false");
+shouldBe("new BeforeLoadEvent('eventType', { bubbles: true }).bubbles", "true");
+
+// cancelable is passed.
+shouldBe("new BeforeLoadEvent('eventType', { cancelable: false }).cancelable", "false");
+shouldBe("new BeforeLoadEvent('eventType', { cancelable: true }).cancelable", "true");
+
+// url is passed.
+// Strings.
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: 'doremi' }).url", "doremi");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: '' }).url", "");
+
+// Non-strings.
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: undefined }).url", "undefined");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: null }).url", "null");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: false }).url", "false");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: true }).url", "true");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: 12345 }).url", "12345");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: 18446744073709551615 }).url", "18446744073709552000");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: NaN }).url", "NaN");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: [] }).url", "");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: [1, 2, 3] }).url", "1,2,3");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: {doremi: 12345} }).url", "[object Object]");
+shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: {valueOf: function () { return 'doremi'; } } }).url", "[object Object]");
+
+// All initializers are passed.
+shouldBe("new BeforeLoadEvent('eventType', { bubbles: true, cancelable: true, url: 'doremi' }).bubbles", "true");
+shouldBe("new BeforeLoadEvent('eventType', { bubbles: true, cancelable: true, url: 'doremi' }).cancelable", "true");
+shouldBe("new BeforeLoadEvent('eventType', { bubbles: true, cancelable: true, url: 'doremi' }).url", "'doremi'");
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (97323 => 97324)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-10-13 00:34:35 UTC (rev 97323)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-10-13 00:35:15 UTC (rev 97324)
@@ -95,6 +95,9 @@
 BUGCR10395 SKIP : svg/custom/image-with-prefix-in-webarchive.svg = PASS FAIL
 BUGCR10395 SKIP : http/tests/webarchive = PASS FAIL
 
+// This will soon be fixed after implementing a BeforeLoadEvent constructor for V8.
+BUGWK69893 : fast/events/constructors/before-load-event-constructor.html = FAIL
+
 // According to the Chromium bug, we need to write some sort of workaround for
 // how clipboards on Windows work, or something?  That doesn't explain why this
 // fails for other platforms...

Modified: trunk/Source/WebCore/ChangeLog (97323 => 97324)


--- trunk/Source/WebCore/ChangeLog	2011-10-13 00:34:35 UTC (rev 97323)
+++ trunk/Source/WebCore/ChangeLog	2011-10-13 00:35:15 UTC (rev 97324)
@@ -1,3 +1,35 @@
+2011-10-12  Kentaro Hara  <[email protected]>
+
+        Implement a BeforeLoadEvent constructor for JSC
+        https://bugs.webkit.org/show_bug.cgi?id=69893
+
+        Reviewed by Adam Barth.
+
+        There is no spec for the BeforeLoadEvent constructor
+        since it is WebKit-specific. However, judging from the current
+        IDL of initBeforeLoadEvent(), the constructor IDL
+        should be as follows.
+
+        [Constructor(DOMString type, optional BeforeLoadEventInit eventInitDict)]
+        interface BeforeLoadEvent : Event {
+            ...;
+        }
+
+        dictionary BeforeLoadEventInit : EventInit {
+            DOMString url;
+        }
+
+        Test: fast/events/constructors/before-load-event-constructor.html
+
+        * bindings/generic/EventConstructors.h: Added a definition for the BeforeLoadEvent constructor.
+        * bindings/js/JSEventConstructors.cpp: Added #includes for BeforeLoadEvent.
+        * dom/BeforeLoadEvent.h: Added a definition for BeforeLoadEventInit.
+        (WebCore::BeforeLoadEventInit::BeforeLoadEventInit):
+        (WebCore::BeforeLoadEvent::create):
+        (WebCore::BeforeLoadEvent::initBeforeLoadEvent):
+        (WebCore::BeforeLoadEvent::BeforeLoadEvent):
+        * dom/BeforeLoadEvent.idl: Makes BeforeLoadEvent constructible.
+
 2011-10-12  Ben Wells  <[email protected]>
 
         [skia] Implement Path.currentPoint for skia

Modified: trunk/Source/WebCore/bindings/generic/EventConstructors.h (97323 => 97324)


--- trunk/Source/WebCore/bindings/generic/EventConstructors.h	2011-10-13 00:34:35 UTC (rev 97323)
+++ trunk/Source/WebCore/bindings/generic/EventConstructors.h	2011-10-13 00:35:15 UTC (rev 97324)
@@ -118,7 +118,14 @@
         FILL_PROPERTY(elapsedTime) \
     DICTIONARY_END(WebKitTransitionEvent)
 
+#define INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_BEFORE_LOAD_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
+    \
+    DICTIONARY_START(BeforeLoadEvent) \
+        FILL_PARENT_PROPERTIES(Event) \
+        FILL_PROPERTY(url) \
+    DICTIONARY_END(BeforeLoadEvent)
 
+
 #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) \
@@ -131,7 +138,9 @@
     INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_CLOSE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
     INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_MESSAGE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
     INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_WEBKIT_TRANSITION_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
+    INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_BEFORE_LOAD_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
 
+
 } // namespace WebCore
 
 #endif // EventConstructors_h

Modified: trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp (97323 => 97324)


--- trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp	2011-10-13 00:34:35 UTC (rev 97323)
+++ trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp	2011-10-13 00:35:15 UTC (rev 97324)
@@ -26,11 +26,13 @@
 #include "config.h"
 #include "EventConstructors.h"
 
+#include "BeforeLoadEvent.h"
 #include "CloseEvent.h"
 #include "CustomEvent.h"
 #include "ErrorEvent.h"
 #include "Event.h"
 #include "HashChangeEvent.h"
+#include "JSBeforeLoadEvent.h"
 #include "JSCloseEvent.h"
 #include "JSCustomEvent.h"
 #include "JSDictionary.h"

Modified: trunk/Source/WebCore/dom/BeforeLoadEvent.h (97323 => 97324)


--- trunk/Source/WebCore/dom/BeforeLoadEvent.h	2011-10-13 00:34:35 UTC (rev 97323)
+++ trunk/Source/WebCore/dom/BeforeLoadEvent.h	2011-10-13 00:35:15 UTC (rev 97324)
@@ -32,6 +32,14 @@
 
 namespace WebCore {
 
+struct BeforeLoadEventInit : public EventInit {
+    BeforeLoadEventInit()
+    {
+    };
+
+    String url;
+};
+
 class BeforeLoadEvent : public Event {
 public:
     virtual bool isBeforeLoadEvent() const { return true; }
@@ -46,11 +54,16 @@
         return adoptRef(new BeforeLoadEvent(url));
     }
 
+    static PassRefPtr<BeforeLoadEvent> create(const AtomicString& type, const BeforeLoadEventInit& initializer)
+    {
+        return adoptRef(new BeforeLoadEvent(type, initializer));
+    }
+
     void initBeforeLoadEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& url)
     {
         if (dispatched())
             return;
-        
+
         initEvent(type, canBubble, cancelable);
 
         m_url = url;
@@ -69,6 +82,12 @@
     {
     }
 
+    BeforeLoadEvent(const AtomicString& type, const BeforeLoadEventInit& initializer)
+        : Event(type, initializer)
+        , m_url(initializer.url)
+    {
+    }
+
     String m_url;
 };
 

Modified: trunk/Source/WebCore/dom/BeforeLoadEvent.idl (97323 => 97324)


--- trunk/Source/WebCore/dom/BeforeLoadEvent.idl	2011-10-13 00:34:35 UTC (rev 97323)
+++ trunk/Source/WebCore/dom/BeforeLoadEvent.idl	2011-10-13 00:35:15 UTC (rev 97324)
@@ -26,7 +26,10 @@
 
 module events {
 
-    interface BeforeLoadEvent : Event {
+    interface [
+        CanBeConstructed,
+        JSCustomConstructor
+    ] BeforeLoadEvent : Event {
         void initBeforeLoadEvent(in [Optional=CallWithDefaultValue] DOMString type,
                                  in [Optional=CallWithDefaultValue] boolean canBubble, 
                                  in [Optional=CallWithDefaultValue] boolean cancelable,
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to