Bug 1080922 - Add subtest logging to mochi-single.html. - r=kamidphish
authorjdashg <jdashg+github@gmail.com>
Thu, 09 Oct 2014 16:01:47 -0700
changeset 209896 d0617afd919996c6592d22121526f27ead09efce
parent 209895 216915390f9b50a2d1520a41bc9ff5b150c4ded2
child 209897 9652f8a8c37b5456ec274cd274acefd5eb4c8319
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerskamidphish
bugs1080922
milestone35.0a1
Bug 1080922 - Add subtest logging to mochi-single.html. - r=kamidphish
dom/canvas/test/webgl-conformance/always-fail.html
dom/canvas/test/webgl-conformance/generate-wrappers-and-manifest.py
dom/canvas/test/webgl-conformance/iframe-autoresize.js
dom/canvas/test/webgl-conformance/mochi-single.html
dom/canvas/test/webgl-conformance/mochi-wrapper.css
dom/canvas/test/webgl-conformance/mochi-wrapper.html.template
dom/canvas/test/webgl-conformance/mochitest.ini.template
--- a/dom/canvas/test/webgl-conformance/always-fail.html
+++ b/dom/canvas/test/webgl-conformance/always-fail.html
@@ -1,25 +1,21 @@
 <!DOCTYPE html>
+<meta charset='utf-8'>
 <html>
-  <head>
-<meta charset="utf-8">
+<head>
     <title>Always fail test</title>
-    <link rel="stylesheet" href="resources/js-test-style.css"/>
-    <script src="resources/js-test-pre.js"></script>
+    <link rel='stylesheet' href='resources/js-test-style.css'/>
+    <script src='resources/js-test-pre.js'></script>
 </head>
 <body>
-<canvas id="example" width="50" height="50">
-</canvas>
-<div id="description"></div>
-<div id="console"></div>
+  <div id='description'></div>
+  <div id='console'></div>
 
-<script>
-description("Deliberately fail so as to test our harness.");
+  <script>
+    description('Deliberately fail so as to test our harness.');
 
-testFailed("The harness should expect and handle this failure.");
+    testFailed('The harness should expect and handle this failure.');
 
-finishTest();
-</script>
-
+    finishTest();
+  </script>
 </body>
 </html>
