| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../inspector/inspector-test.js"></script> | |
| 4 <script> | |
| 5 | |
| 6 function onload() | |
| 7 { | |
| 8 testRunner.showWebInspector(JSON.stringify({experiments: "{\"workersInMainWi
ndow\":true}"})); | |
| 9 runTest(); | |
| 10 } | |
| 11 | |
| 12 function startWorker() | |
| 13 { | |
| 14 new Worker("resources/dedicated-worker.js?id=1"); | |
| 15 } | |
| 16 | |
| 17 function test() | |
| 18 { | |
| 19 InspectorBackendClass.Options.suppressRequestErrors = true; | |
| 20 var targetObservation; | |
| 21 var targetObserver = { | |
| 22 | |
| 23 targetAdded: function(target) | |
| 24 { | |
| 25 if (!target.isWorkerTarget()) | |
| 26 return; | |
| 27 | |
| 28 InspectorTest.addResult("Worker target added"); | |
| 29 targetObservation = internals.observeGC(target); | |
| 30 setTimeout(runAfterPendingDispatches.bind(null, target), 0); | |
| 31 }, | |
| 32 | |
| 33 targetRemoved: function(target) | |
| 34 { | |
| 35 | |
| 36 }, | |
| 37 } | |
| 38 | |
| 39 function runAfterPendingDispatches(target) | |
| 40 { | |
| 41 WebInspector.targetManager.removeTarget(target); | |
| 42 target._connection._close(); | |
| 43 target = null; | |
| 44 WebInspector.workerTargetManager._workerTargetById = {}; | |
| 45 setTimeout(finish, 0); | |
| 46 } | |
| 47 | |
| 48 function finish() | |
| 49 { | |
| 50 gc(); | |
| 51 InspectorTest.addResult("Worker target was collected: " + targetObservat
ion.wasCollected); | |
| 52 InspectorTest.completeTest(); | |
| 53 } | |
| 54 | |
| 55 var panels = Object.keys(WebInspector.inspectorView._panelDescriptors); | |
| 56 for (var i = 0; i < panels.length; ++i) { | |
| 57 WebInspector.inspectorView.showPanel(panels[i]); | |
| 58 } | |
| 59 InspectorTest.evaluateInPage("startWorker();"); | |
| 60 WebInspector.targetManager.observeTargets(targetObserver); | |
| 61 } | |
| 62 | |
| 63 </script> | |
| 64 </head> | |
| 65 | |
| 66 <body onload="onload()"> | |
| 67 <p>This test that target doesn't leak when it is removed</p> | |
| 68 </body> | |
| 69 </html> | |
| 70 | |
| OLD | NEW |