Bug 1549041 - Test that documents receive the right audio notification events when playback is done using the Web Audio API. r=karlt
authorPaul Adenot <paul@paul.cx>
Fri, 17 May 2019 09:46:25 +0000
changeset 474311 6d0bd72a59672bf12d7f0248644c7c708fb74d74
parent 474310 baa019d214ce6e9e89d1d7129479c7f2faa3a925
child 474312 6b3a8394727fbde512c4ee39a4d8d21a17f10581
push id36027
push usershindli@mozilla.com
push dateFri, 17 May 2019 16:24:38 +0000
treeherdermozilla-central@c94c54aff466 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1549041
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549041 - Test that documents receive the right audio notification events when playback is done using the Web Audio API. r=karlt Differential Revision: https://phabricator.services.mozilla.com/D30657
dom/base/test/file_webAudioAudible.html
dom/base/test/mochitest.ini
dom/base/test/test_audioNotificationNavigationWebAudio.html
new file mode 100644
--- /dev/null
+++ b/dom/base/test/file_webAudioAudible.html
@@ -0,0 +1,7 @@
+<meta charset=utf-8>
+<script>
+var ac = new AudioContext();
+var osc = ac.createOscillator();
+osc.connect(ac.destination);
+osc.start();
+</script>
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -192,16 +192,17 @@ support-files =
   w3element_traversal.svg
   wholeTexty-helper.xml
   referrerHelper.js
   img_referrer_testserver.sjs
   file_audioLoop.html
   file_webaudioLoop.html
   file_webaudioLoop2.html
   file_webaudio_startstop.html
+  file_webAudioAudible.html
   file_pluginAudio.html
   file_pluginAudioNonAutoStart.html
   noaudio.webm
   referrer_helper.js
   referrer_testserver.sjs
   script_postmessages_fileList.js
   iframe_postMessages.html
   test_anonymousContent_style_csp.html^headers^
@@ -267,16 +268,19 @@ skip-if = (os == "win" && processor == "
 tags = audiochannel
 skip-if = (os == "win" && processor == "aarch64") # bug 1535775
 [test_audioNotificationStream.html]
 tags = audiochannel
 skip-if = (os == "win" && processor == "aarch64") # bug 1535775
 [test_audioNotificationStopOnNavigation.html]
 tags = audiochannel
 skip-if = (os == "win" && processor == "aarch64") # bug 1535775
+[test_audioNotificationNavigationWebAudio.html]
+tags = audiochannel
+skip-if = (os == "win" && processor == "aarch64") # bug 1535775
 [test_audioNotificationWithEarlyPlay.html]
 tags = audiochannel
 skip-if = (os == "win" && processor == "aarch64") # bug 1535775
 [test_base.xhtml]
 [test_bug5141.html]
 [test_bug28293.html]
 [test_bug28293.xhtml]
 [test_bug51034.html]
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_audioNotificationNavigationWebAudio.html
@@ -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>
+