Title: [91708] trunk
Revision
91708
Author
[email protected]
Date
2011-07-25 15:16:39 -0700 (Mon, 25 Jul 2011)

Log Message

Update Chromium DRT to output binary (instead of base64-encoded) data for web audio testing
https://bugs.webkit.org/show_bug.cgi?id=65039

Reviewed by Tony Chang.

Source/WebKit/chromium: 

* WebKit.gyp:
* public/WebArrayBufferView.h: Added.
(WebKit::WebArrayBufferView::~WebArrayBufferView):
(WebKit::WebArrayBufferView::WebArrayBufferView):
* public/WebBindings.h:
* src/WebArrayBufferView.cpp: Added.
(WebKit::WebArrayBufferView::assign):
(WebKit::WebArrayBufferView::reset):
(WebKit::WebArrayBufferView::baseAddress):
(WebKit::WebArrayBufferView::byteOffset):
(WebKit::WebArrayBufferView::byteLength):
(WebKit::WebArrayBufferView::WebArrayBufferView):
(WebKit::WebArrayBufferView::operator=):
(WebKit::WebArrayBufferView::operator PassRefPtr<ArrayBufferView>):
* src/WebBindings.cpp:
(WebKit::getArrayBufferViewImpl):
(WebKit::WebBindings::getArrayBufferView):

Tools: 

* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController):
(LayoutTestController::setAudioData):
* DumpRenderTree/chromium/LayoutTestController.h:
(LayoutTestController::audioData):
* DumpRenderTree/chromium/TestEventPrinter.cpp:
(DRTPrinter::handleAudioHeader):
(TestShellPrinter::handleAudioHeader):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::dump):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (91707 => 91708)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-07-25 21:43:32 UTC (rev 91707)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-07-25 22:16:39 UTC (rev 91708)
@@ -1,3 +1,28 @@
+2011-07-25  Chris Rogers  <[email protected]>
+
+        Update Chromium DRT to output binary (instead of base64-encoded) data for web audio testing
+        https://bugs.webkit.org/show_bug.cgi?id=65039
+
+        Reviewed by Tony Chang.
+
+        * WebKit.gyp:
+        * public/WebArrayBufferView.h: Added.
+        (WebKit::WebArrayBufferView::~WebArrayBufferView):
+        (WebKit::WebArrayBufferView::WebArrayBufferView):
+        * public/WebBindings.h:
+        * src/WebArrayBufferView.cpp: Added.
+        (WebKit::WebArrayBufferView::assign):
+        (WebKit::WebArrayBufferView::reset):
+        (WebKit::WebArrayBufferView::baseAddress):
+        (WebKit::WebArrayBufferView::byteOffset):
+        (WebKit::WebArrayBufferView::byteLength):
+        (WebKit::WebArrayBufferView::WebArrayBufferView):
+        (WebKit::WebArrayBufferView::operator=):
+        (WebKit::WebArrayBufferView::operator PassRefPtr<ArrayBufferView>):
+        * src/WebBindings.cpp:
+        (WebKit::getArrayBufferViewImpl):
+        (WebKit::WebBindings::getArrayBufferView):
+
 2011-07-23  Alok Priyadarshi  <[email protected]>
 
         Switching off acceleration for small canvas broke gpu tests

Modified: trunk/Source/WebKit/chromium/WebKit.gyp (91707 => 91708)


--- trunk/Source/WebKit/chromium/WebKit.gyp	2011-07-25 21:43:32 UTC (rev 91707)
+++ trunk/Source/WebKit/chromium/WebKit.gyp	2011-07-25 22:16:39 UTC (rev 91708)
@@ -103,6 +103,7 @@
                 'public/WebAnimationController.h',
                 'public/WebApplicationCacheHost.h',
                 'public/WebApplicationCacheHostClient.h',
+                'public/WebArrayBufferView.h',
                 'public/WebAttribute.h',
                 'public/WebAudioBus.h',
                 'public/WebAudioDevice.h',
@@ -421,6 +422,7 @@
                 'src/WebAccessibilityObject.cpp',
                 'src/WebAnimationControllerImpl.cpp',
                 'src/WebAnimationControllerImpl.h',
+                'src/WebArrayBufferView.cpp',
                 'src/WebAttribute.cpp',
                 'src/WebAudioBus.cpp',
                 'src/WebBindings.cpp',

