Skip to content

Commit

Permalink
Implement the WebGLContextEvent constructor
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=72856

Reviewed by Adam Barth.

Source/WebCore:

This patch makes WebGLContextEvent constructable.
The spec: http://www.khronos.org/registry/webgl/specs/latest/#5.14

Test: fast/events/constructors/webgl-context-event-constructor.html

* html/canvas/WebGLContextEvent.cpp: Added an implementation of the WebGLContextEvent constructor.
(WebCore::WebGLContextEventInit::WebGLContextEventInit):
(WebCore::WebGLContextEvent::WebGLContextEvent):
* html/canvas/WebGLContextEvent.h: Added a definition of WebGLContextEventInit.
(WebCore::WebGLContextEvent::create):
* html/canvas/WebGLContextEvent.idl: Added [ConstructorTemplate=Event] IDL.

LayoutTests:

webgl-context-event-constructor.html checks the behavior of the WebGLContextEvent constructor.

* fast/dom/constructed-objects-prototypes-expected.txt: Added window.WebGLContextEvent.
* fast/events/constructors/webgl-context-event-constructor-expected.txt: Added.
* fast/events/constructors/webgl-context-event-constructor.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@101183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
haraken@chromium.org committed Nov 25, 2011
1 parent 4a03b17 commit b78f809
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 1 deletion.
13 changes: 13 additions & 0 deletions LayoutTests/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2011-11-25 Kentaro Hara <haraken@chromium.org>

Implement the WebGLContextEvent constructor
https://bugs.webkit.org/show_bug.cgi?id=72856

Reviewed by Adam Barth.

webgl-context-event-constructor.html checks the behavior of the WebGLContextEvent constructor.

* fast/dom/constructed-objects-prototypes-expected.txt: Added window.WebGLContextEvent.
* fast/events/constructors/webgl-context-event-constructor-expected.txt: Added.
* fast/events/constructors/webgl-context-event-constructor.html: Added.

2011-11-25 Ryosuke Niwa <rniwa@webkit.org>

Add missing results for Mac after r100949 and r100036.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ PASS (new inner.PopStateEvent()).isInner is true
PASS (new inner.PopStateEvent()).constructor.isInner is true
PASS (new inner.ProgressEvent()).isInner is true
PASS (new inner.ProgressEvent()).constructor.isInner is true
PASS (new inner.WebGLContextEvent()).isInner is true
PASS (new inner.WebGLContextEvent()).constructor.isInner is true
PASS (new inner.WebKitAnimationEvent()).isInner is true
PASS (new inner.WebKitAnimationEvent()).constructor.isInner is true
PASS (new inner.WebKitCSSMatrix()).isInner is true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
This tests the constructor for the WebGLContextEvent DOM class.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS new WebGLContextEvent('eventType').bubbles is false
PASS new WebGLContextEvent('eventType').cancelable is false
PASS new WebGLContextEvent('eventType').statusMessage is ""
PASS new WebGLContextEvent('eventType', { bubbles: false }).bubbles is false
PASS new WebGLContextEvent('eventType', { bubbles: true }).bubbles is true
PASS new WebGLContextEvent('eventType', { cancelable: false }).cancelable is false
PASS new WebGLContextEvent('eventType', { cancelable: true }).cancelable is true
PASS new WebGLContextEvent('eventType', { statusMessage: 'abcde' }).statusMessage is "abcde"
PASS new WebGLContextEvent('eventType', { statusMessage: '' }).statusMessage is ""
PASS new WebGLContextEvent('eventType', { statusMessage: undefined }).statusMessage is "undefined"
PASS new WebGLContextEvent('eventType', { statusMessage: null }).statusMessage is "null"
PASS new WebGLContextEvent('eventType', { statusMessage: false }).statusMessage is "false"
PASS new WebGLContextEvent('eventType', { statusMessage: true }).statusMessage is "true"
PASS new WebGLContextEvent('eventType', { statusMessage: 12345 }).statusMessage is "12345"
PASS new WebGLContextEvent('eventType', { statusMessage: 18446744073709551615 }).statusMessage is "18446744073709552000"
PASS new WebGLContextEvent('eventType', { statusMessage: NaN }).statusMessage is "NaN"
PASS new WebGLContextEvent('eventType', { statusMessage: [] }).statusMessage is ""
PASS new WebGLContextEvent('eventType', { statusMessage: [1, 2, 3] }).statusMessage is "1,2,3"
PASS new WebGLContextEvent('eventType', { statusMessage: {abcde: 12345} }).statusMessage is "[object Object]"
PASS new WebGLContextEvent('eventType', { statusMessage: {valueOf: function () { return 'abcde'; } } }).statusMessage is "[object Object]"
PASS new WebGLContextEvent('eventType', { bubbles: true, cancelable: true, statusMessage: 'abcde' }).bubbles is true
PASS new WebGLContextEvent('eventType', { bubbles: true, cancelable: true, statusMessage: 'abcde' }).cancelable is true
PASS new WebGLContextEvent('eventType', { bubbles: true, cancelable: true, statusMessage: 'abcde' }).statusMessage is 'abcde'
PASS successfullyParsed is true

TEST COMPLETE

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<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 WebGLContextEvent DOM class.");

