Commit 1a8cc9d9 authored by weinig@apple.com's avatar weinig@apple.com

Document.createEvent should support all the interfaces of Event we got

https://bugs.webkit.org/show_bug.cgi?id=67568

Reviewed by Anders Carlsson.

Source/WebCore: 

Updated fast/events/event-creation.html

* dom/BeforeLoadEvent.h:
(WebCore::BeforeLoadEvent::create):
(WebCore::BeforeLoadEvent::BeforeLoadEvent):
Added empty create.
        
* dom/Document.cpp:
(WebCore::Document::createEvent):
Add missing interfaces.

* dom/HashChangeEvent.h:
(WebCore::HashChangeEvent::create):
(WebCore::HashChangeEvent::HashChangeEvent):
Added empty create.

* page/SpeechInputEvent.cpp:
(WebCore::SpeechInputEvent::create):
(WebCore::SpeechInputEvent::SpeechInputEvent):
(WebCore::SpeechInputEvent::~SpeechInputEvent):
* page/SpeechInputEvent.h:
Added empty create.

LayoutTests: 

* fast/events/event-creation.html:
Converted to shouldBe style test, changed prototype check to us instanceof and constructor check,
added enumeration based catchall.

* fast/events/event-instanceof-expected.txt: Removed.
* fast/events/event-instanceof.html: Removed.
* fast/events/script-tests/event-instanceof.js: Removed.
Moved contents to fast/events/event-creation.html.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8ef8e5d8
2011-09-04 Sam Weinig <sam@webkit.org>
Document.createEvent should support all the interfaces of Event we got
https://bugs.webkit.org/show_bug.cgi?id=67568
Reviewed by Anders Carlsson.
* fast/events/event-creation.html:
Converted to shouldBe style test, changed prototype check to us instanceof and constructor check,
added enumeration based catchall.
* fast/events/event-instanceof-expected.txt: Removed.
* fast/events/event-instanceof.html: Removed.
* fast/events/script-tests/event-instanceof.js: Removed.
Moved contents to fast/events/event-creation.html.
2011-09-04 Ilya Tikhonovsky <loislo@chromium.org>
Unreviewed fix for chromium expectations.
This diff is collapsed.
This tests that the Event classes have constructors.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS event instanceof window.Event is true
PASS event.constructor === window.Event is true
PASS uiEvent instanceof window.UIEvent is true
PASS uiEvent instanceof window.Event is true
PASS uiEvent.constructor === window.UIEvent is true
PASS keyboardEvent instanceof window.KeyboardEvent is true
PASS keyboardEvent instanceof window.UIEvent is true
PASS keyboardEvent instanceof window.Event is true
PASS keyboardEvent.constructor === window.KeyboardEvent is true
PASS mouseEvent instanceof window.MouseEvent is true
PASS mouseEvent instanceof window.UIEvent is true
PASS mouseEvent instanceof window.Event is true
PASS mouseEvent.constructor === window.MouseEvent is true
PASS wheelEvent instanceof window.WheelEvent is true
PASS wheelEvent instanceof window.UIEvent is true
PASS wheelEvent instanceof window.Event is true
PASS wheelEvent.constructor === window.WheelEvent is true
PASS mutationEvent instanceof window.MutationEvent is true
PASS mutationEvent instanceof window.Event is true
PASS mutationEvent.constructor === window.MutationEvent is true
PASS overflowEvent instanceof window.OverflowEvent is true
PASS overflowEvent instanceof window.Event is true
PASS overflowEvent.constructor === window.OverflowEvent is true
PASS progressEvent instanceof window.ProgressEvent is true
PASS progressEvent instanceof window.Event is true
PASS progressEvent.constructor === window.ProgressEvent is true
PASS textEvent instanceof window.TextEvent is true
PASS textEvent instanceof window.Event is true
PASS textEvent.constructor === window.TextEvent is true
PASS messageEvent instanceof window.MessageEvent is true
PASS messageEvent instanceof window.Event is true
PASS messageEvent.constructor === window.MessageEvent is true
PASS animationEvent instanceof window.WebKitAnimationEvent is true
PASS animationEvent instanceof window.Event is true
PASS animationEvent.constructor === window.WebKitAnimationEvent is true
PASS transitionEvent instanceof window.WebKitTransitionEvent is true
PASS transitionEvent instanceof window.Event is true
PASS transitionEvent.constructor === window.WebKitTransitionEvent is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<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 src="script-tests/event-instanceof.js"></script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
description("This tests that the Event classes have constructors.");
var event = document.createEvent("Event");
shouldBeTrue("event instanceof window.Event");
shouldBeTrue("event.constructor === window.Event");
var uiEvent = document.createEvent("UIEvent");
shouldBeTrue("uiEvent instanceof window.UIEvent");
shouldBeTrue("uiEvent instanceof window.Event");
shouldBeTrue("uiEvent.constructor === window.UIEvent");
var keyboardEvent = document.createEvent("KeyboardEvent");
shouldBeTrue("keyboardEvent instanceof window.KeyboardEvent");
shouldBeTrue("keyboardEvent instanceof window.UIEvent");
shouldBeTrue("keyboardEvent instanceof window.Event");
shouldBeTrue("keyboardEvent.constructor === window.KeyboardEvent");
var mouseEvent = document.createEvent("MouseEvent");
shouldBeTrue("mouseEvent instanceof window.MouseEvent");
shouldBeTrue("mouseEvent instanceof window.UIEvent");
shouldBeTrue("mouseEvent instanceof window.Event");
shouldBeTrue("mouseEvent.constructor === window.MouseEvent");
var wheelEvent = document.createEvent("WheelEvent");
shouldBeTrue("wheelEvent instanceof window.WheelEvent");
shouldBeTrue("wheelEvent instanceof window.UIEvent");
shouldBeTrue("wheelEvent instanceof window.Event");
shouldBeTrue("wheelEvent.constructor === window.WheelEvent");
var mutationEvent = document.createEvent("MutationEvent");
shouldBeTrue("mutationEvent instanceof window.MutationEvent");
shouldBeTrue("mutationEvent instanceof window.Event");
shouldBeTrue("mutationEvent.constructor === window.MutationEvent");
var overflowEvent = document.createEvent("OverflowEvent");
shouldBeTrue("overflowEvent instanceof window.OverflowEvent");
shouldBeTrue("overflowEvent instanceof window.Event");
shouldBeTrue("overflowEvent.constructor === window.OverflowEvent");
var progressEvent = document.createEvent("ProgressEvent");
shouldBeTrue("progressEvent instanceof window.ProgressEvent");
shouldBeTrue("progressEvent instanceof window.Event");
shouldBeTrue("progressEvent.constructor === window.ProgressEvent");
var textEvent = document.createEvent("TextEvent");
shouldBeTrue("textEvent instanceof window.TextEvent");
shouldBeTrue("textEvent instanceof window.Event");
shouldBeTrue("textEvent.constructor === window.TextEvent");
var messageEvent = document.createEvent("MessageEvent");
shouldBeTrue("messageEvent instanceof window.MessageEvent");
shouldBeTrue("messageEvent instanceof window.Event");
shouldBeTrue("messageEvent.constructor === window.MessageEvent");
var animationEvent = document.createEvent("WebKitAnimationEvent");
shouldBeTrue("animationEvent instanceof window.WebKitAnimationEvent");
shouldBeTrue("animationEvent instanceof window.Event");
shouldBeTrue("animationEvent.constructor === window.WebKitAnimationEvent");
var transitionEvent = document.createEvent("WebKitTransitionEvent");
shouldBeTrue("transitionEvent instanceof window.WebKitTransitionEvent");
shouldBeTrue("transitionEvent instanceof window.Event");
shouldBeTrue("transitionEvent.constructor === window.WebKitTransitionEvent");
var successfullyParsed = true;
2011-09-04 Sam Weinig <sam@webkit.org>
Document.createEvent should support all the interfaces of Event we got
https://bugs.webkit.org/show_bug.cgi?id=67568
Reviewed by Anders Carlsson.
Updated fast/events/event-creation.html
* dom/BeforeLoadEvent.h:
(WebCore::BeforeLoadEvent::create):
(WebCore::BeforeLoadEvent::BeforeLoadEvent):
Added empty create.
* dom/Document.cpp:
(WebCore::Document::createEvent):
Add missing interfaces.
* dom/HashChangeEvent.h:
(WebCore::HashChangeEvent::create):
(WebCore::HashChangeEvent::HashChangeEvent):
Added empty create.
* page/SpeechInputEvent.cpp:
(WebCore::SpeechInputEvent::create):
(WebCore::SpeechInputEvent::SpeechInputEvent):
(WebCore::SpeechInputEvent::~SpeechInputEvent):
* page/SpeechInputEvent.h:
Added empty create.
2011-09-04 Adam Barth <abarth@webkit.org>
[Chromium] Add memory threshold values to WebKitPlatformSupport.h
......@@ -36,6 +36,11 @@ class BeforeLoadEvent : public Event {
public:
virtual bool isBeforeLoadEvent() const { return true; }
static PassRefPtr<BeforeLoadEvent> create()
{
return adoptRef(new BeforeLoadEvent);
}
static PassRefPtr<BeforeLoadEvent> create(const String& url)
{
return adoptRef(new BeforeLoadEvent(url));
......@@ -54,10 +59,15 @@ public:
const String& url() const { return m_url; }
private:
BeforeLoadEvent()
{
}
BeforeLoadEvent(const String& url)
: Event(eventNames().beforeloadEvent, false, true)
, m_url(url)
{}
{
}
String m_url;
};
......
......@@ -31,6 +31,7 @@
#include "AnimationController.h"
#include "Attr.h"
#include "Attribute.h"
#include "BeforeLoadEvent.h"
#include "CDATASection.h"
#include "CSSPrimitiveValueCache.h"
#include "CSSStyleSelector.h"
......@@ -41,13 +42,14 @@
#include "Chrome.h"
#include "ChromeClient.h"
#include "Comment.h"
#include "CompositionEvent.h"
#include "Console.h"
#include "ContentSecurityPolicy.h"
#include "CookieJar.h"
#include "CustomEvent.h"
#include "DateComponents.h"
#include "DOMImplementation.h"
#include "DOMWindow.h"
#include "DateComponents.h"
#include "DeviceMotionEvent.h"
#include "DeviceOrientationEvent.h"
#include "DocumentFragment.h"
......@@ -58,6 +60,7 @@
#include "Editor.h"
#include "Element.h"
#include "EntityReference.h"
#include "ErrorEvent.h"
#include "Event.h"
#include "EventHandler.h"
#include "EventListener.h"
......@@ -72,7 +75,6 @@
#include "FrameSelection.h"
#include "FrameTree.h"
#include "FrameView.h"
#include "HashChangeEvent.h"
#include "HTMLAllCollection.h"
#include "HTMLAnchorElement.h"
#include "HTMLBodyElement.h"
......@@ -92,6 +94,7 @@
#include "HTMLStyleElement.h"
#include "HTMLTitleElement.h"
#include "HTTPParsers.h"
#include "HashChangeEvent.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
#include "ImageLoader.h"
......@@ -149,6 +152,7 @@
#include "WheelEvent.h"
#include "XMLDocumentParser.h"
#include "XMLHttpRequest.h"
#include "XMLHttpRequestProgressEvent.h"
#include "XMLNSNames.h"
#include "XMLNames.h"
#include "htmlediting.h"
......@@ -213,6 +217,27 @@
#include "ScriptedAnimationController.h"
#endif
#if ENABLE(WEB_AUDIO)
#include "AudioProcessingEvent.h"
#include "OfflineAudioCompletionEvent.h"
#endif
#if ENABLE(MEDIA_STREAM)
#include "MediaStreamEvent.h"
#endif
#if ENABLE(INPUT_SPEECH)
#include "SpeechInputEvent.h"
#endif
#if ENABLE(WEB_SOCKETS)
#include "CloseEvent.h"
#endif
#if ENABLE(WEBGL)
#include "WebGLContextEvent.h"
#endif
using namespace std;
using namespace WTF;
using namespace Unicode;
......@@ -3440,8 +3465,16 @@ PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode&
RefPtr<Event> event;
if (eventType == "Event" || eventType == "Events" || eventType == "HTMLEvents")
event = Event::create();
else if (eventType == "BeforeLoadEvent")
event = BeforeLoadEvent::create();
else if (eventType == "CompositionEvent")
event = CompositionEvent::create();
else if (eventType == "CustomEvent")
event = CustomEvent::create();
else if (eventType == "ErrorEvent")
event = ErrorEvent::create();
else if (eventType == "HashChangeEvent")
event = HashChangeEvent::create();
else if (eventType == "KeyboardEvent" || eventType == "KeyboardEvents")
event = KeyboardEvent::create();
else if (eventType == "MessageEvent")
......@@ -3458,10 +3491,6 @@ PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode&
event = PopStateEvent::create();
else if (eventType == "ProgressEvent")
event = ProgressEvent::create();
#if ENABLE(DOM_STORAGE)
else if (eventType == "StorageEvent")
event = StorageEvent::create();
#endif
else if (eventType == "TextEvent")
event = TextEvent::create();
else if (eventType == "UIEvent" || eventType == "UIEvents")
......@@ -3472,10 +3501,38 @@ PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode&
event = WebKitTransitionEvent::create();
else if (eventType == "WheelEvent")
event = WheelEvent::create();
else if (eventType == "XMLHttpRequestProgressEvent")
event = XMLHttpRequestProgressEvent::create();
#if ENABLE(WEB_AUDIO)
else if (eventType == "AudioProcessingEvent")
event = AudioProcessingEvent::create();
else if (eventType == "OfflineAudioCompletionEvent")
event = OfflineAudioCompletionEvent::create();
#endif
#if ENABLE(MEDIA_STREAM)
else if (eventType == "MediaStreamEvent")
event = MediaStreamEvent::create();
#endif
#if ENABLE(INPUT_SPEECH)
else if (eventType == "SpeechInputEvent")
event = SpeechInputEvent::create();
#endif
#if ENABLE(WEB_SOCKETS)
else if (eventType == "CloseEvent")
event = CloseEvent::create();
#endif
#if ENABLE(WEBGL)
else if (eventType == "WebGLContextEvent")
event = WebGLContextEvent::create();
#endif
#if ENABLE(DOM_STORAGE)
else if (eventType == "StorageEvent")
event = StorageEvent::create();
#endif
#if ENABLE(SVG)
else if (eventType == "SVGEvents")
event = Event::create();
else if (eventType == "SVGZoomEvents")
else if (eventType == "SVGZoomEvent" || eventType == "SVGZoomEvents")
event = SVGZoomEvent::create();
#endif
#if ENABLE(TOUCH_EVENTS)
......
......@@ -30,6 +30,11 @@ class HashChangeEvent : public Event {
public:
virtual bool isHashChangeEvent() const { return true; }
static PassRefPtr<HashChangeEvent> create()
{
return adoptRef(new HashChangeEvent);
}
static PassRefPtr<HashChangeEvent> create(const String& oldURL, const String& newURL)
{
return adoptRef(new HashChangeEvent(oldURL, newURL));
......@@ -50,11 +55,16 @@ public:
const String& newURL() const { return m_newURL; }
private:
HashChangeEvent()
{
}
HashChangeEvent(const String& oldURL, const String& newURL)
: Event(eventNames().hashchangeEvent, false, false)
, m_oldURL(oldURL)
, m_newURL(newURL)
{}
{
}
String m_oldURL;
String m_newURL;
......
......@@ -35,12 +35,18 @@
namespace WebCore {
PassRefPtr<SpeechInputEvent> SpeechInputEvent::create()
{
return adoptRef(new SpeechInputEvent);
}
PassRefPtr<SpeechInputEvent> SpeechInputEvent::create(const AtomicString& eventType, const SpeechInputResultArray& results)
{
return adoptRef(new SpeechInputEvent(eventType, results));
}
SpeechInputEvent::~SpeechInputEvent() {
SpeechInputEvent::SpeechInputEvent()
{
}
SpeechInputEvent::SpeechInputEvent(const AtomicString& eventType, const SpeechInputResultArray& results)
......@@ -49,6 +55,10 @@ SpeechInputEvent::SpeechInputEvent(const AtomicString& eventType, const SpeechIn
{
}
SpeechInputEvent::~SpeechInputEvent()
{
}
} // namespace WebCore
#endif // ENABLE(INPUT_SPEECH)
......@@ -39,6 +39,7 @@ namespace WebCore {
class SpeechInputEvent : public Event {
public:
static PassRefPtr<SpeechInputEvent> create();
static PassRefPtr<SpeechInputEvent> create(const AtomicString& eventType, const SpeechInputResultArray& results);
~SpeechInputEvent();
......@@ -47,6 +48,7 @@ public:
SpeechInputResultList* results() const { return m_results.get(); }
private:
SpeechInputEvent();
SpeechInputEvent(const AtomicString& eventType, const SpeechInputResultArray& results);
RefPtr<SpeechInputResultList> m_results;
......
......@@ -33,11 +33,20 @@
namespace WebCore {
PassRefPtr<AudioProcessingEvent> AudioProcessingEvent::create()
{
return adoptRef(new AudioProcessingEvent);
}
PassRefPtr<AudioProcessingEvent> AudioProcessingEvent::create(PassRefPtr<AudioBuffer> inputBuffer, PassRefPtr<AudioBuffer> outputBuffer)
{
return adoptRef(new AudioProcessingEvent(inputBuffer, outputBuffer));
}
AudioProcessingEvent::AudioProcessingEvent()
{
}
AudioProcessingEvent::AudioProcessingEvent(PassRefPtr<AudioBuffer> inputBuffer, PassRefPtr<AudioBuffer> outputBuffer)
: Event(eventNames().audioprocessEvent, true, false)
, m_inputBuffer(inputBuffer)
......
......@@ -36,6 +36,7 @@ class AudioBuffer;
class AudioProcessingEvent : public Event {
public:
static PassRefPtr<AudioProcessingEvent> create();
static PassRefPtr<AudioProcessingEvent> create(PassRefPtr<AudioBuffer> inputBuffer, PassRefPtr<AudioBuffer> outputBuffer);
virtual ~AudioProcessingEvent();
......@@ -46,6 +47,7 @@ public:
AudioBuffer* outputBuffer() { return m_outputBuffer.get(); }
private:
AudioProcessingEvent();
AudioProcessingEvent(PassRefPtr<AudioBuffer> inputBuffer, PassRefPtr<AudioBuffer> outputBuffer);
RefPtr<AudioBuffer> m_inputBuffer;
......
......@@ -33,11 +33,21 @@
namespace WebCore {
PassRefPtr<OfflineAudioCompletionEvent> OfflineAudioCompletionEvent::create()
{
return adoptRef(new OfflineAudioCompletionEvent);
}
PassRefPtr<OfflineAudioCompletionEvent> OfflineAudioCompletionEvent::create(PassRefPtr<AudioBuffer> renderedBuffer)
{
return adoptRef(new OfflineAudioCompletionEvent(renderedBuffer));
}
OfflineAudioCompletionEvent::OfflineAudioCompletionEvent()
{
}
OfflineAudioCompletionEvent::OfflineAudioCompletionEvent(PassRefPtr<AudioBuffer> renderedBuffer)
: Event(eventNames().completeEvent, true, false)
, m_renderedBuffer(renderedBuffer)
......
......@@ -36,6 +36,7 @@ class AudioBuffer;
class OfflineAudioCompletionEvent : public Event {
public:
static PassRefPtr<OfflineAudioCompletionEvent> create();
static PassRefPtr<OfflineAudioCompletionEvent> create(PassRefPtr<AudioBuffer> renderedBuffer);
virtual ~OfflineAudioCompletionEvent();
......@@ -45,6 +46,7 @@ public:
AudioBuffer* renderedBuffer() { return m_renderedBuffer.get(); }
private:
OfflineAudioCompletionEvent();
OfflineAudioCompletionEvent(PassRefPtr<AudioBuffer> renderedBuffer);
RefPtr<AudioBuffer> m_renderedBuffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment