| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // A quick and dirty JavaScript test runner. | |
| 6 | |
| 7 function assert(truth) { | |
| 8 if (!truth) { | |
| 9 throw new Error('Assertion failed'); | |
| 10 } | |
| 11 } | |
| 12 | |
| 13 function runAllTests() { | |
| 14 // If there was already an error, do nothing. We don't want to muddy | |
| 15 // up the results. | |
| 16 if (document.title.indexOf("Error: ") == 0) { | |
| 17 return; | |
| 18 } | |
| 19 | |
| 20 for (var propName in window) { | |
| 21 if (typeof window[propName] == "function" && | |
| 22 propName.indexOf("test") == 0) { | |
| 23 try { | |
| 24 window[propName](); | |
| 25 document.title += propName + ","; | |
| 26 } catch (e) { | |
| 27 // We use document.title to communicate results back to the browser. | |
| 28 document.title = "Error: " + propName + ': ' + e.message; | |
| 29 return; | |
| 30 } | |
| 31 } | |
| 32 } | |
| 33 } | |
| OLD | NEW |