Bug 1351547 - Part 1: Add WebVR Canvas2D mochitest for detecting crash; r=kip
authorDaosheng Mu <daoshengmu@gmail.com>
Wed, 26 Apr 2017 07:00:04 +0200
changeset 354849 d30535c0bb622ba4efa4680f0400bff89bb8e96b
parent 354848 b77aaea5f6c975821d04349eecdb8c7423d5d8df
child 354850 1a95eef9b0b55b1f072a1cafe702b84bf8faa142
push id89587
push usercbook@mozilla.com
push dateWed, 26 Apr 2017 05:00:52 +0000
treeherdermozilla-inbound@1a95eef9b0b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1351547, 100644
milestone55.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 1351547 - Part 1: Add WebVR Canvas2D mochitest for detecting crash; r=kip MozReview-Commit-ID: DA8Lx3jGQ4p --- dom/vr/test/mochitest.ini | 2 ++ dom/vr/test/test_vrDisplay_canvas2d.html | 51 ++++++++++++++++++++++++++++ dom/vr/test/test_vrDisplay_exitPresent.html | 1 - dom/vr/test/test_vrDisplay_getFrameData.html | 2 +- 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 dom/vr/test/test_vrDisplay_canvas2d.html
dom/vr/test/mochitest.ini
dom/vr/test/test_vrDisplay_canvas2d.html
dom/vr/test/test_vrDisplay_exitPresent.html
dom/vr/test/test_vrDisplay_getFrameData.html
--- a/dom/vr/test/mochitest.ini
+++ b/dom/vr/test/mochitest.ini
@@ -1,15 +1,17 @@
 [DEFAULT]
 support-files =
   VRSimulationDriver.js
   requestPresent.js
   runVRTest.js
   WebVRHelpers.js
 
+[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]
 skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655
 [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/test_vrDisplay_canvas2d.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>VRDisplay Canvas2D</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="runVRTest.js"></script>
+  </head>
+  <body>
+    <script>
+      var vrDisplay;
+
+      function requestPresentTest() {
+        async_test(function (test) {
+          vrDisplay.requestAnimationFrame(callback);
+
+          function callback() {
+            vrDisplay.resetPose();
+            vrDisplay.getLayers();
+            vrDisplay.submitFrame();
+            vrDisplay.getEyeParameters("right");
+            test.done();
+          }
+        }, "Finish WebVR Canvas2D requestPresentTest.");
+      }
+
+      function startTest() {
+        promise_test((test) => {
+          var canvas = document.createElement('canvas');
+          (document.body || document.documentElement).appendChild(canvas);
+          var context = canvas.getContext('2d');
+          var img = document.createElement('img');
+          img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACw=";
+
+          return navigator.getVRDisplays().then((displays) => {
+            assert_equals(displays.length, 1, "displays.length must be one after attach.");
+            vrDisplay = displays[0];
+            var frameData = new VRFrameData();
+            return vrDisplay.requestPresent([{source: canvas}]).then(() => {
+              requestPresentTest();
+            });
+          });
+        }, "Finish running WebVR Canvas2D test.");
+      }
+
+      runVRTest(startTest);
+    </script>
+  </body>
+</html>
\ No newline at end of file
--- a/dom/vr/test/test_vrDisplay_exitPresent.html
+++ b/dom/vr/test/test_vrDisplay_exitPresent.html
@@ -13,17 +13,16 @@
       function testExitPresentOnOtherIframe(content) {
           return content.navigator.getVRDisplays().then((displays) => {
             content.vrDisplay = displays[0];
             return content.vrDisplay.exitPresent();
         });
       }
       var initVRPresentation = function(content) {
             return content.navigator.getVRDisplays().then((displays) => {
-            console.log("GetVRDisplay!!");
             content.vrDisplay = displays[0];
             content.canvas = content.document.createElement("canvas");
             content.canvas.id = "vrCanvas";
             return content.vrDisplay.requestPresent([{source:content.canvas}]);
           });
       }
       function startTest() {
         var ifr1 = document.getElementById("iframe1");
--- a/dom/vr/test/test_vrDisplay_getFrameData.html
+++ b/dom/vr/test/test_vrDisplay_getFrameData.html
@@ -107,17 +107,17 @@
                   assert_true(checkValueInFloat32Array(pose1.angularVelocity,
                                                        pose2.angularVelocity),
                               "pose.angularVelocity at a frame should be equal.");
 
                   assert_true(checkValueInFloat32Array(pose1.angularAcceleration,
                                                        pose2.angularAcceleration),
                               "pose.angularAcceleration at a frame should be equal.");
                   test.done();
-                };
+                }
               });
             }, "WebVR returns the same frameData within a frame fulfilled");
           }
 
           function insertNewFrameData() {
             var poseOrient = new Float32Array([-0.208, -0.017, 0.055, -0.930]);
             var posePos = new Float32Array([-0.261, 0.036, -0.150]);
             var poseAngVel = new Float32Array([0.018, -0.001, -0.003]);