Added: trunk/Source/WebKit/chromium/public/WebArrayBufferView.h (0 => 91708)


--- trunk/Source/WebKit/chromium/public/WebArrayBufferView.h	                        (rev 0)
+++ trunk/Source/WebKit/chromium/public/WebArrayBufferView.h	2011-07-25 22:16:39 UTC (rev 91708)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebArrayBufferView_h
+#define WebArrayBufferView_h
+
+#include "WebCommon.h"
+#include "WebPrivatePtr.h"
+
+namespace WebCore { class ArrayBufferView; }
+
+namespace WebKit {
+
+// Provides access to an ArrayBufferView.
+class WebArrayBufferView {
+public:
+    ~WebArrayBufferView() { reset(); }
+    WebArrayBufferView() { }
+    WebArrayBufferView(const WebArrayBufferView& v) { assign(v); }
+
+    WEBKIT_API void* baseAddress() const;
+    WEBKIT_API unsigned byteOffset() const;
+    WEBKIT_API unsigned byteLength() const;
+
+    WEBKIT_API void assign(const WebArrayBufferView&);
+    WEBKIT_API void reset();
+
+#if WEBKIT_IMPLEMENTATION
+    WebArrayBufferView(const WTF::PassRefPtr<WebCore::ArrayBufferView>&);
+    WebArrayBufferView& operator=(const WTF::PassRefPtr<WebCore::ArrayBufferView>&);
+    operator WTF::PassRefPtr<WebCore::ArrayBufferView>() const;
+#endif
+
+private:
+    WebPrivatePtr<WebCore::ArrayBufferView> m_private;
+};
+
+} // namespace WebKit
+
+#endif

Modified: trunk/Source/WebKit/chromium/public/WebBindings.h (91707 => 91708)


--- trunk/Source/WebKit/chromium/public/WebBindings.h	2011-07-25 21:43:32 UTC (rev 91707)
+++ trunk/Source/WebKit/chromium/public/WebBindings.h	2011-07-25 22:16:39 UTC (rev 91708)
@@ -38,6 +38,7 @@
 
 namespace WebKit {
 
+class WebArrayBufferView;
 class WebDragData;
 class WebElement;
 class WebNode;
@@ -134,6 +135,10 @@
     // If so, return that range as a WebRange object.
     WEBKIT_API static bool getRange(NPObject* range, WebRange*);
 
+    // Return true (success) if the given npobj is an ArrayBufferView object.
+    // If so, return it as a WebArrayBufferView object.
+    WEBKIT_API static bool getArrayBufferView(NPObject* arrayBufferView, WebArrayBufferView*);
+
     // Return true (success) if the given npobj is an element.
     // If so, return that element as a WebElement object.
     WEBKIT_API static bool getElement(NPObject* element, WebElement*);

Added: trunk/Source/WebKit/chromium/src/WebArrayBufferView.cpp (0 => 91708)


--- trunk/Source/WebKit/chromium/src/WebArrayBufferView.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/src/WebArrayBufferView.cpp	2011-07-25 22:16:39 UTC (rev 91708)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebArrayBufferView.h"
+
+#include "ArrayBufferView.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebArrayBufferView::assign(const WebArrayBufferView& other)
+{
+    m_private = other.m_private;
+}
+
+void WebArrayBufferView::reset()
+{
+    m_private.reset();
+}
+
+void* WebArrayBufferView::baseAddress() const
+{
+    return m_private->baseAddress();
+}
+
+unsigned WebArrayBufferView::byteOffset() const
+{
+    return m_private->byteOffset();
+}
+
+unsigned WebArrayBufferView::byteLength() const
+{
+    return m_private->byteLength();
+}
+
+WebArrayBufferView::WebArrayBufferView(const PassRefPtr<ArrayBufferView>& value)
+    : m_private(value)
+{
+}
+
+WebArrayBufferView& WebArrayBufferView::operator=(const PassRefPtr<ArrayBufferView>& value)
+{
+    m_private = value;
+    return *this;
+}
+
+WebArrayBufferView::operator PassRefPtr<ArrayBufferView>() const
+{
+    return m_private.get();
+}
+
+} // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/WebBindings.cpp (91707 => 91708)


