зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1235612 - Part 6: Add and modify test cases. r=baku
MozReview-Commit-ID: FqIvjv7t2Vp --HG-- extra : rebase_source : 32826bbbc22e8a99f20bf969e43d876feaa45e61
This commit is contained in:
Родитель
9771068fea
Коммит
d457b34009
Двоичные данные
browser/base/content/test/general/audio.ogg
Двоичные данные
browser/base/content/test/general/audio.ogg
Двоичный файл не отображается.
|
@ -147,6 +147,7 @@ skip-if = os == "linux" # Bug 924307
|
|||
[browser_addKeywordSearch.js]
|
||||
[browser_alltabslistener.js]
|
||||
[browser_audioTabIcon.js]
|
||||
tags = audiochannel
|
||||
[browser_backButtonFitts.js]
|
||||
skip-if = os == "mac" # The Fitt's Law back button is not supported on OS X
|
||||
[browser_beforeunload_duplicate_dialogs.js]
|
||||
|
|
Двоичный файл не отображается.
|
@ -1,6 +1,7 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
audio.ogg
|
||||
audioEndedDuringPlaying.webm
|
||||
iframe_bug962251.html
|
||||
iframe_bug976673.html
|
||||
iframe_main_bug1022229.html
|
||||
|
@ -285,6 +286,10 @@ skip-if = buildapp == 'b2g' # Requires webgl support
|
|||
[test_audioNotification.html]
|
||||
tags = audiochannel
|
||||
skip-if = buildapp == 'mulet'
|
||||
[test_audioNotificationSilent_audioFile.html]
|
||||
tags = audiochannel
|
||||
[test_audioNotificationSilent_webAudio.html]
|
||||
tags = audiochannel
|
||||
[test_audioNotificationStream.html]
|
||||
tags = audiochannel
|
||||
skip-if = buildapp == 'mulet'
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Audio-playback should be inactive when input file is silent</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var generator = runTest();
|
||||
var expectedPlaybackActive = null;
|
||||
var expectedPlaying = null;
|
||||
|
||||
var audio = new Audio();
|
||||
audio.src = "audioEndedDuringPlaying.webm";
|
||||
|
||||
var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
|
||||
var observer = {
|
||||
observe: function(subject, topic, data) {
|
||||
is(topic, "audio-playback", "audio-playback received");
|
||||
is(data, expectedPlaybackActive, "Corrrect audible state");
|
||||
is(!audio.ended, expectedPlaying, "Corrrect playing state");
|
||||
continueTest();
|
||||
}
|
||||
};
|
||||
|
||||
function continueTest() {
|
||||
try {
|
||||
generator.next();
|
||||
} catch (e if e instanceof StopIteration) {
|
||||
error("Stop test because of exception!");
|
||||
}
|
||||
}
|
||||
|
||||
function audioPlayingStart() {
|
||||
observerService.addObserver(observer, "audio-playback", false);
|
||||
ok(true, "Observer set");
|
||||
|
||||
expectedPlaybackActive = 'active';
|
||||
expectedPlaying = true;
|
||||
|
||||
info("Audio playing start");
|
||||
audio.play();
|
||||
}
|
||||
|
||||
function audioBecomeSilentDuringPlaying() {
|
||||
info("Audio would become silent during playing");
|
||||
|
||||
expectedPlaybackActive = 'inactive';
|
||||
expectedPlaying = true;
|
||||
}
|
||||
|
||||
function audioPlayingEnd() {
|
||||
audio.onended = function() {
|
||||
info("Audio playback ended");
|
||||
audio.onended = null;
|
||||
|
||||
observerService.removeObserver(observer, "audio-playback");
|
||||
ok(true, "Observer removed");
|
||||
|
||||
SimpleTest.finish();
|
||||
};
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
yield audioPlayingStart();
|
||||
|
||||
yield audioBecomeSilentDuringPlaying();
|
||||
|
||||
yield audioPlayingEnd();
|
||||
}
|
||||
|
||||
continueTest();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,103 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Audio-playback should be inactive when web-audio is silent</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var generator = runTest();
|
||||
var expectedPlaybackActive = null;
|
||||
var expectedPlaying = null;
|
||||
|
||||
var ac = new AudioContext();
|
||||
var audibleDuration = 3;
|
||||
|
||||
var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
|
||||
var observer = {
|
||||
observe: function(subject, topic, data) {
|
||||
is(topic, "audio-playback", "audio-playback received");
|
||||
is(data, expectedPlaybackActive, "Corrrect audible state");
|
||||
is(ac.state, expectedPlaying, "Corrrect playing state");
|
||||
continueTest();
|
||||
}
|
||||
};
|
||||
|
||||
function continueTest() {
|
||||
try {
|
||||
generator.next();
|
||||
} catch (e if e instanceof StopIteration) {
|
||||
error("Stop test because of exception!");
|
||||
}
|
||||
}
|
||||
|
||||
function playOscillatorNode() {
|
||||
var dest = ac.destination;
|
||||
var osc = ac.createOscillator();
|
||||
osc.connect(dest);
|
||||
osc.start(0);
|
||||
osc.stop(ac.currentTime + audibleDuration);
|
||||
}
|
||||
|
||||
function audioPlayingStart() {
|
||||
observerService.addObserver(observer, "audio-playback", false);
|
||||
ok(true, "Observer set");
|
||||
|
||||
expectedPlaybackActive = 'active';
|
||||
expectedPlaying = "running";
|
||||
|
||||
info("Audio playing start");
|
||||
playOscillatorNode();
|
||||
}
|
||||
|
||||
function audioBecomeSilentDuringPlaying() {
|
||||
info("Audio would become silent during playing");
|
||||
|
||||
expectedPlaybackActive = 'inactive';
|
||||
expectedPlaying = "running";
|
||||
}
|
||||
|
||||
function finish() {
|
||||
observerService.removeObserver(observer, "audio-playback");
|
||||
ok(true, "Observer removed");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function startAudioContext() {
|
||||
if (ac.state != "running") {
|
||||
ac.resume();
|
||||
ac.onstatechange = function() {
|
||||
if (ac.state == "running") {
|
||||
ok(true, "AudioContext starts running!");
|
||||
ac.onstatechange = null;
|
||||
continueTest();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ok(true, "AudioContext is running!");
|
||||
continueTest();
|
||||
}
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
yield startAudioContext();
|
||||
|
||||
yield audioPlayingStart();
|
||||
|
||||
yield audioBecomeSilentDuringPlaying();
|
||||
|
||||
yield finish();
|
||||
}
|
||||
|
||||
continueTest();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -3,10 +3,6 @@
|
|||
var audio = new Audio();
|
||||
audio.oncanplay = function() {
|
||||
audio.oncanplay = null;
|
||||
audio.onplaying = function() {
|
||||
audio.onplaying = null;
|
||||
audio.pause();
|
||||
};
|
||||
audio.play();
|
||||
};
|
||||
audio.src = "audio.ogg";
|
||||
|
|
Загрузка…
Ссылка в новой задаче