diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/webaudio/test/test_mozaudiochannel.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/webaudio/test/test_mozaudiochannel.html')
-rw-r--r-- | dom/media/webaudio/test/test_mozaudiochannel.html | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_mozaudiochannel.html b/dom/media/webaudio/test/test_mozaudiochannel.html new file mode 100644 index 000000000..6ba14347b --- /dev/null +++ b/dom/media/webaudio/test/test_mozaudiochannel.html @@ -0,0 +1,151 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test for mozaudiochannel</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<p id="display"></p> +<pre id="test"> +<script type="application/javascript"> + +function test_basic() { + var ac = new AudioContext(); + ok(ac, "AudioContext created"); + + // Default + is(ac.mozAudioChannelType, "normal", "Default ac channel == 'normal'"); + + // Unpermitted channels + ac = new AudioContext("content"); + is(ac.mozAudioChannelType, "normal", "Default ac channel == 'normal'"); + + ac = new AudioContext("notification"); + is(ac.mozAudioChannelType, "normal", "Default ac channel == 'normal'"); + + ac = new AudioContext("alarm"); + is(ac.mozAudioChannelType, "normal", "Default ac channel == 'normal'"); + + ac = new AudioContext("telephony"); + is(ac.mozAudioChannelType, "normal", "Default ac channel == 'normal'"); + + ac = new AudioContext("ringer"); + is(ac.mozAudioChannelType, "normal", "Default ac channel == 'normal'"); + + ac = new AudioContext("publicnotification"); + is(ac.mozAudioChannelType, "normal", "Default ac channel == 'normal'"); + + runTest(); +} + +function test_permission(aChannel) { + var ac = new AudioContext(); + ok(ac, "AudioContext created"); + + is(ac.mozAudioChannelType, "normal", "Default ac channel == 'normal'"); + + var channel = SpecialPowers.wrap(ac).testAudioChannelInAudioNodeStream(); + is(channel, "normal", "AudioNodeStream is using the correct default audio channel."); + + SpecialPowers.pushPermissions( + [{ "type": "audio-channel-" + aChannel, "allow": true, "context": document }], + function() { + var ac = new AudioContext(aChannel); + is(ac.mozAudioChannelType, aChannel, "Default ac channel == '" + aChannel + "'"); + + var channel = SpecialPowers.wrap(ac).testAudioChannelInAudioNodeStream(); + is(channel, aChannel, "AudioNodeStream is using the correct new audio channel."); + + runTest(); + } + ); +} + +function test_preferences(aChannel) { + SpecialPowers.pushPrefEnv({"set": [["media.defaultAudioChannel", aChannel ]]}, + function() { + SpecialPowers.pushPermissions( + [{ "type": "audio-channel-" + aChannel, "allow": false, "context": document }], + function() { + var ac = new AudioContext(aChannel); + ok(ac, "AudioContext created"); + is(ac.mozAudioChannelType, aChannel, "Default ac channel == '" + aChannel + "'"); + + var channel = SpecialPowers.wrap(ac).testAudioChannelInAudioNodeStream(); + is(channel, aChannel, "AudioNodeStream is using the correct audio channel."); + + runTest(); + } + ); + } + ); +} + +function test_wrong_preferences() { + SpecialPowers.pushPrefEnv({"set": [["media.defaultAudioChannel", 'foobar' ]]}, + function() { + var ac = new AudioContext(); + ok(ac, "AudioContext created"); + is(ac.mozAudioChannelType, 'normal', "Default ac channel == 'normal'"); + runTest(); + } + ); +} + +function test_testAudioChannelInAudioNodeStream() { + var ac = new AudioContext(); + ok(ac, "AudioContext created"); + + var status = false; + try { + ac.testAudioChannelInAudioNodeStream(); + } catch(e) { + status = true; + } + + ok(status, "testAudioChannelInAudioNodeStream() should not exist in content."); + runTest(); +} + +var tests = [ + test_basic, + + function() { test_permission("content"); }, + function() { test_permission("notification"); }, + function() { test_permission("alarm"); }, + function() { test_permission("telephony"); }, + function() { test_permission("ringer"); }, + function() { test_permission("publicnotification"); }, + + function() { test_preferences("content"); }, + function() { test_preferences("notification"); }, + function() { test_preferences("alarm"); }, + function() { test_preferences("telephony"); }, + function() { test_preferences("ringer"); }, + function() { test_preferences("publicnotification"); }, + + test_wrong_preferences, + + test_testAudioChannelInAudioNodeStream, +]; + +function runTest() { + if (!tests.length) { + SimpleTest.finish(); + return; + } + + var test = tests.shift(); + test(); +} + +SpecialPowers.pushPrefEnv({"set": [["media.useAudioChannelAPI", true ]]}, runTest); +SimpleTest.waitForExplicitFinish(); +SimpleTest.requestLongerTimeout(5); + +</script> +</pre> +</body> +</html> |