--- trunk/Source/WebKit/chromium/src/WebBindings.cpp	2011-07-25 21:43:32 UTC (rev 91707)
+++ trunk/Source/WebKit/chromium/src/WebBindings.cpp	2011-07-25 22:16:39 UTC (rev 91708)
@@ -35,8 +35,10 @@
 #include "npruntime_priv.h"
 
 #if USE(V8)
+#include "ArrayBufferView.h"
 #include "NPV8Object.h"  // for PrivateIdentifier
 #include "Range.h"
+#include "V8ArrayBufferView.h"
 #include "V8BindingState.h"
 #include "V8DOMWrapper.h"
 #include "V8Element.h"
@@ -46,6 +48,7 @@
 #elif USE(JSC)
 #include "bridge/c/c_utility.h"
 #endif
+#include "WebArrayBufferView.h"
 #include "WebElement.h"
 #include "WebRange.h"
 
@@ -234,6 +237,21 @@
     return true;
 }
 
+static bool getArrayBufferViewImpl(NPObject* object, WebArrayBufferView* arrayBufferView)
+{
+    if (!object || (object->_class != npScriptObjectClass))
+        return false;
+
+    V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(object);
+    v8::Handle<v8::Object> v8Object(v8NPObject->v8Object);
+    ArrayBufferView* native = V8ArrayBufferView::HasInstance(v8Object) ? V8ArrayBufferView::toNative(v8Object) : 0;
+    if (!native)
+        return false;
+
+    *arrayBufferView = WebArrayBufferView(native);
+    return true;
+}
+
 static NPObject* makeIntArrayImpl(const WebVector<int>& data)
 {
     v8::HandleScope handleScope;
@@ -268,6 +286,16 @@
 #endif
 }
 
+bool WebBindings::getArrayBufferView(NPObject* arrayBufferView, WebArrayBufferView* webArrayBufferView)
+{
+#if USE(V8)
+    return getArrayBufferViewImpl(arrayBufferView, webArrayBufferView);
+#else
+    // Not supported on other ports (JSC, etc).
+    return false;
+#endif
+}
+
 bool WebBindings::getElement(NPObject* element, WebElement* webElement)
 {
 #if USE(V8)

Modified: trunk/Tools/ChangeLog (91707 => 91708)


--- trunk/Tools/ChangeLog	2011-07-25 21:43:32 UTC (rev 91707)
+++ trunk/Tools/ChangeLog	2011-07-25 22:16:39 UTC (rev 91708)
@@ -1,3 +1,21 @@
+2011-07-25  Chris Rogers  <[email protected]>
+
+        Update Chromium DRT to output binary (instead of base64-encoded) data for web audio testing
+        https://bugs.webkit.org/show_bug.cgi?id=65039
+
+        Reviewed by Tony Chang.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::setAudioData):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        (LayoutTestController::audioData):
+        * DumpRenderTree/chromium/TestEventPrinter.cpp:
+        (DRTPrinter::handleAudioHeader):
+        (TestShellPrinter::handleAudioHeader):
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::dump):
+
 2011-06-07  Martin Robinson  <[email protected]>
 
         Reviewed by Gustavo Noronha Silva.

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (91707 => 91708)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-07-25 21:43:32 UTC (rev 91707)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-07-25 22:16:39 UTC (rev 91708)
@@ -155,7 +155,7 @@
     bindMethod("setDeferMainResourceDataLoad", &LayoutTestController::setDeferMainResourceDataLoad);
     bindMethod("setDomainRelaxationForbiddenForURLScheme", &LayoutTestController::setDomainRelaxationForbiddenForURLScheme);
     bindMethod("setEditingBehavior", &LayoutTestController::setEditingBehavior);
-    bindMethod("setEncodedAudioData", &LayoutTestController::setEncodedAudioData);
+    bindMethod("setAudioData", &LayoutTestController::setAudioData);
     bindMethod("setGeolocationPermission", &LayoutTestController::setGeolocationPermission);
     bindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled);
     bindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard);
@@ -1846,12 +1846,19 @@
     m_shell->webView()->setTextDirection(direction);
 }
 
