Bug 1485160 - part2 : add test. r=mconley
authoralwu <alwu@mozilla.com>
Thu, 23 Aug 2018 21:50:14 +0000
changeset 481564 65c46c73f0dcd8a9eefee010ddf5a6886ded8a30
parent 481563 9c57953b24de71746904a5a56fd7a2c8d634bedf
child 481565 f7ad979ef6da000082e124258474910b85d58262
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersmconley
bugs1485160
milestone63.0a1
Bug 1485160 - part2 : add test. r=mconley Differential Revision: https://phabricator.services.mozilla.com/D3931
toolkit/content/tests/browser/browser.ini
toolkit/content/tests/browser/browser_autoplay_audibleMediaOccurred.js
--- a/toolkit/content/tests/browser/browser.ini
+++ b/toolkit/content/tests/browser/browser.ini
@@ -25,16 +25,17 @@ support-files =
   silentAudioTrack.webm
   doggy.png
   firebird.png
 
 [browser_audioCompeting.js]
 tags = audiochannel
 [browser_audioCompeting_onlyForActiveAgent.js]
 tags = audiochannel
+[browser_autoplay_audibleMediaOccurred.js]
 [browser_autoplay_policy_iframe_hierarchy.js]
 support-files =
   file_autoplay_three_layers_frame1.html
   file_autoplay_three_layers_frame2.html
   file_autoplay_two_layers_frame1.html
   file_autoplay_two_layers_frame2.html
   file_video.html
   gizmo.mp4
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/browser/browser_autoplay_audibleMediaOccurred.js
@@ -0,0 +1,25 @@
+/**
+ * This test is used to test whether the topic 'AudibleAutoplayMediaOccurred'
+ * is sent correctly when the autoplay audible media tries to start.
+ */
+"use strict";
+
+const PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_mediaPlayback.html";
+
+add_task(async function testAudibleAutoplayMedia() {
+  info("- open new tab  -");
+  let tab = await BrowserTestUtils.openNewForegroundTab(window.gBrowser,
+                                                        "about:blank");
+  let browser = tab.linkedBrowser;
+
+  // start observing the topic before loading the page to ensure we can get it.
+  let audibleAutoplayOccurred = TestUtils.topicObserved("AudibleAutoplayMediaOccurred");
+  browser.loadURI(PAGE);
+
+  await BrowserTestUtils.browserLoaded(browser);
+  await audibleAutoplayOccurred;
+  ok(true, "Got the topic 'AudibleAutoplayMediaOccurred'.");
+
+  info("- remove tab -");
+  BrowserTestUtils.removeTab(tab);
+});