Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / profiler / heap-snapshot-loader.html
blob6e139f234c41daa23d94d2451281459c2b30ada5
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="heap-snapshot-test.js"></script>
5 <script>
7 function test()
9 var source = InspectorTest.createHeapSnapshotMockRaw();
10 var sourceStringified = JSON.stringify(source);
11 var partSize = sourceStringified.length >> 3;
13 function injectMockProfile(callback) {
14 var dispatcher = InspectorBackend._connection._dispatchers["HeapProfiler"]._dispatcher;
15 var panel = WebInspector.panels.profiles;
16 panel._reset();
18 var profileType = WebInspector.ProfileTypeRegistry.instance.heapSnapshotProfileType;
20 InspectorTest.override(InspectorTest.HeapProfilerAgent, "takeHeapSnapshot", takeHeapSnapshotMock);
21 function takeHeapSnapshotMock(reportProgress, callback) {
22 if (reportProgress) {
23 profileType._reportHeapSnapshotProgress({data: {done: 50, total: 100, finished: false}});
24 profileType._reportHeapSnapshotProgress({data: {done: 100, total: 100, finished: true}});
26 for (var i = 0, l = sourceStringified.length; i < l; i += partSize)
27 dispatcher.addHeapSnapshotChunk(sourceStringified.slice(i, i + partSize));
28 setTimeout(callback, 0);
31 function tempFileReady()
33 callback(this);
35 InspectorTest.addSniffer(WebInspector.HeapProfileHeader.prototype, "_didWriteToTempFile", tempFileReady);
36 profileType._takeHeapSnapshot(function() {});
39 WebInspector.console.log = function(message) {
40 InspectorTest.addResult("InspectorTest.consoleModel.log: " + message);
43 InspectorTest.runTestSuite([
44 function heapSnapshotSaveToFileTest(next)
46 function snapshotLoaded(profileHeader)
48 var savedSnapshotData;
49 function saveMock(url, data)
51 savedSnapshotData = data;
52 WebInspector.fileManager._savedURL({data: url});
54 InspectorTest.override(InspectorFrontendHost, "save", saveMock);
56 var oldAppend = InspectorFrontendHost.append;
57 InspectorFrontendHost.append = function appendMock(url, data)
59 savedSnapshotData += data;
60 WebInspector.fileManager._appendedToURL({data: url});
62 function closeMock(url)
64 InspectorTest.assertEquals(sourceStringified, savedSnapshotData, "Saved snapshot data");
65 InspectorFrontendHost.append = oldAppend;
66 next();
68 InspectorTest.override(WebInspector.FileManager.prototype, "close", closeMock);
69 profileHeader.saveToFile();
72 injectMockProfile(snapshotLoaded);
75 function heapSnapshotLoadFromFileTest(next)
77 var panel = WebInspector.panels.profiles;
79 var fileMock = {
80 name: "mock.heapsnapshot",
81 size: sourceStringified.length
84 InspectorTest.override(WebInspector.HeapProfileHeader.prototype, '_createFileReader', function(fileMock, delegate) {
85 return {
86 start: function(receiver) {
87 delegate.onTransferStarted(this);
88 receiver.write(sourceStringified);
89 delegate.onChunkTransferred(this);
90 receiver.close();
91 delegate.onTransferFinished(this);
94 loadedSize: function()
96 return fileMock.size;
99 fileSize: function()
101 return fileMock.size;
104 fileName: function()
106 return fileMock.name;
110 InspectorTest.addSniffer(WebInspector.HeapProfileHeader.prototype, "_snapshotReceived", function() { next(); });
111 panel._loadFromFile(fileMock);
114 function heapSnapshotRejectToSaveToFileTest(next)
116 function snapshotLoaded(profileHeader)
118 if (profileHeader.canSaveToFile())
119 next();
120 else
121 profileHeader.addEventListener(WebInspector.ProfileHeader.Events.ProfileReceived, onCanSaveProfile, this);
122 function onCanSaveProfile()
124 InspectorTest.assertTrue(profileHeader.canSaveToFile());
125 next();
129 injectMockProfile(snapshotLoaded);
134 </script>
135 </head>
137 <body onload="runTest()">
139 This test checks HeapSnapshots loader.
140 </p>
142 </body>
143 </html>