Enable webaudio/ tests on DRT/Mac
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Oct 2013 03:15:04 +0000 (03:15 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Oct 2013 03:15:04 +0000 (03:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86914

Reviewed by Darin Adler.

Tools:

* DumpRenderTree/ForwardingHeaders/runtime/ArrayBufferView.h: Copied from Source/WebCore/ForwardingHeaders/runtime/ArrayBufferView.h.
* DumpRenderTree/ForwardingHeaders/runtime/JSArrayBufferView.h: Copied from Source/WebCore/ForwardingHeaders/runtime/JSArrayBufferView.h.
* DumpRenderTree/ForwardingHeaders/runtime/TypedArrayInlines.h: Copied from Source/WebCore/ForwardingHeaders/runtime/TypedArrayInlines.h.
There is no way to efficiently get TypedArray buffer using API, so we need some internal headers.

* DumpRenderTree/TestRunner.cpp:
(setAudioResultCallback):
(TestRunner::staticFunctions):
* DumpRenderTree/TestRunner.h:
(TestRunner::audioResult):
(TestRunner::setAudioResult):
The function has a different name and argument type now, updated accordingly.
Changed buffer from std::string to std::vector<char>, because it's more idiomatic.

* DumpRenderTree/mac/DumpRenderTree.mm:
(dumpAudio): Updated for the new name of audioResult accessor.
(dump): Print the result in the format webkitpy currently expects.

* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::dumpAudio): fwrite the whole block at once, splitting into
chunks made no sense.

* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setAudioResult): Added a FIXME about getting off WKBundle SPI.

* DumpRenderTree/CMakeLists.txt: Added JavaScriptCore/parser to include search list,
so that "SourceProvider.h" can be found.

LayoutTests:

* TestExpectations: Moved webaudio/javascriptaudionode here, as garbage collection
issues with it are cross-platform.

* platform/mac-wk2/TestExpectations: Moved out everything, as there is nothing
WK2 specific about WebAudio.

* platform/mac/TestExpectations: WebAudio expectations here were just ignored. Replaced
with slightly updated expectations from WK2.

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/mac/TestExpectations
Tools/ChangeLog
Tools/DumpRenderTree/CMakeLists.txt
Tools/DumpRenderTree/ForwardingHeaders/runtime/ArrayBufferView.h [new file with mode: 0644]
Tools/DumpRenderTree/ForwardingHeaders/runtime/JSArrayBufferView.h [new file with mode: 0644]
Tools/DumpRenderTree/ForwardingHeaders/runtime/TypedArrayInlines.h [new file with mode: 0644]
Tools/DumpRenderTree/TestRunner.cpp
Tools/DumpRenderTree/TestRunner.h
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/TestInvocation.cpp

index 21db960..395e8a0 100644 (file)
@@ -1,3 +1,19 @@
+2013-10-19  Alexey Proskuryakov  <ap@apple.com>
+
+        Enable webaudio/ tests on DRT/Mac
+        https://bugs.webkit.org/show_bug.cgi?id=86914
+
+        Reviewed by Darin Adler.
+
+        * TestExpectations: Moved webaudio/javascriptaudionode here, as garbage collection
+        issues with it are cross-platform.
+
+        * platform/mac-wk2/TestExpectations: Moved out everything, as there is nothing
+        WK2 specific about WebAudio.
+
+        * platform/mac/TestExpectations: WebAudio expectations here were just ignored. Replaced
+        with slightly updated expectations from WK2.
+
 2013-10-19  Santosh Mahto  <santosh.ma@samsung.com>
 
         Adding test case for text-decoration property state change on applying different command
index 6ea0544..668048d 100644 (file)
@@ -51,6 +51,8 @@ http/tests/inspector-enabled [ Skip ]
 
 webkit.org/b/112521 [ Release ] webaudio/javascriptaudionode.html [ Pass Failure ]
 webkit.org/b/112521 [ Debug ] webaudio/javascriptaudionode.html [ Pass Crash ]
+webkit.org/b/120148 [ Release ] webaudio/javascriptaudionode-upmix2-8channel-input.html [ Pass Failure ]
+webkit.org/b/120148 [ Debug ] webaudio/javascriptaudionode-upmix2-8channel-input.html [ Pass Crash ]
 
 # The test frequently times out, and is just unsuccessful at detecting incorrect behavior when it passes.
 webkit.org/b/72698 media/audio-garbage-collect.html [ Skip ]
