Bug 1402147 - Part 2: Add test to ensure vrdisplayconnect fires when a listener is added after the display is connected r=daoshengmu
authorKearwood "Kip" Gilbert <kgilbert@mozilla.com>
Fri, 05 Jan 2018 16:20:12 -0800
changeset 718455 0123b237b26c24cf64caffa70f18811561bc2cbc
parent 718454 a6cdc53b929fe19aaf820fc83a4b73e8488c806a
child 718456 ec2323f6d9e9d1aec711f9d93855102a7ed6a445
push id94927
push userbmo:gasolin@mozilla.com
push dateWed, 10 Jan 2018 10:34:10 +0000
reviewersdaoshengmu
bugs1402147
milestone59.0a1
Bug 1402147 - Part 2: Add test to ensure vrdisplayconnect fires when a listener is added after the display is connected r=daoshengmu MozReview-Commit-ID: 2LDF15LEbM2
dom/vr/test/mochitest/mochitest.ini
dom/vr/test/mochitest/test_vrDisplay_onvrdisplayconnect.html
--- a/dom/vr/test/mochitest/mochitest.ini
+++ b/dom/vr/test/mochitest/mochitest.ini
@@ -11,12 +11,14 @@ support-files =
 skip-if = (os != "win" && release_or_beta) || (os == "android")
 [test_vrDisplay_canvas2d.html]
 skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655
 [test_vrDisplay_exitPresent.html]
 skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655
 [test_vrDisplay_getFrameData.html]
 # Enable Linux after Bug 1310655, enable Android after Bug 1348246
 skip-if = (os != "win" && release_or_beta) || (os == "android")
+[test_vrDisplay_onvrdisplayconnect.html]
+skip-if = true
 [test_vrDisplay_onvrdisplaydeactivate_crosscontent.html]
 skip-if = true
 [test_vrDisplay_requestPresent.html]
 skip-if = true
new file mode 100644
--- /dev/null
+++ b/dom/vr/test/mochitest/test_vrDisplay_onvrdisplayconnect.html
@@ -0,0 +1,43 @@
+<html>
+  <head>
+    <title>VRDisplay onvrdisplayconnect test</title>
+    <meta name="timeout" content="long"/>
+    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+    <script src="VRSimulationDriver.js"></script>
+    <script src="WebVRHelpers.js"></script>
+    <script src="requestPresent.js"></script>
+    <script src="runVRTest.js"></script>
+  </head>
+  <body>
+    <script>
+
+      function eventAfterConnectedTest() {
+        async_test(function (test) {
+          window.addEventListener("vrdisplayconnect", () => {
+            test.done();
+          });
+        }, "vrdisplayconnect should fire as soon as content listens for it, \
+            even if the VR display was already connected.");
+      }
+
+      function startTest() {
+        promise_test((test) => {
+          return attachVRDisplay(test).then(() => {
+            return promise_test((test) => {
+              return setupVRDisplay(test).then(() => {
+                VRSimulationDriver.UpdateVRDisplay();
+                eventAfterConnectedTest();
+                VRSimulationDriver.UpdateVRDisplay();
+              });
+            });
+          });
+        });
+      }
+
+      runVRTest(startTest);
+    </script>
+    <iframe id="iframe1"></iframe>
+  </body>
+</html>
\ No newline at end of file