Title: [120181] trunk
Revision
120181
Author
[email protected]
Date
2012-06-13 03:48:19 -0700 (Wed, 13 Jun 2012)

Log Message

Speech _javascript_ API: Add test for constructing SpeechRecognitionError events
https://bugs.webkit.org/show_bug.cgi?id=88868

Reviewed by Adam Barth.

Source/WebCore:

This adds a test for constructing SpeechRecognitionError events, and
code to make it work.

Test: fast/events/constructors/speech-recognition-error-constructor.html

* Modules/speech/SpeechRecognitionError.cpp:
(WebCore::SpeechRecognitionError::create):
(WebCore):
(WebCore::SpeechRecognitionError::SpeechRecognitionError):
(WebCore::SpeechRecognitionErrorInit::SpeechRecognitionErrorInit):
* Modules/speech/SpeechRecognitionError.h:
(SpeechRecognitionErrorInit):
(WebCore):
(SpeechRecognitionError):
(WebCore::SpeechRecognitionError::code):
* Modules/speech/SpeechRecognitionError.idl:

LayoutTests:

Add a layout test for constructing SpeechRecognitionError events.

* fast/events/constructors/speech-recognition-error-constructor-expected.txt: Added.
* fast/events/constructors/speech-recognition-error-constructor.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (120180 => 120181)


--- trunk/LayoutTests/ChangeLog	2012-06-13 10:38:46 UTC (rev 120180)
+++ trunk/LayoutTests/ChangeLog	2012-06-13 10:48:19 UTC (rev 120181)
@@ -1,3 +1,15 @@
+2012-06-12  Hans Wennborg  <[email protected]>
+
+        Speech _javascript_ API: Add test for constructing SpeechRecognitionError events
+        https://bugs.webkit.org/show_bug.cgi?id=88868
+
+        Reviewed by Adam Barth.
+
+        Add a layout test for constructing SpeechRecognitionError events.
+
+        * fast/events/constructors/speech-recognition-error-constructor-expected.txt: Added.
+        * fast/events/constructors/speech-recognition-error-constructor.html: Added.
+
 2012-06-13  Ryosuke Niwa  <[email protected]>
 
         Chromium rebaseline after r120173.

Added: trunk/LayoutTests/fast/events/constructors/speech-recognition-error-constructor-expected.txt (0 => 120181)


--- trunk/LayoutTests/fast/events/constructors/speech-recognition-error-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/speech-recognition-error-constructor-expected.txt	2012-06-13 10:48:19 UTC (rev 120181)
@@ -0,0 +1,17 @@
+This tests the constructor for the SpeechRecognitionError DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new webkitSpeechRecognitionError('eventType').bubbles is false
+PASS new webkitSpeechRecognitionError('eventType').cancelable is false
+PASS new webkitSpeechRecognitionError('eventType').code is 0
+PASS new webkitSpeechRecognitionError('eventType').message is ""
+PASS new webkitSpeechRecognitionError('eventType', { bubbles: false }).bubbles is false
+PASS new webkitSpeechRecognitionError('eventType', { bubbles: true }).bubbles is true
+PASS new webkitSpeechRecognitionError('eventType', { cancelable: false }).cancelable is false
+PASS new webkitSpeechRecognitionError('eventType', { cancelable: true }).cancelable is true
+PASS new webkitSpeechRecognitionError('eventType', { code: 1 }).code is 1
+PASS new webkitSpeechRecognitionError('eventType', { code: 12345 }).code is 12345
+PASS new webkitSpeechRecognitionError('eventType', { message: 'foo' }).message is "foo"
+
Property changes on: trunk/LayoutTests/fast/events/constructors/speech-recognition-error-constructor-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/events/constructors/speech-recognition-error-constructor.html (0 => 120181)


--- trunk/LayoutTests/fast/events/constructors/speech-recognition-error-constructor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/speech-recognition-error-constructor.html	2012-06-13 10:48:19 UTC (rev 120181)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("This tests the constructor for the SpeechRecognitionError DOM class.");
+
+// Test constructor without initializer.
+shouldBe("new webkitSpeechRecognitionError('eventType').bubbles", "false");
+shouldBe("new webkitSpeechRecognitionError('eventType').cancelable", "false");
+shouldBe("new webkitSpeechRecognitionError('eventType').code", "0");
+shouldBeEqualToString("new webkitSpeechRecognitionError('eventType').message", "");
+
+// Test passing bubbles in the initializer.
+shouldBe("new webkitSpeechRecognitionError('eventType', { bubbles: false }).bubbles", "false");
+shouldBe("new webkitSpeechRecognitionError('eventType', { bubbles: true }).bubbles", "true");
+
+// Test passing cancelable in the initializer.
+shouldBe("new webkitSpeechRecognitionError('eventType', { cancelable: false }).cancelable", "false");
+shouldBe("new webkitSpeechRecognitionError('eventType', { cancelable: true }).cancelable", "true");
+
+// Test passing code in the initializer.
+shouldBe("new webkitSpeechRecognitionError('eventType', { code: 1 }).code", "1");
+shouldBe("new webkitSpeechRecognitionError('eventType', { code: 12345 }).code", "12345");
+
+// Test passing message in the initializer.
+shouldBeEqualToString("new webkitSpeechRecognitionError('eventType', { message: 'foo' }).message", "foo");
+
+</script>
+<script src=""
+</body>
+</html>
+
+
Property changes on: trunk/LayoutTests/fast/events/constructors/speech-recognition-error-constructor.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (120180 => 120181)


