mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changesets 0c9407b0e481, c2c37b2e9fac, and 488700194519 (bug 1000264) for e10s test failures.
CLOSED TREE
This commit is contained in:
parent
341d273989
commit
d9de42ef04
@ -138,10 +138,11 @@ ToJSValue(JSContext* aCx,
|
||||
return MaybeWrapValue(aCx, aValue);
|
||||
}
|
||||
|
||||
// Accept objects that inherit from nsWrapperCache (e.g. most
|
||||
// Accept objects that inherit from nsWrapperCache and nsISupports (e.g. most
|
||||
// DOM objects).
|
||||
template <class T>
|
||||
typename EnableIf<IsBaseOf<nsWrapperCache, T>::value, bool>::Type
|
||||
typename EnableIf<IsBaseOf<nsWrapperCache, T>::value &&
|
||||
IsBaseOf<nsISupports, T>::value, bool>::Type
|
||||
ToJSValue(JSContext* aCx,
|
||||
T& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "OscillatorNode.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "AudioStream.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -439,24 +438,16 @@ AudioContext::Listener()
|
||||
return mListener;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
void
|
||||
AudioContext::DecodeAudioData(const ArrayBuffer& aBuffer,
|
||||
const Optional<OwningNonNull<DecodeSuccessCallback> >& aSuccessCallback,
|
||||
DecodeSuccessCallback& aSuccessCallback,
|
||||
const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback)
|
||||
{
|
||||
ErrorResult rv;
|
||||
nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(GetParentObject());
|
||||
nsRefPtr<Promise> promise;
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
JSAutoCompartment ac(cx, aBuffer.Obj());
|
||||
|
||||
promise = Promise::Create(parentObject, rv);
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aBuffer.ComputeLengthAndData();
|
||||
|
||||
// Neuter the array buffer
|
||||
@ -471,21 +462,15 @@ AudioContext::DecodeAudioData(const ArrayBuffer& aBuffer,
|
||||
NS_SniffContent(NS_DATA_SNIFFER_CATEGORY, nullptr, data, length, contentType);
|
||||
|
||||
nsRefPtr<DecodeErrorCallback> failureCallback;
|
||||
nsRefPtr<DecodeSuccessCallback> successCallback;
|
||||
if (aFailureCallback.WasPassed()) {
|
||||
failureCallback = &aFailureCallback.Value();
|
||||
}
|
||||
if (aSuccessCallback.WasPassed()) {
|
||||
successCallback = &aSuccessCallback.Value();
|
||||
}
|
||||
nsRefPtr<WebAudioDecodeJob> job(
|
||||
new WebAudioDecodeJob(contentType, this,
|
||||
promise, successCallback, failureCallback));
|
||||
&aSuccessCallback, failureCallback));
|
||||
mDecoder.AsyncDecodeMedia(contentType.get(), data, length, *job);
|
||||
// Transfer the ownership to mDecodeJobs
|
||||
mDecodeJobs.AppendElement(job.forget());
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -61,7 +61,6 @@ class PannerNode;
|
||||
class ScriptProcessorNode;
|
||||
class WaveShaperNode;
|
||||
class PeriodicWave;
|
||||
class Promise;
|
||||
|
||||
class AudioContext MOZ_FINAL : public DOMEventTargetHelper,
|
||||
public nsIMemoryReporter
|
||||
@ -185,10 +184,9 @@ public:
|
||||
CreatePeriodicWave(const Float32Array& aRealData, const Float32Array& aImagData,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise>
|
||||
DecodeAudioData(const ArrayBuffer& aBuffer,
|
||||
const Optional<OwningNonNull<DecodeSuccessCallback> >& aSuccessCallback,
|
||||
const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback);
|
||||
void DecodeAudioData(const ArrayBuffer& aBuffer,
|
||||
DecodeSuccessCallback& aSuccessCallback,
|
||||
const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback);
|
||||
|
||||
// OfflineAudioContext methods
|
||||
void StartRendering(ErrorResult& aRv);
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "WebAudioUtils.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#ifdef XP_WIN
|
||||
#include "ThreadPoolCOMListener.h"
|
||||
#endif
|
||||
@ -513,17 +512,16 @@ MediaBufferDecoder::Shutdown() {
|
||||
|
||||
WebAudioDecodeJob::WebAudioDecodeJob(const nsACString& aContentType,
|
||||
AudioContext* aContext,
|
||||
Promise* aPromise,
|
||||
DecodeSuccessCallback* aSuccessCallback,
|
||||
DecodeErrorCallback* aFailureCallback)
|
||||
: mContentType(aContentType)
|
||||
, mWriteIndex(0)
|
||||
, mContext(aContext)
|
||||
, mPromise(aPromise)
|
||||
, mSuccessCallback(aSuccessCallback)
|
||||
, mFailureCallback(aFailureCallback)
|
||||
{
|
||||
MOZ_ASSERT(aContext);
|
||||
MOZ_ASSERT(aSuccessCallback);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_COUNT_CTOR(WebAudioDecodeJob);
|
||||
}
|
||||
@ -543,10 +541,7 @@ WebAudioDecodeJob::OnSuccess(ErrorCode aErrorCode)
|
||||
// Ignore errors in calling the callback, since there is not much that we can
|
||||
// do about it here.
|
||||
ErrorResult rv;
|
||||
if (mSuccessCallback) {
|
||||
mSuccessCallback->Call(*mOutput, rv);
|
||||
}
|
||||
mPromise->MaybeResolve(mOutput);
|
||||
mSuccessCallback->Call(*mOutput, rv);
|
||||
|
||||
mContext->RemoveFromDecodeQueue(this);
|
||||
}
|
||||
@ -594,8 +589,6 @@ WebAudioDecodeJob::OnFailure(ErrorCode aErrorCode)
|
||||
mFailureCallback->Call(rv);
|
||||
}
|
||||
|
||||
mPromise->MaybeReject(NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR);
|
||||
|
||||
mContext->RemoveFromDecodeQueue(this);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ class AudioBuffer;
|
||||
class AudioContext;
|
||||
class DecodeErrorCallback;
|
||||
class DecodeSuccessCallback;
|
||||
class Promise;
|
||||
}
|
||||
|
||||
struct WebAudioDecodeJob MOZ_FINAL
|
||||
@ -31,7 +30,6 @@ struct WebAudioDecodeJob MOZ_FINAL
|
||||
// The callbacks are only necessary for asynchronous operation.
|
||||
WebAudioDecodeJob(const nsACString& aContentType,
|
||||
dom::AudioContext* aContext,
|
||||
dom::Promise* aPromise,
|
||||
dom::DecodeSuccessCallback* aSuccessCallback = nullptr,
|
||||
dom::DecodeErrorCallback* aFailureCallback = nullptr);
|
||||
|
||||
@ -60,7 +58,6 @@ struct WebAudioDecodeJob MOZ_FINAL
|
||||
nsCString mContentType;
|
||||
uint32_t mWriteIndex;
|
||||
nsRefPtr<dom::AudioContext> mContext;
|
||||
nsRefPtr<dom::Promise> mPromise;
|
||||
nsRefPtr<dom::DecodeSuccessCallback> mSuccessCallback;
|
||||
nsRefPtr<dom::DecodeErrorCallback> mFailureCallback; // can be null
|
||||
nsRefPtr<dom::AudioBuffer> mOutput;
|
||||
|
@ -87,7 +87,6 @@ skip-if = toolkit == 'android' # bug 1056706
|
||||
[test_convolverNodeWithGain.html]
|
||||
[test_currentTime.html]
|
||||
[test_decodeMultichannel.html]
|
||||
[test_decodeAudioDataPromise.html]
|
||||
[test_delayNode.html]
|
||||
[test_delayNodeAtMax.html]
|
||||
[test_delayNodeChannelChanges.html]
|
||||
|
@ -1,61 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test the decodeAudioData API with Promise</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script src="webaudio.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
|
||||
var finished = 0;
|
||||
|
||||
function finish() {
|
||||
if (++finished == 2) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
var ac = new AudioContext();
|
||||
// Test that a the promise is rejected with an invalid source buffer.
|
||||
expectNoException(function() {
|
||||
var p = ac.decodeAudioData(" ");
|
||||
ok(p instanceof Promise, "AudioContext.decodeAudioData should return a Promise");
|
||||
p.then(function(data) {
|
||||
ok(false, "Promise should not resolve with an invalid source buffer.");
|
||||
finish();
|
||||
}).catch(function() {
|
||||
ok(true, "Promise should be rejected with an invalid source buffer.");
|
||||
finish();
|
||||
})
|
||||
});
|
||||
|
||||
// Test that a the promise is resolved with a valid source buffer.
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "ting-44.1k-1ch.ogg", true);
|
||||
xhr.responseType = "arraybuffer";
|
||||
xhr.onload = function() {
|
||||
var p = ac.decodeAudioData(xhr.response);
|
||||
ok(p instanceof Promise, "AudioContext.decodeAudioData should return a Promise");
|
||||
p.then(function(data) {
|
||||
ok(data instanceof AudioBuffer, "Promise should resolve, passing an AudioBuffer");
|
||||
ok(true, "Promise should resolve with a valid source buffer.");
|
||||
finish();
|
||||
}).catch(function() {
|
||||
ok(false, "Promise should not be rejected with a valid source buffer.");
|
||||
finish();
|
||||
});
|
||||
};
|
||||
xhr.send();
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -25,9 +25,9 @@ interface AudioContext : EventTarget {
|
||||
[NewObject, Throws]
|
||||
AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long length, float sampleRate);
|
||||
|
||||
Promise<AudioBuffer> decodeAudioData(ArrayBuffer audioData,
|
||||
optional DecodeSuccessCallback successCallback,
|
||||
optional DecodeErrorCallback errorCallback);
|
||||
void decodeAudioData(ArrayBuffer audioData,
|
||||
DecodeSuccessCallback successCallback,
|
||||
optional DecodeErrorCallback errorCallback);
|
||||
|
||||
// AudioNode creation
|
||||
[NewObject]
|
||||
|
Loading…
Reference in New Issue
Block a user