index 21a1f77..264dbc9 100644 (file)
@@ -330,11 +330,6 @@ webkit.org/b/118925 [ Debug ] svg/repaint/buffered-rendering-static-image.html
 # Only failing on WK1
 webkit.org/b/104104 fast/overflow/scrollbar-click-retains-focus.html [ Pass ]
 
-# Flakily fails in release build, asserts in debug.
-webkit.org/b/120148 webaudio/javascriptaudionode-upmix2-8channel-input.html [ Pass Crash Failure ]
-
-webkit.org/b/120161 [ Lion ] webaudio/codec-tests/mp3/128kbps-44khz.html [ Failure ]
-
 webkit.org/b/121581 [ Lion ] media/video-object-fit.html [ ImageOnlyFailure ]
 
 webkit.org/b/107018 svg/animations/animate-linear-discrete-additive.svg [ ImageOnlyFailure Pass ]
@@ -455,14 +450,6 @@ plugins/snapshotting [ Skip ]
 # This test fails with WebKit1 only.
 editing/secure-input/reset-state-on-navigation.html [ Pass ]
 
-# WebAudio tests are supported in WK2
-webaudio/ [ Pass ]
-# Except for these
-webaudio/mediastreamaudiodestinationnode.html
-webaudio/mediastreamaudiosourcenode.html
-webaudio/codec-tests/vorbis/
-webkit.org/b/119467 webaudio/audiobuffersource-loop-points.html [ Skip ]
-
 # Asserts in WebKit1-debug only, so reenabling.
 compositing/geometry/fixed-position-flipped-writing-mode.html [ Pass ]
 
index 4609a67..cf343bc 100644 (file)
@@ -362,10 +362,6 @@ compositing/rtl/rtl-iframe-fixed-overflow.html
 compositing/rtl/rtl-iframe-fixed.html
 compositing/rtl/rtl-iframe-relative.html
 
-# For now, Web Audio tests are disabled
-# https://bugs.webkit.org/show_bug.cgi?id=86914
-webaudio/
-
 # ENABLE(DRAGGABLE_REGION) is disabled
 fast/css/draggable-region-parser.html
 
@@ -937,8 +933,10 @@ webkit.org/b/85308 ietestcenter/css3/valuesandunits/units-000.htm [ Skip ]
 # IETC namespace failures
 webkit.org/b/86142 ietestcenter/css3/namespaces/syntax-021.xml [ ImageOnlyFailure ]
 
-# Disable webaudio codec tests, including proprietary codecs.
-webkit.org/b/88794 webaudio/codec-tests
+webaudio/mediastreamaudiodestinationnode.html [ Failure ]
+webaudio/mediastreamaudiosourcenode.html [ Failure ]
+webaudio/codec-tests/vorbis/ [ WontFix ]
+webkit.org/b/119467 webaudio/audiobuffersource-loop-points.html [ Skip ]
 
 # Text Autosizing is not enabled.
 webkit.org/b/84186 fast/text-autosizing
index 2aea630..d9c15f8 100644 (file)
@@ -1,3 +1,38 @@
+2013-10-19  Alexey Proskuryakov  <ap@apple.com>
+
+        Enable webaudio/ tests on DRT/Mac
+        https://bugs.webkit.org/show_bug.cgi?id=86914
+
+        Reviewed by Darin Adler.
+
+        * DumpRenderTree/ForwardingHeaders/runtime/ArrayBufferView.h: Copied from Source/WebCore/ForwardingHeaders/runtime/ArrayBufferView.h.
+        * DumpRenderTree/ForwardingHeaders/runtime/JSArrayBufferView.h: Copied from Source/WebCore/ForwardingHeaders/runtime/JSArrayBufferView.h.
+        * DumpRenderTree/ForwardingHeaders/runtime/TypedArrayInlines.h: Copied from Source/WebCore/ForwardingHeaders/runtime/TypedArrayInlines.h.
+        There is no way to efficiently get TypedArray buffer using API, so we need some internal headers.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (setAudioResultCallback): 
+        (TestRunner::staticFunctions):
+        * DumpRenderTree/TestRunner.h:
+        (TestRunner::audioResult):
+        (TestRunner::setAudioResult):
+        The function has a different name and argument type now, updated accordingly.
+        Changed buffer from std::string to std::vector<char>, because it's more idiomatic.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (dumpAudio): Updated for the new name of audioResult accessor.
+        (dump): Print the result in the format webkitpy currently expects.
+
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::dumpAudio): fwrite the whole block at once, splitting into
+        chunks made no sense.
+
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setAudioResult): Added a FIXME about getting off WKBundle SPI.
+
+        * DumpRenderTree/CMakeLists.txt: Added JavaScriptCore/parser to include search list,
+        so that "SourceProvider.h" can be found.
+
 2013-10-19  Ryosuke Niwa  <rniwa@webkit.org>
 
         run-webkit-tests should submit time and modifiers to the new flakiness dashboard