-
--- a/dom/canvas/test/webgl-conformance/generate-wrappers-and-manifest.py
+++ b/dom/canvas/test/webgl-conformance/generate-wrappers-and-manifest.py
@@ -19,16 +19,19 @@ FILE_PATH_PREFIX = os.path.basename(os.g
 
 SUPPORT_DIRS = [
     'conformance',
     'resources',
 ]
 
 EXTRA_SUPPORT_FILES = [
     'always-fail.html',
+    'iframe-autoresize.js',
+    'mochi-single.html',
+    '../webgl-mochitest/driver-info.js',
 ]
 
 ACCEPTABLE_ERRATA_KEYS = set([
   'skip-if',
 ])
 
 GENERATED_HEADER = '''
 # This is a GENERATED FILE. Do not edit it directly.
@@ -373,10 +376,8 @@ if __name__ == '__main__':
     testWebPathList = GetTestList()
 
     wrapperFilePathList = WriteWrappers(testWebPathList)
 
     supportFilePathList = GetSupportFileList()
     WriteManifest(wrapperFilePathList, supportFilePathList)
 
     print('Done!')
-
-
new file mode 100644
--- /dev/null
+++ b/dom/canvas/test/webgl-conformance/iframe-autoresize.js
@@ -0,0 +1,32 @@
+IFrameAutoresize = (function(){
+  var IFRAME_BODY_MARGIN = 8;
+  var UPDATE_INTERVAL = 100; // ms
+  var MIN_HEIGHT = 100;
+
+  function Start(elem, hasMargin) {
+    var fnResize = function() {
+      var frameBody = elem.contentWindow.document.body;
+      if (frameBody) {
+        var frameHeight = frameBody.scrollHeight;
+        if (hasMargin) {
+          frameHeight += 2*IFRAME_BODY_MARGIN;
+        }
+
+        elem.height = Math.max(MIN_HEIGHT, frameHeight);
+      }
+
+      setTimeout(fnResize, UPDATE_INTERVAL);
+    }
+    fnResize();
+  }
+
+  function StartById(id, hasMargin) {
+    var elem = document.getElementById(id);
+    Start(elem, hasMargin);
+  }
+
+  return {
+    Start: Start,
+    StartById: StartById,
+  };
+})();
--- a/dom/canvas/test/webgl-conformance/mochi-single.html
+++ b/dom/canvas/test/webgl-conformance/mochi-single.html
@@ -1,58 +1,60 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
 <title>
 WebGL Conformance Test Suite Single Test Wrapper
 </title>
 <!-- Uncomment this to use this without mochi-wrapper.html files.
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+<script type='application/javascript' src='/tests/SimpleTest/SimpleTest.js'></script>
+<link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
 -->
-<script src="../webgl-mochitest/driver-info.js"></script>
+<script src='../webgl-mochitest/driver-info.js'></script>
+<script src='iframe-autoresize.js'></script>
 </head>
-<body>
+<body style='margin:0'>
+
 <div>Status: <span id='status'>Initializing</span></div>
 <div>Path: <span id='path'>-</span></div>
 <div>Failures: <span id='results'>-</span></div>
-<iframe id='test-frame' width='100%' scrolling='no'></iframe>
+<hr/>
+<iframe style='border:none' id='test-frame' width='100%' scrolling='no'></iframe>
 <script>
 'use strict';
 
-var IFRAME_BODY_MARGIN = 8;
-var IFRAME_SIZE_UPDATE_INTERVAL = 100; // ms
-
 var statusElem = document.getElementById('status');
 var pathElem = document.getElementById('path');
 var resultsElem = document.getElementById('results');
 var frameElem = document.getElementById('test-frame');
 
+IFrameAutoresize.Start(frameElem, true);
+
 ////////////////////////////////////////////////////////////////////////
 // Forward SimpleTest functions and replace if missing.
 
 if (!window.ok) {
   window.ok = parent.ok;
 }
 if (!window.todo) {
   window.todo = parent.todo;
 }
 if (!window.SimpleTest) {
   window.SimpleTest = parent.SimpleTest;
 }
 
 if (!window.ok) {
   window.ok = function(status, message) {
-    console.log('ok(' + status + ', "' + message + '")');
+    console.log('ok(' + status + ', \'' + message + '\')');
   }
 }
 if (!window.todo) {
   window.todo = function(status, message) {
-    console.log('todo(' + status + ', "' + message + '")');
+    console.log('todo(' + status + ', \'' + message + '\')');
   }
 }
 if (!window.SimpleTest) {
   window.SimpleTest = {
     waitForExplicitFinish: function(){},
     finish: function(){},
   };
 }
@@ -155,88 +157,89 @@ function GetExpectedTestFailSet() {
 
   return failSet;
 }
 
 ////////////////////////////////////////////////////////////////////////
 // Test running and harness.
 
 var gTestPath = null;
+var gExpectFailures;
+var gIsComplete;
 
 function RunTest(testPath) {
   console.log('testPath: ' + testPath);
 
   if (testPath == ALWAYS_FAIL_TEST_FILEPATH) {
     // Make it easier to respond to new test failures.
     console.log('OS: ' + DriverInfo.getOS());
     console.log('OS version: ' + DriverInfo.getOSVersion());
     console.log('Driver: ' + DriverInfo.getDriver());
   }
 
-  pathElem.innerHTML = testPath;
   gTestPath = testPath;
-
-  // Auto-update to grow the size of the doc.
-  function UpdateFrameSize() {
-    var frameBody = frameElem.contentWindow.document.body;
+  pathElem.innerHTML = gTestPath;
 
-    if (frameBody) {
-      var scrollHeight = frameBody.scrollHeight;
-      frameElem.height = scrollHeight + 2*IFRAME_BODY_MARGIN;
-    }
-
-    setTimeout(UpdateFrameSize, IFRAME_SIZE_UPDATE_INTERVAL);
-  }
-  UpdateFrameSize();
+  gExpectFailures = (gTestPath in GetExpectedTestFailSet());
 
   // Load the iframe.
   statusElem.innerHTML = 'Loading';
 
-  frameElem.onloadstart = function() {
-    statusElem.innerHTML = 'Running';
+  gIsComplete = false;
+  frameElem.onload = function() {
+    if (!gIsComplete)
+      statusElem.innerHTML = 'Running';
   };
-  frameElem.src = testPath;
+  frameElem.src = gTestPath;
 }
 
-var failureCount = 0;
-var resultCount = 0;
+var gFailureCount = 0;
+var gResultCount = 0;
 window.webglTestHarness = {
   reportResults: function(success, message) {
-    resultCount++;
-    if (!success) {
-      failureCount++;
+    if (gExpectFailures) {
+      if (success) {
+        ok(success, message);
+      } else {
+        todo(success, message);
+      }
+    } else {
+      ok(success, message);
     }
 
-    var color = failureCount ? 'red' : 'green';
+    gResultCount++;
+    if (!success) {
+      gFailureCount++;
+    }
+
+    var color = gFailureCount ? 'red' : 'green';
 
     resultsElem.innerHTML = [
-      '<font color="' + color + '">',
-      '' + failureCount + '/' + resultCount,
+      '<font color=\'' + color + '\'>',
+      '' + gFailureCount + '/' + gResultCount,
       '</font>',
     ].join('\n');
   },
 
   notifyFinished: function(testPath) {
     OnTestComplete();
   },
 };
 
 function OnTestComplete() {
   statusElem.innerHTML = 'Complete';
+  gIsComplete = true;
 
-  var passed = failureCount == 0;
+  var hadFailures = gFailureCount != 0;
 
-  var passExpected = true;
-  if (gTestPath in GetExpectedTestFailSet())
-    passExpected = false;
-
-  var expectedStatus = passExpected ? 'pass' : 'fail';
-  var text = 'Should ' + expectedStatus + ': ' + gTestPath;
-
-  ok(passed == passExpected, text);
+  if (gExpectFailures) {
+    todo(!hadFailures, 'Expected failures: ' + gTestPath);
+  } else {
+    ok(!hadFailures, 'Expected no failures: ' + gTestPath);
+  }
   SimpleTest.finish();
 }
 
 ////////////////////////////////////////////////////////////////////////
 // Begin execution
 
 SimpleTest.waitForExplicitFinish();
 
deleted file mode 100644
--- a/dom/canvas/test/webgl-conformance/mochi-wrapper.css
+++ /dev/null
@@ -1,8 +0,0 @@
-iframe {
-  position:fixed;
-  top:0px; left:0px; bottom:0px; right:0px;
-  width:100%; height:100%;
-  border:none; margin:0; padding:0;
-  overflow:hidden;
-  z-index:999999;
-}
--- a/dom/canvas/test/webgl-conformance/mochi-wrapper.html.template
+++ b/dom/canvas/test/webgl-conformance/mochi-wrapper.html.template
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?%%TEST_PATH%%'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?%%TEST_PATH%%'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/mochitest.ini.template
+++ b/dom/canvas/test/webgl-conformance/mochitest.ini.template
@@ -1,10 +1,8 @@
 %%HEADER%%
 
 [DEFAULT]
 %%DEFAULT_ERRATA%%
 
-support-files = webgl-conformance/mochi-single.html
-                webgl-conformance/mochi-wrapper.css
-                %%SUPPORT_FILES%%
+support-files = %%SUPPORT_FILES%%
 
 %%MANIFEST_TESTS%%