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