[Chromium] Unreviewed, mark fast/regions tests failing after r136045 as failing,...
[WebKit-https.git] / LayoutTests / inspector-protocol / nmi-webaudio-leak-test.html
1 <html>
2 <head>
3 <script src="../http/tests/inspector-protocol/resources/protocol-test.js"></script>
4 <script>
5
6 function runTestOnlyOnce()
7 {
8     if (window.testFirstRun)
9         return;
10     window.testFirstRun = 1;
11
12     runTest();
13 }
14
15 function navigateIFrame()
16 {
17     var iframe = document.getElementById("iframe");
18     iframe.src = "resources/blank.html";
19 }
20
21 function test()
22 {
23     function sizeForType(entry, typeNames)
24     {
25         for (var index = 0; index < typeNames.length; ++index) {
26             var typeName = typeNames[index];
27             var found = 0;
28             for (var i = 0; i < entry.children.length; ++i) {
29                 var childEntry = entry.children[i];
30                 if (childEntry.name === typeName) {
31                     if (index === typeNames.length - 1)
32                         return childEntry.size;
33
34                     if (!childEntry.children)
35                         return -1;
36
37                     entry = childEntry;
38                     found = 1;
39                     break;
40                 }
41             }
42             if (!found)
43                 return -1;
44         }
45
46         return -1;
47     }
48
49     var pivotSize = 15000000;
50
51     function noAudioSharedData(messageObject)
52     {
53         var size = sizeForType(messageObject["result"]["distribution"], ["Page", "Audio"]);
54         if (size === -1)
55             InspectorTest.log("PASS: No Page.Audio data found");
56         else
57             InspectorTest.log("FAIL: " + size + " bytes of Page.Audio data was found");
58         InspectorTest.completeTest();
59     }
60
61     function iFrameNavigated(messageObject) {
62         InspectorTest.log("PASS: IFrame was navigated to resources/blank.html");
63         InspectorTest.sendCommand('Profiler.collectGarbage', {}, function() { } );
64         InspectorTest.log("Action: Run GC and check Page.Audio data size");
65         InspectorTest.sendCommand('Memory.getProcessMemoryDistribution', {}, noAudioSharedData);
66     }
67
68     function waitForSharedAudioData(messageObject) {
69         var size = sizeForType(messageObject["result"]["distribution"], ["Page", "Audio"]);
70         if (size === -1) {
71             InspectorTest.log("FAIL: No Page.Audio data was found.");
72             InspectorTest.completeTest();
73             return;
74         }
75         if (size < pivotSize)
76             InspectorTest.sendCommand('Memory.getProcessMemoryDistribution', {}, waitForSharedAudioData);
77         else {
78             InspectorTest.log("PASS: Memory size for Page.Audio more than " + pivotSize);
79
80             InspectorTest.sendCommand('Page.enable', {}, function() { } );
81
82             InspectorTest.log("Action: Navigate IFrame to resources/blank.html");
83             InspectorTest.eventHandler["Page.frameNavigated"] = iFrameNavigated;
84             InspectorTest.sendCommand('Runtime.evaluate', {expression: 'navigateIFrame()'}, function() { } );
85         }
86     }
87
88     InspectorTest.log("");
89     InspectorTest.log("Action: Wait for Page.Audio data");
90     InspectorTest.sendCommand('Memory.getProcessMemoryDistribution', {}, waitForSharedAudioData);
91 }
92 </script>
93 </head>
94 <body onload="testRunner.waitUntilDone()">
95 This test is checking that AudioContext is deleting after navigation.
96 It is not possible to count AudioContext objects directly.
97 But we could use Native Memory Snapshot which has information about Page.Audio.SharedData.
98 All the shared data are retained by HRTFDatabaseLoader refcounted singleton
99 and Native Memory Instrumentation is visiting it via public getter.
100
101 <iframe id="iframe" onLoad="runTestOnlyOnce()" src="resources/audio-context.html" >
102 </iframe>
103
104 </body>
105 </html>