forked from BrowserWorks/Waterfox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1549041 - Test that documents receive the right audio notificatio…
…n events when playback is done using the Web Audio API. r=karlt Differential Revision: https://phabricator.services.mozilla.com/D30657 --HG-- extra : moz-landing-system : lando
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<meta charset=utf-8> | ||
<script> | ||
var ac = new AudioContext(); | ||
var osc = ac.createOscillator(); | ||
osc.connect(ac.destination); | ||
osc.start(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
dom/base/test/test_audioNotificationNavigationWebAudio.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Test for audio controller in windows, when using the Web Audio API</title> | ||
<script src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> | ||
</head> | ||
<body> | ||
<pre id="test"> | ||
</pre> | ||
<iframe></iframe> | ||
|
||
<script type="application/javascript"> | ||
|
||
SimpleTest.waitForExplicitFinish(); | ||
|
||
// playback starts, stops when the page is reloaded, and starts again. | ||
var expectedNotification = ["active", "inactive-pause", "active"]; | ||
var iframe = null; | ||
|
||
var observer = { | ||
observe: function(subject, topic, data) { | ||
is(topic, "audio-playback", "audio-playback received"); | ||
var expected = expectedNotification.shift(); | ||
is(data, expected, "This is the right notification"); | ||
if (expected != "inactive-pause") { | ||
runTest(); | ||
} | ||
} | ||
}; | ||
|
||
var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"] | ||
.getService(SpecialPowers.Ci.nsIObserverService); | ||
|
||
var tests = [ | ||
function() { | ||
iframe = document.querySelector("iframe"); | ||
observerService.addObserver(observer, "audio-playback"); | ||
ok(true, "Observer set"); | ||
runTest(); | ||
}, | ||
|
||
function() { | ||
iframe.src = "file_webAudioAudible.html"; | ||
}, | ||
|
||
function() { | ||
// Reload | ||
iframe.src = "file_webAudioAudible.html"; | ||
}, | ||
function() { | ||
// Wait for the "active" notification, that is expected after the previous | ||
// load of "file_webAudioAudible.html". | ||
runTest(); | ||
} | ||
]; | ||
|
||
function runTest() { | ||
if (!tests.length) { | ||
observerService.removeObserver(observer, "audio-playback"); | ||
ok(true, "Observer removed"); | ||
SimpleTest.finish(); | ||
return; | ||
} | ||
|
||
var test = tests.shift(); | ||
test(); | ||
} | ||
|
||
onload = runTest; | ||
|
||
</script> | ||
</body> | ||
</html> | ||
|