-void LayoutTestController::setEncodedAudioData(const CppArgumentList& arguments, CppVariant* result)
+void LayoutTestController::setAudioData(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
-    if (arguments.size() < 1 || !arguments[0].isString())
+
+    if (arguments.size() < 1 || !arguments[0].isObject())
         return;
 
-    m_encodedAudioData = arguments[0].toString();
+    // Check that passed-in object is, in fact, an ArrayBufferView.
+    NPObject* npobject = NPVARIANT_TO_OBJECT(arguments[0]);
+    if (!npobject)
+        return;
+    if (!WebBindings::getArrayBufferView(npobject, &m_audioData))
+        return;
+
     setShouldDumpAsAudio(true);
 }

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h (91707 => 91708)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-07-25 21:43:32 UTC (rev 91707)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-07-25 22:16:39 UTC (rev 91708)
@@ -43,6 +43,7 @@
 
 #include "CppBoundClass.h"
 #include "Task.h"
+#include "WebArrayBufferView.h"
 #include "WebString.h"
 #include "WebTextDirection.h"
 #include "WebURL.h"
@@ -249,9 +250,9 @@
     void setDeferMainResourceDataLoad(const CppArgumentList&, CppVariant*);
     void setEditingBehavior(const CppArgumentList&, CppVariant*);
 
-    // Deals with Web Audio base64 encoded WAVE file data.
-    void setEncodedAudioData(const CppArgumentList&, CppVariant*);
-    const std::string& encodedAudioData() const { return m_encodedAudioData; } 
+    // Deals with Web Audio WAV file data.
+    void setAudioData(const CppArgumentList&, CppVariant*);
+    const WebKit::WebArrayBufferView& audioData() const { return m_audioData; } 
 
     // The following are only stubs.
     // FIXME: Implement any of these that are needed to pass the layout tests.
@@ -619,8 +620,8 @@
 
     OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock;
 
-    // base64 encoded WAV audio data is stored here.
-    std::string m_encodedAudioData;
+    // WAV audio data is stored here.
+    WebKit::WebArrayBufferView m_audioData;
 };
 
 #endif // LayoutTestController_h

Modified: trunk/Tools/DumpRenderTree/chromium/TestEventPrinter.cpp (91707 => 91708)


--- trunk/Tools/DumpRenderTree/chromium/TestEventPrinter.cpp	2011-07-25 21:43:32 UTC (rev 91707)
+++ trunk/Tools/DumpRenderTree/chromium/TestEventPrinter.cpp	2011-07-25 22:16:39 UTC (rev 91708)
@@ -100,7 +100,6 @@
 void DRTPrinter::handleAudioHeader() const
 {
     printf("Content-Type: audio/wav\n");
-    printf("Content-Transfer-Encoding: base64\n");            
 }
 
 void DRTPrinter::handleImage(const char* actualHash, const char* expectedHash, const unsigned char* imageData, size_t imageSize, const char*) const
@@ -152,7 +151,6 @@
 void TestShellPrinter::handleAudioHeader() const
 {
     printf("Content-Type: audio/wav\n");
-    printf("Content-Transfer-Encoding: base64\n");
 }
 
 void TestShellPrinter::handleImage(const char* actualHash, const char*, const unsigned char* imageData, size_t imageSize, const char* fileName) const

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.cpp (91707 => 91708)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2011-07-25 21:43:32 UTC (rev 91707)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2011-07-25 22:16:39 UTC (rev 91708)
@@ -34,6 +34,7 @@
 #include "DRTDevToolsAgent.h"
 #include "DRTDevToolsClient.h"
 #include "LayoutTestController.h"
+#include "WebArrayBufferView.h"
 #include "WebDataSource.h"
 #include "WebDocument.h"
 #include "WebElement.h"
@@ -477,13 +478,17 @@
 
     if (shouldDumpAsAudio) {
         m_printer->handleAudioHeader();
-
-        const string& encodedAudioData = m_layoutTestController->encodedAudioData();
-        if (fwrite(encodedAudioData.c_str(), 1, encodedAudioData.size(), stdout) != encodedAudioData.size())
+        
+        const WebKit::WebArrayBufferView& webArrayBufferView = m_layoutTestController->audioData();
+        printf("Content-Length: %d\n", webArrayBufferView.byteLength());
+        
+        if (fwrite(webArrayBufferView.baseAddress(), 1, webArrayBufferView.byteLength(), stdout) != webArrayBufferView.byteLength())
             FATAL("Short write to stdout, disk full?\n");
         printf("\n");
+        printf("#EOF\n");
+        
+        m_printer->handleTestFooter(true);
 
-        m_printer->handleTestFooter(true);
         fflush(stdout);
         fflush(stderr);
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to