2011-06-06 Paul Kinlan <paulkinlan@google.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jun 2011 21:15:45 +0000 (21:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jun 2011 21:15:45 +0000 (21:15 +0000)
        Reviewed by Jeremy Orlow.

        Adds a test for firing popstate, using window.dispatchEvent.
        https://bugs.webkit.org/show_bug.cgi?id=62099

        * fast/events/fire-popstate-event-expected.txt: Added.
        * fast/events/fire-popstate-event.html: Added.
2011-06-06  Paul Kinlan  <paulkinlan@google.com>

        Reviewed by Jeremy Orlow.

        Let developers call createEvent("PopStateEvent"), previously it wasn't
        exposed and threw an exeception.
        https://bugs.webkit.org/show_bug.cgi?id=62099

        * WebCore/dom/Document.cpp:
        * WebCore/dom/PopStateEvent.cpp:
        * WebCore/dom/PopStateEvent.h:

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

LayoutTests/ChangeLog
LayoutTests/fast/events/fire-popstate-event-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/fire-popstate-event.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/PopStateEvent.cpp
Source/WebCore/dom/PopStateEvent.h

index 5758a8a..9f8e2fa 100644 (file)
@@ -1,3 +1,13 @@
+2011-06-06  Paul Kinlan  <paulkinlan@google.com>
+
+        Reviewed by Jeremy Orlow.
+
+        Adds a test for firing popstate, using window.dispatchEvent.
+        https://bugs.webkit.org/show_bug.cgi?id=62099
+
+        * fast/events/fire-popstate-event-expected.txt: Added.
+        * fast/events/fire-popstate-event.html: Added.
+
 2011-06-06  Jessie Berlin  <jberlin@apple.com>
 
         Update the Windows-specific results after r88020 in order to get the bots green.
diff --git a/LayoutTests/fast/events/fire-popstate-event-expected.txt b/LayoutTests/fast/events/fire-popstate-event-expected.txt
new file mode 100644 (file)
index 0000000..e714b7f
--- /dev/null
@@ -0,0 +1,10 @@
+Checks that the popstate event fires when dispatched via createEvent
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Popstate state: (Success)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/fire-popstate-event.html b/LayoutTests/fast/events/fire-popstate-event.html
new file mode 100644 (file)
index 0000000..7b477d5
--- /dev/null
@@ -0,0 +1,33 @@
+
+<html>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+<body style="min-width: 5000px; min-height: 5000px">
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Checks that the popstate event fires when dispatched via createEvent');
+
+onpopstate = function(event)
+{
+    if(!!event.state && !!event.state.testValue) 
+    {
+        testPassed('Popstate state: (' + event.state.testValue +')');
+    }
+}
+
+onload = function()
+{
+    var evt = document.createEvent("PopStateEvent");
+    evt.initPopStateEvent("popstate", false, false, { testValue: "Success"} );
+    window.dispatchEvent(evt);
+}
+
+setTimeout(finishJSTest, 500);
+
+var successfullyParsed = true;
+var jsTestIsAsync = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 1d8e1b1..c40a747 100644 (file)
@@ -1,3 +1,15 @@
+2011-06-06  Paul Kinlan  <paulkinlan@google.com>
+
+        Reviewed by Jeremy Orlow.
+
+        Let developers call createEvent("PopStateEvent"), previously it wasn't
+        exposed and threw an exeception. 
+        https://bugs.webkit.org/show_bug.cgi?id=62099
+
+        * WebCore/dom/Document.cpp:
+        * WebCore/dom/PopStateEvent.cpp:
+        * WebCore/dom/PopStateEvent.h:
+
 2011-06-03  Levi Weintraub  <leviw@chromium.org>
 
         Reviewed by Eric Seidel.
index 58d1c99..a19fdd2 100644 (file)
@@ -3465,6 +3465,8 @@ PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode&
         event = OverflowEvent::create();
     else if (eventType == "PageTransitionEvent")
         event = PageTransitionEvent::create();
+    else if (eventType == "PopStateEvent")
+        event = PopStateEvent::create(); 
     else if (eventType == "ProgressEvent")
         event = ProgressEvent::create();
 #if ENABLE(DOM_STORAGE)
index bac676a..330c761 100644 (file)
 
 namespace WebCore {
 
+PopStateEvent::PopStateEvent()
+    : Event(eventNames().popstateEvent, false, true)
+{
+}
+
 PopStateEvent::PopStateEvent(PassRefPtr<SerializedScriptValue> stateObject)
     : Event(eventNames().popstateEvent, false, true)
     , m_stateObject(stateObject)
@@ -41,6 +46,16 @@ PopStateEvent::~PopStateEvent()
 {
 }
 
+PassRefPtr<PopStateEvent> PopStateEvent::create()
+{
+    return adoptRef(new PopStateEvent);
+}
+
+PassRefPtr<PopStateEvent> PopStateEvent::create(PassRefPtr<SerializedScriptValue> stateObject)
+{
+    return adoptRef(new PopStateEvent(stateObject));
+}
+
 void PopStateEvent::initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> stateObject)
 {
     if (dispatched())
index 42fbd45..0a98313 100644 (file)
@@ -37,20 +37,16 @@ class SerializedScriptValue;
 class PopStateEvent : public Event {
 public:
     virtual ~PopStateEvent();
-
-    static PassRefPtr<PopStateEvent> create(PassRefPtr<SerializedScriptValue> stateObject)
-    {
-        return adoptRef(new PopStateEvent(stateObject));
-    }
-
+    static PassRefPtr<PopStateEvent> create();
+    static PassRefPtr<PopStateEvent> create(PassRefPtr<SerializedScriptValue>);
     void initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue>);
     bool isPopStateEvent() const { return true; }
 
     SerializedScriptValue* state() const { return m_stateObject.get(); }    
 
 private:
+    PopStateEvent();
     explicit PopStateEvent(PassRefPtr<SerializedScriptValue>);
-
     RefPtr<SerializedScriptValue> m_stateObject;
 };