mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 847597 - Paris binding for NotifyAudioAvailableEvent, r=peterv
--HG-- extra : rebase_source : 2fb578e3f0c7a60f95f3a2f13634f9b4c887d95f
This commit is contained in:
parent
dd33f26541
commit
07409694c9
@ -10,7 +10,10 @@
|
||||
#include "nsContentUtils.h" // NS_DROP_JS_OBJECTS
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
nsDOMNotifyAudioAvailableEvent::nsDOMNotifyAudioAvailableEvent(mozilla::dom::EventTarget* aOwner,
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
nsDOMNotifyAudioAvailableEvent::nsDOMNotifyAudioAvailableEvent(EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
uint32_t aEventType,
|
||||
@ -28,6 +31,7 @@ nsDOMNotifyAudioAvailableEvent::nsDOMNotifyAudioAvailableEvent(mozilla::dom::Eve
|
||||
if (mEvent) {
|
||||
mEvent->message = aEventType;
|
||||
}
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
DOMCI_DATA(NotifyAudioAvailableEvent, nsDOMNotifyAudioAvailableEvent)
|
||||
@ -93,7 +97,7 @@ nsDOMNotifyAudioAvailableEvent::GetFrameBuffer(JSContext* aCx, JS::Value* aResul
|
||||
NS_IMETHODIMP
|
||||
nsDOMNotifyAudioAvailableEvent::GetTime(float *aRetVal)
|
||||
{
|
||||
*aRetVal = mTime;
|
||||
*aRetVal = Time();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -117,11 +121,42 @@ nsDOMNotifyAudioAvailableEvent::InitAudioAvailableEvent(const nsAString& aType,
|
||||
mFrameBufferLength = aFrameBufferLength;
|
||||
mTime = aTime;
|
||||
mAllowAudioData = aAllowAudioData;
|
||||
mCachedArray = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMNotifyAudioAvailableEvent::InitAudioAvailableEvent(const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
const Nullable<Sequence<float> >& aFrameBuffer,
|
||||
uint32_t aFrameBufferLength,
|
||||
float aTime,
|
||||
bool aAllowAudioData,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if ((aFrameBuffer.IsNull() && aFrameBufferLength > 0) ||
|
||||
(!aFrameBuffer.IsNull() &&
|
||||
aFrameBuffer.Value().Length() < aFrameBufferLength)) {
|
||||
aRv = NS_ERROR_UNEXPECTED;
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoArrayPtr<float> buffer;
|
||||
if (!aFrameBuffer.IsNull()) {
|
||||
buffer = new float[aFrameBufferLength];
|
||||
memcpy(buffer.get(), aFrameBuffer.Value().Elements(),
|
||||
aFrameBufferLength * sizeof(float));
|
||||
}
|
||||
|
||||
aRv = InitAudioAvailableEvent(aType, aCanBubble, aCancelable,
|
||||
buffer.forget(),
|
||||
aFrameBufferLength,
|
||||
aTime, aAllowAudioData);
|
||||
}
|
||||
|
||||
nsresult NS_NewDOMAudioAvailableEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
mozilla::dom::EventTarget* aOwner,
|
||||
EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
nsEvent *aEvent,
|
||||
uint32_t aEventType,
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/dom/NotifyAudioAvailableEventBinding.h"
|
||||
|
||||
class nsDOMNotifyAudioAvailableEvent : public nsDOMEvent,
|
||||
public nsIDOMNotifyAudioAvailableEvent
|
||||
@ -39,6 +40,32 @@ public:
|
||||
|
||||
~nsDOMNotifyAudioAvailableEvent();
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
||||
{
|
||||
return mozilla::dom::NotifyAudioAvailableEventBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
JSObject* GetFrameBuffer(JSContext* aCx, mozilla::ErrorResult& aRv)
|
||||
{
|
||||
JS::Value dummy;
|
||||
aRv = GetFrameBuffer(aCx, &dummy);
|
||||
return mCachedArray;
|
||||
}
|
||||
|
||||
float Time()
|
||||
{
|
||||
return mTime;
|
||||
}
|
||||
|
||||
void InitAudioAvailableEvent(const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
const mozilla::dom::Nullable<mozilla::dom::Sequence<float> >& aFrameBuffer,
|
||||
uint32_t aFrameBufferLength,
|
||||
float aTime,
|
||||
bool aAllowAudioData,
|
||||
mozilla::ErrorResult& aRv);
|
||||
private:
|
||||
nsAutoArrayPtr<float> mFrameBuffer;
|
||||
uint32_t mFrameBufferLength;
|
||||
|
@ -102,6 +102,7 @@ MOCHITEST_FILES = \
|
||||
test_bug812744.html \
|
||||
test_addEventListenerExtraArg.html \
|
||||
test_focus_disabled.html \
|
||||
test_bug847597.html \
|
||||
$(NULL)
|
||||
|
||||
MOCHITEST_CHROME_FILES = \
|
||||
|
81
content/events/test/test_bug847597.html
Normal file
81
content/events/test/test_bug847597.html
Normal file
@ -0,0 +1,81 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=847597
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 847597</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 847597 **/
|
||||
|
||||
|
||||
var e = document.createEvent("mozaudioavailableevent");
|
||||
e.initAudioAvailableEvent("foo", true, true, [1], 1, 123456, false);
|
||||
is(e.type, "foo");
|
||||
is(e.bubbles, true);
|
||||
is(e.cancelable, true);
|
||||
is(e.time, 123456);
|
||||
|
||||
try {
|
||||
e.frameBuffer;
|
||||
ok(false, "Should not be possible to access frameBuffer in unsafe context when the last parameter to init is false.");
|
||||
} catch(ex) {
|
||||
ok(true);
|
||||
}
|
||||
|
||||
try {
|
||||
e.initAudioAvailableEvent("foo", true, true, [1, 2, 3], 4, 123456, false);
|
||||
ok(false, "Should have thrown an exception because too short array");
|
||||
} catch(ex) {
|
||||
ok(true);
|
||||
}
|
||||
|
||||
try {
|
||||
e.initAudioAvailableEvent("foo", true, true, [], 1, 123456, false);
|
||||
ok(false, "Should have thrown an exception because too short array");
|
||||
} catch(ex) {
|
||||
ok(true);
|
||||
}
|
||||
|
||||
try {
|
||||
e.initAudioAvailableEvent("foo", true, true, null, 1, 123456, false);
|
||||
ok(false, "Should have thrown an exception because too short array");
|
||||
} catch(ex) {
|
||||
ok(true);
|
||||
}
|
||||
|
||||
e.initAudioAvailableEvent("foo", true, true, null, 0, 123456, false);
|
||||
e.initAudioAvailableEvent("foo", true, true, [], 0, 123456, false);
|
||||
e.initAudioAvailableEvent("foo", true, true, [1], 0, 123456, false);
|
||||
|
||||
e.initAudioAvailableEvent("foo", true, true, [0, 1, 2], 0, 123456, true);
|
||||
is(e.frameBuffer.length, 0);
|
||||
e.initAudioAvailableEvent("foo", true, true, [0, 1, 2], 1, 123456, true);
|
||||
is(e.frameBuffer.length, 1);
|
||||
is(e.frameBuffer[0], 0);
|
||||
e.initAudioAvailableEvent("foo", true, true, [0, 1, 2], 2, 123456, true);
|
||||
is(e.frameBuffer.length, 2);
|
||||
is(e.frameBuffer[0], 0);
|
||||
is(e.frameBuffer[1], 1);
|
||||
e.initAudioAvailableEvent("foo", true, true, [0, 1, 2], 3, 123456, true);
|
||||
is(e.frameBuffer.length, 3);
|
||||
is(e.frameBuffer[0], 0);
|
||||
is(e.frameBuffer[1], 1);
|
||||
is(e.frameBuffer[2], 2);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=847597">Mozilla Bug 847597</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -665,6 +665,10 @@ DOMInterfaces = {
|
||||
'nativeType': 'nsDOMNotifyPaintEvent',
|
||||
},
|
||||
|
||||
'NotifyAudioAvailableEvent': {
|
||||
'nativeType': 'nsDOMNotifyAudioAvailableEvent',
|
||||
},
|
||||
|
||||
'PaintRequest': {
|
||||
'nativeType': 'nsPaintRequest',
|
||||
},
|
||||
|
22
dom/webidl/NotifyAudioAvailableEvent.webidl
Normal file
22
dom/webidl/NotifyAudioAvailableEvent.webidl
Normal file
@ -0,0 +1,22 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
interface NotifyAudioAvailableEvent : Event
|
||||
{
|
||||
[Throws]
|
||||
readonly attribute Float32Array frameBuffer;
|
||||
|
||||
readonly attribute float time;
|
||||
|
||||
[Throws]
|
||||
void initAudioAvailableEvent(DOMString type,
|
||||
boolean canBubble,
|
||||
boolean cancelable,
|
||||
sequence<float>? frameBuffer,
|
||||
unsigned long frameBufferLength,
|
||||
float time,
|
||||
boolean allowAudioData);
|
||||
};
|
@ -172,6 +172,7 @@ webidl_files = \
|
||||
NodeIterator.webidl \
|
||||
NodeList.webidl \
|
||||
Notification.webidl \
|
||||
NotifyAudioAvailableEvent.webidl \
|
||||
NotifyPaintEvent.webidl \
|
||||
PaintRequest.webidl \
|
||||
PaintRequestList.webidl \
|
||||
|
@ -100,10 +100,6 @@ members = [
|
||||
'nsIBoxObject.width',
|
||||
'nsIBoxObject.height',
|
||||
|
||||
# Audio
|
||||
'nsIDOMNotifyAudioAvailableEvent.frameBuffer',
|
||||
'nsIDOMNotifyAudioAvailableEvent.time',
|
||||
|
||||
# dom/indexedDB
|
||||
'nsIIDBCursor.*',
|
||||
'nsIIDBCursorWithValue.*',
|
||||
|
Loading…
Reference in New Issue
Block a user