Implement a PageTransitionEvent constructor for JSC
authorharaken@google.com <haraken@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2011 07:40:25 +0000 (07:40 +0000)
committerharaken@google.com <haraken@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2011 07:40:25 +0000 (07:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68048

Reviewed by Sam Weinig.

Source/WebCore:

The spec for the PageTransitionEvent constructor is here:
http://www.whatwg.org/specs/web-apps/current-work/#pagetransitionevent

Test: fast/events/constructors/page-transition-event-constructor.html

* bindings/generic/EventConstructors.h: Added a definition for the PageTransitionEvent constructor.
* bindings/js/JSEventConstructors.cpp: Added #includes for PageTransitionEvent.
* dom/PageTransitionEvent.cpp:
(WebCore::PageTransitionEventInit::PageTransitionEventInit):
(WebCore::PageTransitionEvent::PageTransitionEvent):
(WebCore::PageTransitionEvent::initPageTransitionEvent):
* dom/PageTransitionEvent.h: Added a definition for PageTransitionEventInit.
(WebCore::PageTransitionEvent::create):
(WebCore::PageTransitionEvent::isPageTransitionEvent):
(WebCore::PageTransitionEvent::persisted):
* dom/PageTransitionEvent.idl: Makes PageTransitionEvent constructible.

LayoutTests:

page-transition-event-constructor.html checks the behavior of the PageTransitionEvent constructor.

* fast/dom/constructed-objects-prototypes-expected.txt: Added PageTransitionEvent.
* fast/events/constructors/page-transition-event-constructor-expected.txt: Added.
* fast/events/constructors/page-transition-event-constructor.html: Added.
* platform/chromium/test_expectations.txt: Skipped page-transition-event-constructor.html, since V8 does not yet have the PageTransitionEvent constructor.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt
LayoutTests/fast/events/constructors/page-transition-event-constructor.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/generic/EventConstructors.h
Source/WebCore/bindings/js/JSEventConstructors.cpp
Source/WebCore/dom/PageTransitionEvent.cpp
Source/WebCore/dom/PageTransitionEvent.h
Source/WebCore/dom/PageTransitionEvent.idl

index 6699d2a..5e0f425 100644 (file)
@@ -1,3 +1,17 @@
+2011-09-14  Kentaro Hara  <haraken@google.com>
+
+        Implement a PageTransitionEvent constructor for JSC
+        https://bugs.webkit.org/show_bug.cgi?id=68048
+
+        Reviewed by Sam Weinig.
+
+        page-transition-event-constructor.html checks the behavior of the PageTransitionEvent constructor.
+
+        * fast/dom/constructed-objects-prototypes-expected.txt: Added PageTransitionEvent.
+        * fast/events/constructors/page-transition-event-constructor-expected.txt: Added.
+        * fast/events/constructors/page-transition-event-constructor.html: Added.
+        * platform/chromium/test_expectations.txt: Skipped page-transition-event-constructor.html, since V8 does not yet have the PageTransitionEvent constructor.
+
 2011-09-13  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r95058.
index d365159..316a4dd 100644 (file)
@@ -21,6 +21,8 @@ PASS (new inner.MessageChannel()).isInner is true
 PASS (new inner.MessageChannel()).constructor.isInner is true
 PASS (new inner.Option()).isInner is true
 PASS (new inner.Option()).constructor.isInner is true
+PASS (new inner.PageTransitionEvent()).isInner is true
+PASS (new inner.PageTransitionEvent()).constructor.isInner is true
 PASS (new inner.ProgressEvent()).isInner is true
 PASS (new inner.ProgressEvent()).constructor.isInner is true
 PASS (new inner.WebKitAnimationEvent()).isInner is true
diff --git a/LayoutTests/fast/events/constructors/page-transition-event-constructor.html b/LayoutTests/fast/events/constructors/page-transition-event-constructor.html
new file mode 100644 (file)
index 0000000..245d719
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("This tests the constructor for the PageTransitionEvent DOM class.");
+
+// No initializer is passed.
+shouldBe("new PageTransitionEvent('eventType').bubbles", "false");
+shouldBe("new PageTransitionEvent('eventType').cancelable", "false");
+shouldBe("new PageTransitionEvent('eventType').persisted", "false");
+
+// bubbles is passed.
+shouldBe("new PageTransitionEvent('eventType', { bubbles: false }).bubbles", "false");
+shouldBe("new PageTransitionEvent('eventType', { bubbles: true }).bubbles", "true");
+
+// cancelable is passed.
+shouldBe("new PageTransitionEvent('eventType', { cancelable: false }).cancelable", "false");
+shouldBe("new PageTransitionEvent('eventType', { cancelable: true }).cancelable", "true");
+
+// persisted is passed.
+shouldBe("new PageTransitionEvent('eventType', { persisted: false }).persisted", "false");
+shouldBe("new PageTransitionEvent('eventType', { persisted: true }).persisted", "true");
+
+// All initializers are passed.
+shouldBe("new PageTransitionEvent('eventType', { bubbles: true, cancelable: true, persisted: true }).bubbles", "true");
+shouldBe("new PageTransitionEvent('eventType', { bubbles: true, cancelable: true, persisted: true }).cancelable", "true");
+shouldBe("new PageTransitionEvent('eventType', { bubbles: true, cancelable: true, persisted: true }).persisted", "true");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 8cdc7e3..5117097 100644 (file)
@@ -64,6 +64,9 @@ BUGCR84572 SKIP : storage/storageinfo-no-callbacks.html = FAIL
 // to re-enable these "in the next few weeks".
 BUGPKASTING SKIP : animations/animation-api-1.html = TEXT
 
+// This will soon be fixed after implementing a PageTransitionEvent constructor for V8.
+BUGWK68048 : fast/events/constructors/page-transition-event-constructor.html = FAIL
+
 // Unskip after implementing DRT support for setDefersLoading and goBack.
 BUGWK60877 SKIP : loader/navigation-while-deferring-loads.html = FAIL
 BUGWK60877 SKIP : loader/load-defer-resume-crash.html = FAIL
index a918006..e6fd871 100644 (file)
@@ -1,3 +1,27 @@
+2011-09-14  Kentaro Hara  <haraken@google.com>
+
+        Implement a PageTransitionEvent constructor for JSC
+        https://bugs.webkit.org/show_bug.cgi?id=68048
+
+        Reviewed by Sam Weinig.
+
+        The spec for the PageTransitionEvent constructor is here:
+        http://www.whatwg.org/specs/web-apps/current-work/#pagetransitionevent
+
+        Test: fast/events/constructors/page-transition-event-constructor.html
+
+        * bindings/generic/EventConstructors.h: Added a definition for the PageTransitionEvent constructor.
+        * bindings/js/JSEventConstructors.cpp: Added #includes for PageTransitionEvent.
+        * dom/PageTransitionEvent.cpp:
+        (WebCore::PageTransitionEventInit::PageTransitionEventInit):
+        (WebCore::PageTransitionEvent::PageTransitionEvent):
+        (WebCore::PageTransitionEvent::initPageTransitionEvent):
+        * dom/PageTransitionEvent.h: Added a definition for PageTransitionEventInit.
+        (WebCore::PageTransitionEvent::create):
+        (WebCore::PageTransitionEvent::isPageTransitionEvent):
+        (WebCore::PageTransitionEvent::persisted):
+        * dom/PageTransitionEvent.idl: Makes PageTransitionEvent constructible.
+
 2011-09-13  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r95058.
index 5cd4ba5..55ad140 100644 (file)
@@ -67,6 +67,13 @@ namespace WebCore {
         FILL_PROPERTY(newURL) \
     DICTIONARY_END(HashChangeEvent)
 
+#define INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_PAGE_TRANSITION_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
+    \
+    DICTIONARY_START(PageTransitionEvent) \
+        FILL_PARENT_PROPERTIES(Event) \
+        FILL_PROPERTY(persisted) \
+    DICTIONARY_END(PageTransitionEvent)
+
 
 #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) \
@@ -74,6 +81,7 @@ namespace WebCore {
     INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_PROGRESS_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
     INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_WEBKIT_ANIMATION_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
     INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_HASH_CHANGE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
+    INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_PAGE_TRANSITION_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
 
 } // namespace WebCore
 
index 2dce28b..ae2f0a2 100644 (file)
 #include "JSDictionary.h"
 #include "JSEvent.h"
 #include "JSHashChangeEvent.h"
+#include "JSPageTransitionEvent.h"
 #include "JSProgressEvent.h"
 #include "JSWebKitAnimationEvent.h"
+#include "PageTransitionEvent.h"
 #include "ProgressEvent.h"
 #include "WebKitAnimationEvent.h"
 #include <runtime/Error.h>
index f9c487d..fa7d95d 100644 (file)
 #include "EventNames.h"
 
 namespace WebCore {
-        
+
+PageTransitionEventInit::PageTransitionEventInit()
+    : persisted(false)
+{
+}
+
 PageTransitionEvent::PageTransitionEvent()
     : m_persisted(false)
 {
@@ -41,6 +46,12 @@ PageTransitionEvent::PageTransitionEvent(const AtomicString& type, bool persiste
 {
 }
 
+PageTransitionEvent::PageTransitionEvent(const AtomicString& type, const PageTransitionEventInit& initializer)
+    : Event(type, initializer)
+    , m_persisted(initializer.persisted)
+{
+}
+
 PageTransitionEvent::~PageTransitionEvent()
 {
 }
@@ -52,9 +63,9 @@ void PageTransitionEvent::initPageTransitionEvent(const AtomicString& type,
 {
     if (dispatched())
         return;
-    
+
     initEvent(type, canBubbleArg, cancelableArg);
-    
+
     m_persisted = persisted;
 }
 
index 33c5a0c..2ac6858 100644 (file)
 
 namespace WebCore {
 
-    class PageTransitionEvent : public Event {
-    public:
-        static PassRefPtr<PageTransitionEvent> create()
-        {
-            return adoptRef(new PageTransitionEvent);
-        }
-        static PassRefPtr<PageTransitionEvent> create(const AtomicString& type, bool persisted)
-        {
-            return adoptRef(new PageTransitionEvent(type, persisted));
-        }
+struct PageTransitionEventInit : public EventInit {
+    PageTransitionEventInit();
 
-        virtual ~PageTransitionEvent();
+    bool persisted;
+};
 
-        void initPageTransitionEvent(const AtomicString& type, 
-                                bool canBubbleArg,
-                                bool cancelableArg,
-                                bool persisted);
+class PageTransitionEvent : public Event {
+public:
+    static PassRefPtr<PageTransitionEvent> create()
+    {
+        return adoptRef(new PageTransitionEvent);
+    }
+    static PassRefPtr<PageTransitionEvent> create(const AtomicString& type, bool persisted)
+    {
+        return adoptRef(new PageTransitionEvent(type, persisted));
+    }
+    static PassRefPtr<PageTransitionEvent> create(const AtomicString& type, const PageTransitionEventInit& initializer)
+    {
+        return adoptRef(new PageTransitionEvent(type, initializer));
+    }
 
-        virtual bool isPageTransitionEvent() const { return true; }
+    virtual ~PageTransitionEvent();
 
-        bool persisted() const { return m_persisted; }
+    void initPageTransitionEvent(const AtomicString& type, 
+                                 bool canBubbleArg,
+                                 bool cancelableArg,
+                                 bool persisted);
 
-    private:
-        PageTransitionEvent();
-        PageTransitionEvent(const AtomicString& type, bool persisted);
+    virtual bool isPageTransitionEvent() const { return true; }
 
-        bool m_persisted;
-    };
+    bool persisted() const { return m_persisted; }
+
+private:
+    PageTransitionEvent();
+    PageTransitionEvent(const AtomicString& type, bool persisted);
+    PageTransitionEvent(const AtomicString&, const PageTransitionEventInit&);
+
+    bool m_persisted;
+};
 
 } // namespace WebCore
 
index 7703f8f..dab23ae 100644 (file)
 
 module events {
 
-    interface PageTransitionEvent : Event {
+    interface [
+        CanBeConstructed,
+        CustomConstructFunction
+    ] PageTransitionEvent : Event {
 
         readonly attribute boolean persisted;