3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"heap-snapshot-test.js"></script>
9 // Make sure there is a body wrapper.
10 document
.body
.fieldOnDomWrapper
= 2012;
16 var heapProfileType
= WebInspector
.ProfileTypeRegistry
.instance
.heapSnapshotProfileType
;
17 heapProfileType
.addEventListener(WebInspector
.HeapSnapshotProfileType
.SnapshotReceived
, finishHeapSnapshot
);
18 InspectorTest
.addSniffer(heapProfileType
, "_snapshotReceived", snapshotReceived
);
19 heapProfileType
._takeHeapSnapshot(function() {});
21 function finishHeapSnapshot(uid
)
23 InspectorTest
.addResult("PASS: snapshot was taken");
24 var profiles
= heapProfileType
.getProfiles();
27 return clear("FAILED: no profiles found");
29 if (profiles
.length
> 1)
30 return clear("FAILED: wrong number of recorded profiles was found. profiles.length = " + profiles
.length
);
32 var profile
= profiles
[profiles
.length
- 1];
33 WebInspector
.panels
.profiles
.showProfile(profile
);
36 function snapshotReceived(profile
)
38 InspectorTest
.addResult("PASS: snapshot was received");
39 var snapshotProxy
= profile
._snapshotProxy
;
40 snapshotProxy
.callMethod(didGetBodyWrapperIds
, "idsOfObjectsWithName", "HTMLBodyElement");
43 function didGetBodyWrapperIds(bodyWrapperIds
)
45 if (bodyWrapperIds
.length
< 3)
46 return clear("FAILED: less than 3 HTMLBodyElement objects were detected");
48 InspectorTest
.addResult("PASS: more than 2 HTMLBodyElements were found");
50 for (var i
= 0; i
< bodyWrapperIds
.length
; i
++)
51 InspectorTest
.HeapProfilerAgent
.getObjectByHeapObjectId("" + bodyWrapperIds
[i
], undefined, didGetObjectByHeapObjectId
);
53 var resolvedObjectsCount
= 0;
54 var remoteObjects
= [];
55 function didGetObjectByHeapObjectId(error
, object
)
58 remoteObjects
.push(InspectorTest
.runtimeModel
.createRemoteObject(object
));
60 if (++resolvedObjectsCount
=== bodyWrapperIds
.length
)
61 requestPropertiesOfResolvedObjects();
64 function requestPropertiesOfResolvedObjects()
66 if (!remoteObjects
.length
)
67 return clear("FAILED: no resolved objects were detected");
69 InspectorTest
.addResult("PASS: got at least one HTMLBodyElement wrapper");
71 for (var i
= 0; i
< remoteObjects
.length
; i
++)
72 remoteObjects
[i
].getOwnProperties(didGetOwnProperties
);
75 var didGetOwnPropertiesCount
= 0;
76 function didGetOwnProperties()
78 if (++didGetOwnPropertiesCount
!== remoteObjects
.length
)
86 function clear(errorMessage
)
89 InspectorTest
.addResult(errorMessage
);
91 WebInspector
.panels
.profiles
._reset();
97 InspectorTest
.addResult("PASS: profile was deleted");
98 InspectorTest
.completeTest();
105 <body onload=
"handleLoad()">
107 Test that resolving heap snaphot object to a JS object will not crash on DOM wrapper boilerplate. Test passes if it doesn't crash.