summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webgl/tools/js-test-pre.patch
blob: 1e8a4c9581d6ca426172e50b4464336e017b2b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
--- js-test-pre.orig.js	2016-04-08 22:35:15.629226767 +0200
+++ js-test-pre.js	2016-04-08 22:43:11.906092062 +0200
@@ -71,11 +71,25 @@
   }
 }
 
-function reportTestResultsToHarness(success, msg) {
-  if (window.parent.webglTestHarness) {
-    window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
+(function() {
+  var WPT_TEST_ID = 0;
+
+  // Store the current WPT test harness `test` function
+  // if found, since it's overriden by some tests.
+  var wpt_test = window.test;
+  var wpt_assert_true = window.assert_true;
+
+
+  window.reportTestResultsToHarness = function reportTestResultsToHarness(success, msg) {
+    if (window.parent.webglTestHarness) {
+      window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
+    } else if (wpt_test) { // WPT test harness
+      wpt_test(function () {
+        wpt_assert_true(success, msg);
+      }, "WebGL test #" + (WPT_TEST_ID++) + ": " + msg);
+    }
   }
-}
+}())
 
 function notifyFinishedToHarness() {
   if (window.parent.webglTestHarness) {
@@ -92,7 +106,7 @@
       window.console.log(msg);
 }
 
-var _jsTestPreVerboseLogging = false;
+var _jsTestPreVerboseLogging = true;
 
 function enableJSTestPreVerboseLogging()
 {
@@ -105,31 +119,18 @@
     if (msg === undefined) {
       msg = document.title;
     }
-    // For MSIE 6 compatibility
-    var span = document.createElement("span");
-    span.innerHTML = '<p>' + msg + '</p><p>On success, you will see a series of "<span class="pass">PASS</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
-    var description = document.getElementById("description");
-    if (description.firstChild)
-        description.replaceChild(span, description.firstChild);
-    else
-        description.appendChild(span);
-    if (_jsTestPreVerboseLogging) {
-        _logToConsole(msg);
-    }
+    _logToConsole("DESCRIPTION: " + msg);
 }
 
 function _addSpan(contents)
 {
-    var span = document.createElement("span");
-    document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace
-    span.innerHTML = contents + '<br />';
 }
 
 function debug(msg)
 {
     _addSpan(msg);
     if (_jsTestPreVerboseLogging) {
-	_logToConsole(msg);
+        _logToConsole(msg);
     }
 }
 
@@ -143,7 +144,7 @@
     reportTestResultsToHarness(true, msg);
     _addSpan('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
     if (_jsTestPreVerboseLogging) {
-	_logToConsole('PASS ' + msg);
+        _logToConsole('PASS ' + msg);
     }
 }