OLD | NEW |
1 var UnitTest = {}; | 1 var UnitTest = {}; |
2 (function() | 2 (function() |
3 { | 3 { |
4 var oldLoadResourcePromise = Runtime.loadResourcePromise; | 4 var oldLoadResourcePromise = Runtime.loadResourcePromise; |
5 Runtime.loadResourcePromise = function(url) | 5 Runtime.loadResourcePromise = function(url) |
6 { | 6 { |
7 if (url.startsWith("/")) | 7 if (url.startsWith("/")) |
8 return oldLoadResourcePromise(url); | 8 return oldLoadResourcePromise(url); |
9 | 9 |
10 if (!url.startsWith("http://")) | 10 if (!url.startsWith("http://")) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 UnitTest.addResult = function(text) | 51 UnitTest.addResult = function(text) |
52 { | 52 { |
53 if (window.testRunner) | 53 if (window.testRunner) |
54 results.push(String(text)); | 54 results.push(String(text)); |
55 else | 55 else |
56 console.log(text); | 56 console.log(text); |
57 } | 57 } |
58 | 58 |
| 59 UnitTest.runTests = function(tests) |
| 60 { |
| 61 nextTest(); |
| 62 |
| 63 function nextTest() |
| 64 { |
| 65 var test = tests.shift(); |
| 66 if (!test) { |
| 67 UnitTest.completeTest(); |
| 68 return; |
| 69 } |
| 70 UnitTest.addResult("\ntest: " + test.name); |
| 71 var testPromise = test(); |
| 72 if (!(testPromise instanceof Promise)) |
| 73 testPromise = Promise.resolve(); |
| 74 testPromise.then(nextTest); |
| 75 } |
| 76 } |
| 77 |
59 function completeTestOnError(message, source, lineno, colno, error) | 78 function completeTestOnError(message, source, lineno, colno, error) |
60 { | 79 { |
61 UnitTest.addResult("TEST ENDED IN ERROR: " + error.stack); | 80 UnitTest.addResult("TEST ENDED IN ERROR: " + error.stack); |
62 UnitTest.completeTest(); | 81 UnitTest.completeTest(); |
63 } | 82 } |
64 window.onerror = completeTestOnError; | 83 window.onerror = completeTestOnError; |
65 | 84 |
66 Runtime.startApplication("/inspector-unit/inspector-unit-test").then(runTest
); | 85 Runtime.startApplication("/inspector-unit/inspector-unit-test").then(runTest
); |
67 | 86 |
68 function runTest() | 87 function runTest() |
(...skipping 17 matching lines...) Expand all Loading... |
86 WebInspector.ContextMenu.installHandler(document); | 105 WebInspector.ContextMenu.installHandler(document); |
87 WebInspector.Tooltip.installHandler(document); | 106 WebInspector.Tooltip.installHandler(document); |
88 | 107 |
89 var rootView = new WebInspector.RootView(); | 108 var rootView = new WebInspector.RootView(); |
90 WebInspector.inspectorView.show(rootView.element); | 109 WebInspector.inspectorView.show(rootView.element); |
91 WebInspector.inspectorView.showInitialPanel(); | 110 WebInspector.inspectorView.showInitialPanel(); |
92 rootView.attachToDocument(document); | 111 rootView.attachToDocument(document); |
93 | 112 |
94 test(); | 113 test(); |
95 } | 114 } |
96 })(); | 115 })(); |
OLD | NEW |