Browse Source

spec: update media-started-playing tests based on the autoplay policy

deepak1556 6 years ago
parent
commit
7ec05fb202
2 changed files with 11 additions and 7 deletions
  1. 0 1
      spec/fixtures/pages/audio.html
  2. 11 6
      spec/webview-spec.js

+ 0 - 1
spec/fixtures/pages/audio.html

@@ -1 +0,0 @@
-<audio muted src="../assets/tone.wav"></audio>

+ 11 - 6
spec/webview-spec.js

@@ -971,12 +971,17 @@ describe('<webview> tag', function () {
 
   describe('media-started-playing media-paused events', () => {
     it('emits when audio starts and stops playing', async () => {
-      await loadWebView(webview, { src: `file://${fixtures}/pages/audio.html` })
-
-      // XXX(alexeykuzmin): Starting from Ch66 playing an audio requires
-      // a user interaction. See https://goo.gl/xX8pDD.
-
-      webview.executeJavaScript('document.querySelector("audio").play()', true)
+      await loadWebView(webview, { src: `file://${fixtures}/pages/base-page.html` })
+
+      // With the new autoplay policy, audio elements must be unmuted
+      // see https://goo.gl/xX8pDD.
+      const source = `
+        const audio = document.createElement("audio")
+        audio.src = "../assets/tone.wav"
+        document.body.appendChild(audio);
+        audio.play()
+      `
+      webview.executeJavaScript(source, true)
       await waitForEvent(webview, 'media-started-playing')
 
       webview.executeJavaScript('document.querySelector("audio").pause()', true)