gecko/content/events/test/test_bug847597.html
Olli Pettay 07409694c9 Bug 847597 - Paris binding for NotifyAudioAvailableEvent, r=peterv
--HG--
extra : rebase_source : 2fb578e3f0c7a60f95f3a2f13634f9b4c887d95f
2013-05-02 20:11:12 +03:00

82 lines
2.4 KiB
HTML

<!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>