index 6ceaa4f..7b8aa18 100644 (file)
@@ -54,6 +54,7 @@ set(DumpRenderTree_INCLUDE_DIRECTORIES
     ${JAVASCRIPTCORE_DIR}/interpreter
     ${JAVASCRIPTCORE_DIR}/jit
     ${JAVASCRIPTCORE_DIR}/llint
+    ${JAVASCRIPTCORE_DIR}/parser
     ${JAVASCRIPTCORE_DIR}/profiler
     ${JAVASCRIPTCORE_DIR}/runtime
     ${JAVASCRIPTCORE_DIR}/ForwardingHeaders
diff --git a/Tools/DumpRenderTree/ForwardingHeaders/runtime/ArrayBufferView.h b/Tools/DumpRenderTree/ForwardingHeaders/runtime/ArrayBufferView.h
new file mode 100644 (file)
index 0000000..7731671
--- /dev/null
@@ -0,0 +1 @@
+#include <JavaScriptCore/ArrayBufferView.h>
diff --git a/Tools/DumpRenderTree/ForwardingHeaders/runtime/JSArrayBufferView.h b/Tools/DumpRenderTree/ForwardingHeaders/runtime/JSArrayBufferView.h
new file mode 100644 (file)
index 0000000..e38a804
--- /dev/null
@@ -0,0 +1 @@
+#include <JavaScriptCore/JSArrayBufferView.h>
diff --git a/Tools/DumpRenderTree/ForwardingHeaders/runtime/TypedArrayInlines.h b/Tools/DumpRenderTree/ForwardingHeaders/runtime/TypedArrayInlines.h
new file mode 100644 (file)
index 0000000..6a61945
--- /dev/null
@@ -0,0 +1 @@
+#include <JavaScriptCore/TypedArrayInlines.h>
index 5c0d03c..fb90dc8 100644 (file)
 
 #include "WorkQueue.h"
 #include "WorkQueueItem.h"
+#include <JavaScriptCore/APICast.h>
 #include <JavaScriptCore/JSContextRef.h>
 #include <JavaScriptCore/JSCTestRunnerUtils.h>
 #include <JavaScriptCore/JSObjectRef.h>
 #include <JavaScriptCore/JSRetainPtr.h>
 #include <cstring>
 #include <locale.h>
+#include <runtime/ArrayBufferView.h>
+#include <runtime/JSArrayBufferView.h>
+#include <runtime/TypedArrayInlines.h>
 #include <stdio.h>
 #include <wtf/Assertions.h>
 #include <wtf/CurrentTime.h>
@@ -328,22 +332,22 @@ static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef cont
     return JSValueMakeUndefined(context);
 }
 
-static JSValueRef setEncodedAudioDataCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+static JSValueRef setAudioResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> encodedAudioData(Adopt, JSValueToStringCopy(context, arguments[0], exception));
-    ASSERT(!*exception);
-    
-    size_t maxLength = JSStringGetMaximumUTF8CStringSize(encodedAudioData.get());
-    auto encodedAudioDataBuffer = std::make_unique<char[]>(maxLength + 1);
-    JSStringGetUTF8CString(encodedAudioData.get(), encodedAudioDataBuffer.get(), maxLength + 1);
+    // FIXME (123058): Use a JSC API to get buffer contents once such is exposed.
+    JSC::JSArrayBufferView* jsBufferView = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(toJS(toJS(context), arguments[0]));
+    ASSERT(jsBufferView);
+    RefPtr<JSC::ArrayBufferView> bufferView = jsBufferView->impl();
+    const char* buffer = static_cast<const char*>(bufferView->baseAddress());
+    std::vector<char> audioData(buffer, buffer + bufferView->byteLength());
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    controller->setEncodedAudioData(encodedAudioDataBuffer.get());
+    controller->setAudioResult(audioData);
     controller->setDumpAsAudio(true);
-    
+
     return JSValueMakeUndefined(context);
 }
 