// No initializer is passed.
shouldBe("new WebGLContextEvent('eventType').bubbles", "false");
shouldBe("new WebGLContextEvent('eventType').cancelable", "false");
shouldBeEqualToString("new WebGLContextEvent('eventType').statusMessage", "");

// bubbles is passed.
shouldBe("new WebGLContextEvent('eventType', { bubbles: false }).bubbles", "false");
shouldBe("new WebGLContextEvent('eventType', { bubbles: true }).bubbles", "true");

// cancelable is passed.
shouldBe("new WebGLContextEvent('eventType', { cancelable: false }).cancelable", "false");
shouldBe("new WebGLContextEvent('eventType', { cancelable: true }).cancelable", "true");

// statusMessage is passed.
// Strings.
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: 'abcde' }).statusMessage", "abcde");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: '' }).statusMessage", "");

// Non-strings.
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: undefined }).statusMessage", "undefined");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: null }).statusMessage", "null");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: false }).statusMessage", "false");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: true }).statusMessage", "true");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: 12345 }).statusMessage", "12345");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: 18446744073709551615 }).statusMessage", "18446744073709552000");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: NaN }).statusMessage", "NaN");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: [] }).statusMessage", "");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: [1, 2, 3] }).statusMessage", "1,2,3");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: {abcde: 12345} }).statusMessage", "[object Object]");
shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: {valueOf: function () { return 'abcde'; } } }).statusMessage", "[object Object]");

// All initializers are passed.
shouldBe("new WebGLContextEvent('eventType', { bubbles: true, cancelable: true, statusMessage: 'abcde' }).bubbles", "true");
shouldBe("new WebGLContextEvent('eventType', { bubbles: true, cancelable: true, statusMessage: 'abcde' }).cancelable", "true");
shouldBe("new WebGLContextEvent('eventType', { bubbles: true, cancelable: true, statusMessage: 'abcde' }).statusMessage", "'abcde'");
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
19 changes: 19 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
2011-11-25 Kentaro Hara <haraken@chromium.org>

Implement the WebGLContextEvent constructor
https://bugs.webkit.org/show_bug.cgi?id=72856

Reviewed by Adam Barth.

This patch makes WebGLContextEvent constructable.
The spec: http://www.khronos.org/registry/webgl/specs/latest/#5.14

Test: fast/events/constructors/webgl-context-event-constructor.html

* html/canvas/WebGLContextEvent.cpp: Added an implementation of the WebGLContextEvent constructor.
(WebCore::WebGLContextEventInit::WebGLContextEventInit):
(WebCore::WebGLContextEvent::WebGLContextEvent):
* html/canvas/WebGLContextEvent.h: Added a definition of WebGLContextEventInit.
(WebCore::WebGLContextEvent::create):
* html/canvas/WebGLContextEvent.idl: Added [ConstructorTemplate=Event] IDL.

2011-11-25 Jeff Timanus <twiz@chromium.org>

[Chromium] The DrawingBuffer::bind method was incorrectly resetting the
Expand Down
10 changes: 10 additions & 0 deletions Source/WebCore/html/canvas/WebGLContextEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

namespace WebCore {

WebGLContextEventInit::WebGLContextEventInit()
{
}

WebGLContextEvent::WebGLContextEvent()
{
}
Expand All @@ -40,6 +44,12 @@ WebGLContextEvent::WebGLContextEvent(const AtomicString& type, bool canBubble, b
{
}

WebGLContextEvent::WebGLContextEvent(const AtomicString& type, const WebGLContextEventInit& initializer)
: Event(type, initializer)
, m_statusMessage(initializer.statusMessage)
{
}

WebGLContextEvent::~WebGLContextEvent()
{
}
Expand Down
11 changes: 11 additions & 0 deletions Source/WebCore/html/canvas/WebGLContextEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@

namespace WebCore {

struct WebGLContextEventInit : public EventInit {
WebGLContextEventInit();

String statusMessage;
};

class WebGLContextEvent : public Event {
public:
static PassRefPtr<WebGLContextEvent> create()
Expand All @@ -40,6 +46,10 @@ class WebGLContextEvent : public Event {
{
return adoptRef(new WebGLContextEvent(type, canBubble, cancelable, statusMessage));
}
static PassRefPtr<WebGLContextEvent> create(const AtomicString& type, const WebGLContextEventInit& initializer)
{
return adoptRef(new WebGLContextEvent(type, initializer));
}
virtual ~WebGLContextEvent();

const String& statusMessage() const { return m_statusMessage; }
Expand All @@ -49,6 +59,7 @@ class WebGLContextEvent : public Event {
private:
WebGLContextEvent();
WebGLContextEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& statusMessage);
WebGLContextEvent(const AtomicString&, const WebGLContextEventInit&);

String m_statusMessage;
};
Expand Down
5 changes: 4 additions & 1 deletion Source/WebCore/html/canvas/WebGLContextEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
*/

module html {

interface [
Conditional=WEBGL,
ConstructorTemplate=Event
] WebGLContextEvent : Event {
readonly attribute DOMString statusMessage;
readonly attribute [InitializedByConstructor] DOMString statusMessage;
};

}

0 comments on commit b78f809

Please sign in to comment.