Debian Codegraph @

dojox/grid/tests/enhanced/test_enhanced_grid_leak_programmatic.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <title>dojox.grid.EnhancedGrid Leak Test Programmatic</title>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
7 <link rel=stylesheet href="support/common.css"/>
8 <style type="text/css">
9 body {
10 font-size: 0.9em;
11 font-family: Geneva, Arial, Helvetica, sans-serif;
12 padding: 0.5em;
13 }
14 .title {
15 text-align:center;
16 }
17
18 #grid {
19 border: 1px solid #333;
20 width: 85.2em;
21 height: 50em;
22 }
23
24 </style>
25 <script type="text/javascript" src="../../../../dojo/dojo.js"
26 data-dojo-config="isDebug:true, parseOnLoad: true"></script>
27 <script type="text/javascript">
28 dojo.require("dijit.dijit"); // optimize: load dijit layer
29 dojo.require("dojox.grid.EnhancedGrid");
30 dojo.require("dojo.data.ItemFileWriteStore");
31 dojo.require("dojo.parser");
32 dojo.require("dojox.grid.enhanced.plugins.Filter");
33 dojo.require("dojox.grid.enhanced.plugins.exporter.CSVWriter");
34 dojo.require("dojox.grid.enhanced.plugins.Printer");
35 dojo.require("dojox.grid.enhanced.plugins.Cookie");
36 dojo.require("dojox.grid.enhanced.plugins.IndirectSelection");
37 dojo.require("dojox.grid.enhanced.plugins.NestedSorting");
38 dojo.require("dojox.grid.enhanced.plugins.Selector");
39 dojo.require("dojox.grid.enhanced.plugins.Menu");
40 dojo.require("dojox.grid.enhanced.plugins.DnD");
41 dojo.require("dojox.grid.enhanced.plugins.Search");
42 dojo.require("dojox.grid.enhanced.plugins.CellMerge");
43 dojo.require("dojox.grid.enhanced.plugins.Pagination");
44 dojo.require('doh.runner');
45 </script>
46 <script type="text/javascript" src="../support/test_data.js"></script>
47 <script type="text/javascript">
48 var grid = null,
49 connecter = [];
50 var gridArgs = {
51 };
52 var plugins = {
53 "nestedSorting": {},
54 "indirectSelection": {
55 headerSelector: true,
56 name: "Selection",
57 width:"70px",
58 styles:"text-align: center;"
59 },
60 "menus": {
61 },
62 "exporter": {},
63 "printer": {},
64 "filter": {
65 closeFilterbarButton: true,
66 ruleCount: 0
67 },
68 "cookie": {},
69 "selector": {
70 },
71 "dnd": {
72 copyOnly: false
73 },
74 "cellMerge": {
75 "mergedCells": [
76 {row: "3", start: 1, end: 10, major: 3}
77 ]
78 },
79 "search": {},
80 "pagination":
81 {
82 pageSizes: ["5", "10", "20", "50", "All"], // Array, custom the items per page button
83 // itemTitle: "entrys", // String, custom the item' title of description
84 description: true, // boolean, custom weather or not the discription will be displayed
85 sizeSwitch: true, // boolean, custom weather or not the page size switch will be displayed
86 pageStepper: true, // boolean, custom weather or not the page step will be displayed
87 gotoButton: true,
88 maxPageStep: 10, // Integer, custom how many page step will be displayed
89 position: "bottom" // String, custom the position of the paginator bar
90 // there're three options: top, bottom, both
91 // ,descTemplate: "${1} ${0}" // A template of the current position description.
92 }
93 };
94
95 var layout = [[
96 {name: 'Column 1', field: 'col1'},
97 {name: 'Column 2', field: 'col2'},
98 {name: 'Column 3', field: 'col3'},
99 {name: 'Column 4', field: 'col4', width: "150px"},
100 {name: 'Column 5', field: 'col5'},
101 {name: 'Column 6', field: 'col6'},
102 {name: 'Column 7', field: 'col7'},
103 {name: 'Column 8', field: 'col5'}
104 ]];
105
106 dojo.addOnLoad(function() {
107 dojo.connect(dojo._listener, "add", function(obj, event, context, method){
108 connecter.push([obj, event, context, method]); // Handle
109 });
110 });
111
112 function toggleGrid() {
113 if (grid){
114 grid.destroy();
115 grid = null;
116
117 doh.register("leak_programmatic", [
118 {
119 name: 'widget_destroy',
120 runTest: function(t){
121 for(var name in dijit.registry._hash){
122 t.assertEqual(dijit.registry._hash[name], undefined);
123 }
124 }
125 },
126 {
127 name: "connecter_destroy",
128 runTest: function(t){
129 dojo.forEach(connecter, function(conn){
130 var f = (conn[0] || dojo.global)[conn[1]];
131 if(f && f._listeners){
132 dojo.forEach(f._listeners, function(l){
133 t.assertEqual(l, undefined);
134 });
135 }
136 });
137 }
138 },
139 {
140 name: "topics_destroy",
141 runTest: function(t){
142
143 for(var name in dojo._topics){
144 if(name === "dijit.Editor.getPlugin"){continue;}
145 var topic = dojo._topics[name];
146 dojo.forEach(topic._listeners, function(l){
147 t.assertEqual(l, undefined);
148 });
149 }
150 }
151 }
152 ]);
153
154 doh.run();
155 }
156 else {
157 grid = new dojox.grid.EnhancedGrid(dojo.mixin({
158 id: "grid",
159 store: test_store,
160 structure: layout,
161 plugins : plugins
162 }, gridArgs));
163
164 dojo.byId("gridContainer").appendChild(grid.domNode);
165 grid.startup();
166 }
167 }
168
169 function leakTest(){
170 toggleGrid();
171 }
172 </script>
173 </head>
174 <body class="claro">
175 <div class="heading">dojox.grid.EnhancedGrid Leak Test Programmatic</div>
176 <div>
177 <p>Please follow below two steps and see the doh test output in console: ( TEST SUMMARY )</p>
178 <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1> click "Toggle Grid Programmatic" button, wait until grid created.</p>
179 <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2> click "Toggle Grid Programmatic" button again to destroy Grid,
180 all event connections, topics, and checkbox widgets should be destroyed, please check with debugging console, if there are no failures, means no leak. If there are one or more failures, means leak exist.</p>
181 </div>
182 <button id="leakTest" onClick="leakTest();">Toggle Grid Programmatic</button>
183 <div id="gridContainer"></div>
184 </body>
185 </html>