@@ -2126,7 +2130,7 @@ JSStaticFunction* TestRunner::staticFunctions()
         { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
-        { "setEncodedAudioData", setEncodedAudioDataCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setAudioResult", setAudioResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index 8cdacd9..d2b3a04 100644 (file)
@@ -286,8 +286,8 @@ public:
     const std::string& testPathOrURL() const { return m_testPathOrURL; }
     const std::string& expectedPixelHash() const { return m_expectedPixelHash; }
 
-    const std::string& encodedAudioData() const { return m_encodedAudioData; }
-    void setEncodedAudioData(const std::string& encodedAudioData) { m_encodedAudioData = encodedAudioData; }
+    const std::vector<char>& audioResult() const { return m_audioResult; }
+    void setAudioResult(const std::vector<char>& audioData) { m_audioResult = audioData; }
 
     void addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
     void removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
@@ -418,9 +418,8 @@ private:
     std::string m_titleTextDirection;
 
     std::set<std::string> m_willSendRequestClearHeaders;
-    
-    // base64 encoded WAV audio data is stored here.
-    std::string m_encodedAudioData;
+
+    std::vector<char> m_audioResult;
 
     std::map<std::string, std::string> m_URLsToRedirect;
     
index 3f6fce6..66ca6e7 100644 (file)
@@ -971,9 +971,9 @@ static NSInteger compareHistoryItems(id item1, id item2, void *context)
 
 static NSData *dumpAudio()
 {
-    const char *encodedAudioData = gTestRunner->encodedAudioData().c_str();
+    const vector<char>& dataVector = gTestRunner->audioResult();
     
-    NSData *data = [NSData dataWithBytes:encodedAudioData length:gTestRunner->encodedAudioData().length()];
+    NSData *data = [NSData dataWithBytes:dataVector.data() length:dataVector.size()];
     return data;
 }
 
@@ -1218,16 +1218,16 @@ void dump()
 
         printf("Content-Type: %s\n", [resultMimeType UTF8String]);
 
-        if (gTestRunner->dumpAsAudio())
-            printf("Content-Transfer-Encoding: base64\n");
-
         WTF::FastMallocStatistics mallocStats = WTF::fastMallocStatistics();
         printf("DumpMalloc: %li\n", mallocStats.committedVMBytes);
 
+        if (gTestRunner->dumpAsAudio())
+            printf("Content-Length: %lu\n", [resultData length]);
+
         if (resultData) {
             fwrite([resultData bytes], 1, [resultData length], stdout);
 
-            if (!gTestRunner->dumpAsText() && !gTestRunner->dumpDOMAsWebArchive() && !gTestRunner->dumpSourceAsWebArchive())
+            if (!gTestRunner->dumpAsText() && !gTestRunner->dumpDOMAsWebArchive() && !gTestRunner->dumpSourceAsWebArchive() && !gTestRunner->dumpAsAudio())
                 dumpFrameScrollPosition(mainFrame);
 
             if (gTestRunner->dumpBackForwardList())
index 3f2d038..25ec652 100644 (file)
@@ -378,6 +378,7 @@ void TestRunner::setValueForUser(JSContextRef context, JSValueRef element, JSStr
 
 void TestRunner::setAudioResult(JSContextRef context, JSValueRef data)
 {
+    // FIXME (123058): Use a JSC API to get buffer contents once such is exposed.
     WKRetainPtr<WKDataRef> audioData(AdoptWK, WKBundleCreateWKDataFromUInt8Array(InjectedBundle::shared().bundle(), context, data));
     InjectedBundle::shared().setAudioResult(audioData.get());
     m_whatToDump = Audio;
index b6121d3..1c8bc61 100644 (file)
@@ -353,16 +353,7 @@ void TestInvocation::dumpAudio(WKDataRef audioData)
     printf("Content-Type: audio/wav\n");
     printf("Content-Length: %lu\n", static_cast<unsigned long>(length));
 
-    const size_t bytesToWriteInOneChunk = 1 << 15;
-    size_t dataRemainingToWrite = length;
-    while (dataRemainingToWrite) {
-        size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk);
-        size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, stdout);
-        if (bytesWritten != bytesToWriteInThisChunk)
-            break;
-        dataRemainingToWrite -= bytesWritten;
-        data += bytesWritten;
-    }
+    fwrite(data, 1, length, stdout);
     printf("#EOF\n");
     fprintf(stderr, "#EOF\n");
 }