summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_audioNotificationSilent_audioFile.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/test/test_audioNotificationSilent_audioFile.html')
-rw-r--r--dom/base/test/test_audioNotificationSilent_audioFile.html73
1 files changed, 73 insertions, 0 deletions
diff --git a/dom/base/test/test_audioNotificationSilent_audioFile.html b/dom/base/test/test_audioNotificationSilent_audioFile.html
new file mode 100644
index 000000000..0b3b89580
--- /dev/null
+++ b/dom/base/test/test_audioNotificationSilent_audioFile.html
@@ -0,0 +1,73 @@
+<!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 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");
+ 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';
+
+ info("Audio playing start");
+ audio.play();
+}
+
+function audioBecomeSilentDuringPlaying() {
+ info("Audio would become silent during playing");
+
+ expectedPlaybackActive = 'inactive-nonaudible';
+}
+
+function finish() {
+ observerService.removeObserver(observer, "audio-playback");
+ ok(true, "Observer removed");
+
+ SimpleTest.finish();
+}
+
+function runTest() {
+ yield audioPlayingStart();
+
+ yield audioBecomeSilentDuringPlaying();
+
+ yield finish();
+}
+
+continueTest();
+
+</script>
+</body>
+</html> \ No newline at end of file