| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="heap-snapshot-test.js"></script> |
| <script> |
| |
| function handleLoad() |
| { |
| // Make sure there is a body wrapper. |
| document.body.fieldOnDomWrapper = 2012; |
| runTest(); |
| } |
| |
| function test() |
| { |
| WebInspector.showPanel("profiles"); |
| ProfilerAgent.takeHeapSnapshot(step0); |
| |
| function step0() |
| { |
| var profiles = WebInspector.panels.profiles.getProfiles("HEAP"); |
| WebInspector.panels.profiles.showProfile(profiles[profiles.length - 1]); |
| InspectorTest.addSniffer(WebInspector.panels.profiles, "_finishHeapSnapshot", step1); |
| } |
| |
| function step1(uid) |
| { |
| InspectorTest.addResult("_finishHeapSnapshot " + uid); |
| var panel = WebInspector.panels.profiles; |
| var profile = panel._profilesIdMap[panel._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)]; |
| profile.load(step2.bind(this)); |
| } |
| |
| function step2(snapshotProxy) |
| { |
| InspectorTest.addResult("_callLoadCallbacks"); |
| var snapshot = snapshotProxy._worker._worker._dispatcher._objects[snapshotProxy._objectId]; |
| |
| var bodyWrapperIds = []; |
| for (var it = snapshot._allNodes; it.hasNext(); it.next()) { |
| if (it.node.className === "HTMLBodyElement") |
| bodyWrapperIds.push(it.node.id); |
| } |
| for (var i = 0; i < bodyWrapperIds.length; i++) |
| ProfilerAgent.getObjectByHeapObjectId(bodyWrapperIds[i], undefined, didGetObjectByHeapObjectId); |
| |
| var resolvedObjectsCount = 0; |
| var remoteObjects = []; |
| function didGetObjectByHeapObjectId(error, object) |
| { |
| if (error) |
| InspectorTest.addResult("Error resolving heap snapshot object: " + error); |
| else |
| remoteObjects.push(WebInspector.RemoteObject.fromPayload(object)); |
| |
| if (++resolvedObjectsCount === bodyWrapperIds.length) |
| requestPropertiesOfResolvedObjects(); |
| } |
| |
| function requestPropertiesOfResolvedObjects() |
| { |
| for (var i = 0; i < remoteObjects.length; i++) |
| remoteObjects[i].getOwnProperties(didGetOwnProperties); |
| } |
| |
| var didGetOwnPropertiesCount = 0; |
| function didGetOwnProperties() |
| { |
| if (++didGetOwnPropertiesCount !== remoteObjects.length) |
| return; |
| |
| ProfilerAgent.clearProfiles(done); |
| WebInspector.panels.profiles._reset(); |
| } |
| } |
| |
| function done() |
| { |
| InspectorTest.addResult("clearProfiles"); |
| InspectorTest.completeTest(); |
| } |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="handleLoad()"> |
| <p> |
| Test that resolving heap snaphot object to a JS object will not crash on DOM wrapper boilerplate. Test passes if it doesn't crash. |
| </p> |
| |
| </body> |
| </html> |