Bug 1424271 - convert mochitest test_AudioListener.html to a web-platform-test r?padenot draft
authorp1509425
Fri, 05 Jan 2018 16:49:07 +0100
changeset 717084 1f8bf942111cf28a8ce260e86d64127ed9b0432b
parent 717083 ccbfff9e6b68aa35b91f66758d10c679e62fc4d3
child 717085 bfa6fbe910960686130ec4f1fbb0d21a570f21f4
push id94557
push userbmo:alan.guyoch@gmail.com
push dateMon, 08 Jan 2018 07:50:18 +0000
reviewerspadenot
bugs1424271
milestone59.0a1
Bug 1424271 - convert mochitest test_AudioListener.html to a web-platform-test r?padenot MozReview-Commit-ID: LjTC1kxVY5Q
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/test_AudioListener.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -348582,16 +348582,22 @@
     ]
    ],
    "webaudio/the-audio-api/the-audiocontext-interface/test_AudioContext.html": [
     [
      "/webaudio/the-audio-api/the-audiocontext-interface/test_AudioContext.html",
      {}
     ]
    ],
+   "webaudio/the-audio-api/the-audiocontext-interface/test_AudioListener.html": [
+    [
+     "/webaudio/the-audio-api/the-audiocontext-interface/test_AudioListener.html",
+     {}
+    ]
+   ],
    "webaudio/the-audio-api/the-audiocontext-interface/test_audioDestinationNode.html": [
     [
      "/webaudio/the-audio-api/the-audiocontext-interface/test_audioDestinationNode.html",
      {}
     ]
    ],
    "webaudio/the-audio-api/the-audiodestinationnode-interface/idl-test.html": [
     [
@@ -576513,16 +576519,20 @@
   "webaudio/the-audio-api/the-audiocontext-interface/.gitkeep": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
   "webaudio/the-audio-api/the-audiocontext-interface/test_AudioContext.html": [
    "e8833ffc68e8a1dbee1fc48f15347f35dcca7a5a",
    "testharness"
   ],
+  "webaudio/the-audio-api/the-audiocontext-interface/test_AudioListener.html": [
+   "940029c8ed0a0dcf87d618a64cdb3358deb5a7bf",
+   "testharness"
+  ],
   "webaudio/the-audio-api/the-audiocontext-interface/test_audioDestinationNode.html": [
    "10a4852ec668833e7047610aa0085861a9f96f56",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audiodestinationnode-interface/.gitkeep": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/test_AudioListener.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <script src="/resources/testharness.js"></script>
+  <script src="/resources/testharnessreport.js"></script>
+  <script>
+var t = async_test();
+var context = new AudioContext();
+assert_true("listener" in context, "AudioContext.listener should exist");
+assert_true(
+  Math.abs(context.listener.dopplerFactor - 1.0) < 1e-4,
+  "Correct default doppler factor"
+);
+assert_true(
+  Math.abs(context.listener.speedOfSound - 343.3) < 1e-4,
+  "Correct default speed of sound value"
+);
+context.listener.dopplerFactor = 0.5;
+assert_true(
+  Math.abs(context.listener.dopplerFactor - 0.5) < 1e-4,
+  "The doppler factor value can be changed"
+);
+context.listener.speedOfSound = 400;
+assert_true(
+  Math.abs(context.listener.speedOfSound - 400) < 1e-4,
+  "The speed of sound can be changed"
+);
+// The values set by the following cannot be read from script, but the
+// implementation is simple enough, so we just make sure that nothing throws.
+with (context.listener) {
+  setPosition(1.0, 1.0, 1.0);
+  setOrientation(1.0, 1.0, 1.0, 1.0, 1.0, 1.0);
+  setVelocity(0.5, 1.0, 1.5);
+}
+t.done();
+  </script>
+</head>
+</body>
+</html>