зеркало из https://github.com/mozilla/gecko-dev.git
104 строки
3.1 KiB
HTML
104 строки
3.1 KiB
HTML
<!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>
|
|
<div id="content" style="display: none">
|
|
<audio id="audio1" />
|
|
<audio id="audio2" mozaudiochannel="foo" />
|
|
<audio id="audio3" mozaudiochannel="content" />
|
|
</div>
|
|
|
|
<pre id="test">
|
|
<script type="application/javascript">
|
|
|
|
function test_basic() {
|
|
var audio1 = document.getElementById("audio1");
|
|
ok(audio1, "Audio Element exists");
|
|
is(audio1.mozAudioChannelType, "normal", "Default audio1 channel == 'normal'");
|
|
try {
|
|
audio1.mozAudioChannelType = "foo";
|
|
} catch(e) {}
|
|
is(audio1.mozAudioChannelType, "normal", "Default audio1 channel == 'normal'");
|
|
audio1.mozAudioChannelType = "alarm";
|
|
is(audio1.mozAudioChannelType, "alarm", "Default audio1 channel == 'alarm'");
|
|
|
|
var audio2 = document.getElementById("audio2");
|
|
ok(audio2, "Audio Element exists");
|
|
is(audio2.mozAudioChannelType, "normal", "Default audio2 channel == 'normal'");
|
|
try {
|
|
audio2.mozAudioChannelType = "foo";
|
|
} catch(e) {}
|
|
is(audio2.mozAudioChannelType, "normal", "Default audio2 channel == 'normal'");
|
|
audio2.mozAudioChannelType = "alarm";
|
|
is(audio2.mozAudioChannelType, "alarm", "Default audio2 channel == 'alarm'");
|
|
|
|
var audio3 = document.getElementById("audio3");
|
|
ok(audio3, "Audio Element exists");
|
|
is(audio3.mozAudioChannelType, "content", "Default audio3 channel == 'content'");
|
|
try {
|
|
audio3.mozAudioChannelType = "foo";
|
|
} catch(e) {}
|
|
is(audio3.mozAudioChannelType, "content", "audio3 channel == 'content'");
|
|
audio3.mozAudioChannelType = "alarm";
|
|
is(audio3.mozAudioChannelType, "alarm", "audio3 channel == 'alarm'");
|
|
|
|
runTest();
|
|
}
|
|
|
|
function test_preferences(aChannel) {
|
|
SpecialPowers.pushPrefEnv({"set": [["media.defaultAudioChannel", aChannel ]]},
|
|
function() {
|
|
var audio = document.createElement('audio');
|
|
ok(audio, "Audio Element created");
|
|
is(audio.mozAudioChannelType, aChannel, "Default audio channel == '" + aChannel + "'");
|
|
runTest();
|
|
}
|
|
);
|
|
}
|
|
|
|
function test_wrong_preferences() {
|
|
SpecialPowers.pushPrefEnv({"set": [["media.defaultAudioChannel", 'foobar' ]]},
|
|
function() {
|
|
var audio = document.createElement('audio');
|
|
ok(audio, "Audio Element created");
|
|
is(audio.mozAudioChannelType, 'normal', "Default audio channel == 'normal'");
|
|
runTest();
|
|
}
|
|
);
|
|
}
|
|
var tests = [
|
|
test_basic,
|
|
|
|
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,
|
|
];
|
|
|
|
function runTest() {
|
|
if (!tests.length) {
|
|
SimpleTest.finish();
|
|
return;
|
|
}
|
|
|
|
var test = tests.shift();
|
|
test();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
runTest();
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|