OLD | NEW |
1 /* | 1 /* |
2 * THIS FILE INTENTIONALLY LEFT BLANK | 2 * THIS FILE INTENTIONALLY LEFT BLANK |
3 * | 3 * |
4 * More specifically, this file is intended for vendors to implement | 4 * More specifically, this file is intended for vendors to implement |
5 * code needed to integrate testharness.js tests with their own test systems. | 5 * code needed to integrate testharness.js tests with their own test systems. |
6 * | 6 * |
7 * Typically such integration will attach callbacks when each test is | 7 * Typically such integration will attach callbacks when each test is |
8 * has run, using add_result_callback(callback(test)), or when the whole test fi
le has | 8 * has run, using add_result_callback(callback(test)), or when the whole test fi
le has |
9 * completed, using add_completion_callback(callback(tests, harness_status)). | 9 * completed, using add_completion_callback(callback(tests, harness_status)). |
10 * | 10 * |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 /* Using a callback function, test results will be added to the page in a | 41 /* Using a callback function, test results will be added to the page in a |
42 * manner that allows dumpAsText to produce readable test results | 42 * manner that allows dumpAsText to produce readable test results |
43 */ | 43 */ |
44 add_completion_callback(function (tests, harness_status){ | 44 add_completion_callback(function (tests, harness_status){ |
45 | 45 |
46 // Create element to hold results | 46 // Create element to hold results |
47 var results = document.createElement("pre"); | 47 var results = document.createElement("pre"); |
48 | 48 |
49 // Declare result string | 49 // Declare result string |
50 var resultStr = "\n"; | 50 var resultStr = "This is a testharness.js-based test.\n"; |
51 | 51 |
52 // Check harness_status. If it is not 0, tests did not | 52 // Check harness_status. If it is not 0, tests did not |
53 // execute correctly, output the error code and message | 53 // execute correctly, output the error code and message |
54 if(harness_status.status != 0){ | 54 if(harness_status.status != 0){ |
55 resultStr += "Harness Error. harness_status.status = " + | 55 resultStr += "Harness Error. harness_status.status = " + |
56 harness_status.status + | 56 harness_status.status + |
57 " , harness_status.message = " + | 57 " , harness_status.message = " + |
58 harness_status.message; | 58 harness_status.message; |
59 } | 59 } |
60 else { | 60 else { |
61 // Iterate through tests array and build string that contains | 61 // Iterate through tests array and build string that contains |
62 // results for all tests | 62 // results for all tests |
63 for(var i=0; i<tests.length; i++){ | 63 for(var i=0; i<tests.length; i++){ |
64 resultStr += convertResult(tests[i].status) + " " + | 64 resultStr += convertResult(tests[i].status) + " " + |
65 ( (tests[i].name!=null) ? tests[i].name : "" ) + " " + | 65 ( (tests[i].name!=null) ? tests[i].name : "" ) + " " + |
66 ( (tests[i].message!=null) ? tests[i].message : "" ) + | 66 ( (tests[i].message!=null) ? tests[i].message : "" ) + |
67 "\n"; | 67 "\n"; |
68 } | 68 } |
69 } | 69 } |
| 70 resultStr += "Harness: the test ran to completion.\n"; |
70 | 71 |
71 // Set results element's innerHTML to the results string | 72 // Set results element's textContent to the results string |
72 results.innerHTML = resultStr; | 73 results.textContent = resultStr; |
73 | 74 |
74 // Add results element to document | 75 // Add results element to document |
75 document.body.appendChild(results); | 76 document.body.appendChild(results); |
76 | 77 |
77 if (self.testRunner) | 78 if (self.testRunner) |
78 testRunner.notifyDone(); | 79 testRunner.notifyDone(); |
79 }); | 80 }); |
OLD | NEW |