| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 function test() | 6 function test() |
| 7 { | 7 { |
| 8 var ProcessMock = function(name, runnable) | 8 var ProcessMock = function(name, runnable) |
| 9 { | 9 { |
| 10 this._runnable = runnable; | 10 this._runnable = runnable; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 this.startPromise.then(onFinish.bind(this)); | 46 this.startPromise.then(onFinish.bind(this)); |
| 47 | 47 |
| 48 function onFinish() | 48 function onFinish() |
| 49 { | 49 { |
| 50 InspectorTest.addResult("Process '" + this.processName + "' FINI
SHED."); | 50 InspectorTest.addResult("Process '" + this.processName + "' FINI
SHED."); |
| 51 this._finishCallback(); | 51 this._finishCallback(); |
| 52 } | 52 } |
| 53 }, | 53 }, |
| 54 } | 54 } |
| 55 | 55 |
| 56 var throttler = new WebInspector.Throttler(1989); | 56 var throttler = new Common.Throttler(1989); |
| 57 var timeoutMock = new InspectorTest.TimeoutMock(); | 57 var timeoutMock = new InspectorTest.TimeoutMock(); |
| 58 throttler._setTimeout = timeoutMock.setTimeout; | 58 throttler._setTimeout = timeoutMock.setTimeout; |
| 59 throttler._clearTimeout = timeoutMock.clearTimeout; | 59 throttler._clearTimeout = timeoutMock.clearTimeout; |
| 60 InspectorTest.addSniffer(throttler, "schedule", logSchedule, true); | 60 InspectorTest.addSniffer(throttler, "schedule", logSchedule, true); |
| 61 | 61 |
| 62 function testSimpleSchedule(next, runningProcess) | 62 function testSimpleSchedule(next, runningProcess) |
| 63 { | 63 { |
| 64 assertThrottlerIdle(); | 64 assertThrottlerIdle(); |
| 65 throttler.schedule(ProcessMock.create("operation #1").run, false); | 65 throttler.schedule(ProcessMock.create("operation #1").run, false); |
| 66 var process = ProcessMock.create("operation #2"); | 66 var process = ProcessMock.create("operation #2"); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 { | 190 { |
| 191 throw new Error("Exception during process execution."); | 191 throw new Error("Exception during process execution."); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 ]); | 194 ]); |
| 195 | 195 |
| 196 function waitForProcessFinish() | 196 function waitForProcessFinish() |
| 197 { | 197 { |
| 198 var promiseResolve; | 198 var promiseResolve; |
| 199 var hasFinished; | 199 var hasFinished; |
| 200 InspectorTest.addSniffer(WebInspector.Throttler.prototype, "_processComp
letedForTests", onFinished); | 200 InspectorTest.addSniffer(Common.Throttler.prototype, "_processCompletedF
orTests", onFinished); |
| 201 function onFinished() | 201 function onFinished() |
| 202 { | 202 { |
| 203 hasFinished = true; | 203 hasFinished = true; |
| 204 if (promiseResolve) | 204 if (promiseResolve) |
| 205 promiseResolve(); | 205 promiseResolve(); |
| 206 } | 206 } |
| 207 return new Promise(function(success) { | 207 return new Promise(function(success) { |
| 208 promiseResolve = success; | 208 promiseResolve = success; |
| 209 if (hasFinished) | 209 if (hasFinished) |
| 210 success(); | 210 success(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 </script> | 252 </script> |
| 253 </head> | 253 </head> |
| 254 | 254 |
| 255 <body onload="runTest()"> | 255 <body onload="runTest()"> |
| 256 <p>This test verifies throttler behavior.</p> | 256 <p>This test verifies throttler behavior.</p> |
| 257 </body> | 257 </body> |
| 258 </html> | 258 </html> |
| OLD | NEW |