Bug 1489375 - part2 : add test. r=padenot
authoralwu <alwu@mozilla.com>
Tue, 18 Sep 2018 14:59:48 +0000
changeset 436986 aca62b00f1e4d3026c90be8809e1eaf00a6d56ab
parent 436985 6ec9bc89a5b392867e0df66d192a2f73eb2d6776
child 436987 ecf3df8fabc71796f1b14ec86da1a038dce77aff
push id34667
push useraiakab@mozilla.com
push dateWed, 19 Sep 2018 02:13:23 +0000
treeherdermozilla-central@3857cbe7b717 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1489375
milestone64.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 1489375 - part2 : add test. r=padenot add test. Differential Revision: https://phabricator.services.mozilla.com/D5800
toolkit/content/tests/browser/browser.ini
toolkit/content/tests/browser/browser_webAudio_hideSoundPlayingIcon.js
--- a/toolkit/content/tests/browser/browser.ini
+++ b/toolkit/content/tests/browser/browser.ini
@@ -122,8 +122,10 @@ support-files =
   data/post_form_inner.sjs
   data/post_form_outer.sjs
 skip-if = e10s # Bug ?????? - test directly manipulates content (gBrowser.contentDocument.getElementById("postForm").submit();)
 [browser_saveImageURL.js]
 uses-unsafe-cpows = true
 [browser_sound_indicator_silent_video.js]
 tags = audiochannel
 [browser_resume_bkg_video_on_tab_hover.js]
+[browser_webAudio_hideSoundPlayingIcon.js]
+tags = audiochannel
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/browser/browser_webAudio_hideSoundPlayingIcon.js
@@ -0,0 +1,61 @@
+/**
+ * This test is used to ensure the 'sound-playing' icon would not disappear after
+ * sites call AudioContext.resume().
+ */
+"use strict";
+
+function setup_test_preference() {
+  return SpecialPowers.pushPrefEnv({"set": [
+    ["media.useAudioChannelService.testing", true],
+    ["browser.tabs.delayHidingAudioPlayingIconMS", 0],
+  ]});
+}
+
+function createAudioContext() {
+  content.ac = new content.AudioContext();
+  const ac = content.ac;
+  const dest = ac.destination;
+  const osc = ac.createOscillator();
+  osc.connect(dest);
+  osc.start();
+}
+
+async function resumeAudioContext() {
+  const ac = content.ac;
+  await ac.resume();
+  ok(true, "AudioContext is resumed.");
+}
+
+async function testResumeRunningAudioContext() {
+  info(`- create new tab -`);
+  const tab = await BrowserTestUtils.openNewForegroundTab(window.gBrowser,
+                                                          "about:blank");
+  const browser = tab.linkedBrowser;
+
+  info(`- create audio context -`);
+  // We want the same audio context to be used across different content
+  // tasks, so it needs to be loaded by a frame script.
+  const mm = tab.linkedBrowser.messageManager;
+  mm.loadFrameScript("data:,(" + createAudioContext.toString() + ")();", false);
+
+  info(`- wait for 'sound-playing' icon showing -`);
+  await waitForTabPlayingEvent(tab, true);
+
+  info(`- resume AudioContext -`);
+  await ContentTask.spawn(browser, null,
+                          resumeAudioContext);
+
+  info(`- 'sound-playing' icon should still exist -`);
+  await waitForTabPlayingEvent(tab, true);
+
+  info(`- remove tab -`);
+  await BrowserTestUtils.removeTab(tab);
+}
+
+add_task(async function start_test() {
+  info("- setup test preference -");
+  await setup_test_preference();
+
+  info("- start testing -");
+  await testResumeRunningAudioContext();
+});