--- trunk/Source/WebCore/ChangeLog	2012-06-13 10:38:46 UTC (rev 120180)
+++ trunk/Source/WebCore/ChangeLog	2012-06-13 10:48:19 UTC (rev 120181)
@@ -1,3 +1,27 @@
+2012-06-12  Hans Wennborg  <[email protected]>
+
+        Speech _javascript_ API: Add test for constructing SpeechRecognitionError events
+        https://bugs.webkit.org/show_bug.cgi?id=88868
+
+        Reviewed by Adam Barth.
+
+        This adds a test for constructing SpeechRecognitionError events, and
+        code to make it work.
+
+        Test: fast/events/constructors/speech-recognition-error-constructor.html
+
+        * Modules/speech/SpeechRecognitionError.cpp:
+        (WebCore::SpeechRecognitionError::create):
+        (WebCore):
+        (WebCore::SpeechRecognitionError::SpeechRecognitionError):
+        (WebCore::SpeechRecognitionErrorInit::SpeechRecognitionErrorInit):
+        * Modules/speech/SpeechRecognitionError.h:
+        (SpeechRecognitionErrorInit):
+        (WebCore):
+        (SpeechRecognitionError):
+        (WebCore::SpeechRecognitionError::code):
+        * Modules/speech/SpeechRecognitionError.idl:
+
 2012-06-13  Taiju Tsuiki  <[email protected]>
 
         Implement InspectorFileSystemAgent::readDirectory for FileSystem support.

Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognitionError.cpp (120180 => 120181)


--- trunk/Source/WebCore/Modules/speech/SpeechRecognitionError.cpp	2012-06-13 10:38:46 UTC (rev 120180)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognitionError.cpp	2012-06-13 10:48:19 UTC (rev 120181)
@@ -36,18 +36,35 @@
     return adoptRef(new SpeechRecognitionError(code, message));
 }
 
+PassRefPtr<SpeechRecognitionError> SpeechRecognitionError::create(const AtomicString& eventName, const SpeechRecognitionErrorInit& initializer)
+{
+    return adoptRef(new SpeechRecognitionError(eventName, initializer));
+}
+
 SpeechRecognitionError::SpeechRecognitionError(Code code, const String& message)
     : Event(eventNames().errorEvent, /*canBubble=*/false, /*cancelable=*/false) // FIXME: Spec should say whether it bubbles and is cancelable.
-    , m_code(code)
+    , m_code(static_cast<unsigned short>(code))
     , m_message(message)
 {
 }
 
+SpeechRecognitionError::SpeechRecognitionError(const AtomicString& eventName, const SpeechRecognitionErrorInit& initializer)
+    : Event(eventName, initializer)
+    , m_code(initializer.code)
+    , m_message(initializer.message)
+{
+}
+
 const AtomicString& SpeechRecognitionError::interfaceName() const
 {
     return eventNames().interfaceForSpeechRecognitionError;
 }
 
+SpeechRecognitionErrorInit::SpeechRecognitionErrorInit()
+    : code(0)
+{
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SCRIPTED_SPEECH)

Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognitionError.h (120180 => 120181)


--- trunk/Source/WebCore/Modules/speech/SpeechRecognitionError.h	2012-06-13 10:38:46 UTC (rev 120180)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognitionError.h	2012-06-13 10:48:19 UTC (rev 120181)
@@ -34,6 +34,13 @@
 
 namespace WebCore {
 
+struct SpeechRecognitionErrorInit : public EventInit {
+    SpeechRecognitionErrorInit();
+
+    unsigned short code;
+    String message;
+};
+
 class SpeechRecognitionError : public Event {
 public:
     enum Code {
@@ -50,16 +57,18 @@
 
     static PassRefPtr<SpeechRecognitionError> create(Code, const String&);
     static PassRefPtr<SpeechRecognitionError> create() { return create(OTHER, emptyString()); }
+    static PassRefPtr<SpeechRecognitionError> create(const AtomicString&, const SpeechRecognitionErrorInit&);
 
-    Code code() { return m_code; }
+    unsigned short code() { return m_code; }
     const String& message() { return m_message; }
 
     virtual const AtomicString& interfaceName() const OVERRIDE;
 
 private:
     SpeechRecognitionError(Code, const String&);
+    SpeechRecognitionError(const AtomicString&, const SpeechRecognitionErrorInit&);
 
-    Code m_code;
+    unsigned short m_code;
     String m_message;
 };
 

Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognitionError.idl (120180 => 120181)


--- trunk/Source/WebCore/Modules/speech/SpeechRecognitionError.idl	2012-06-13 10:38:46 UTC (rev 120180)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognitionError.idl	2012-06-13 10:48:19 UTC (rev 120181)
@@ -25,7 +25,8 @@
 
 module core {
     interface [
-        Conditional=SCRIPTED_SPEECH
+        Conditional=SCRIPTED_SPEECH,
+        ConstructorTemplate=Event
     ] SpeechRecognitionError : Event {
         const unsigned short OTHER = 0;
         const unsigned short NO_SPEECH = 1;
@@ -37,7 +38,7 @@
         const unsigned short BAD_GRAMMAR = 7;
         const unsigned short LANGUAGE_NOT_SUPPORTED = 8;
 
-        readonly attribute unsigned short code;
-        readonly attribute DOMString message;
+        readonly attribute [InitializedByEventConstructor] unsigned short code;
+        readonly attribute [InitializedByEventConstructor] DOMString message;
     };
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to