2006-09-17 Eric Seidel <eric@eseidel.com>
[WebKit-https.git] / LayoutTests / fast / js / window-properties.html
1 <div id="log"></div>
2 <script type="text/javascript">
3
4 if (window.layoutTestController)
5   layoutTestController.dumpAsText();
6
7 var logDiv = document.getElementById("log");
8 var lastLogLine = 0;
9
10 function log(string) {
11   var newDiv = document.createElement('DIV');
12   newDiv.appendChild(document.createTextNode(string));
13   logDiv.appendChild(newDiv);
14   lastLogLine++;
15 }
16
17 function shouldSkipProperty(fullPropertyName, propertyValue) {
18   if (fullPropertyName.match(/_childrenPrintedUnderName$/))
19     return true;
20 }
21
22 function shouldSkipChildren(fullPropertyName, propertyValue) {
23   if (propertyValue == logDiv
24     || fullPropertyName == 'window.document.body.lastChild')
25     return true;
26 }
27
28 function havePrintedChildren(fullPropertyName, propertyValue) {
29   var childrenPrintedUnderName = propertyValue._childrenPrintedUnderName;
30   if (!childrenPrintedUnderName)
31     propertyValue._childrenPrintedUnderName = fullPropertyName;
32   return childrenPrintedUnderName;
33 }
34
35 function printProperties(object, parentString) {
36   for (propertyName in object) {
37     var fullPropertyName = parentString + '.' + propertyName;
38     var propertyValue = object[propertyName];
39     if (shouldSkipProperty(fullPropertyName, propertyValue))
40       continue;
41     var type = typeof(propertyValue);
42     log(fullPropertyName + " : " + type);
43     var previousPropertyName = '';
44     if (propertyValue && type == 'object') {
45       if (shouldSkipChildren(fullPropertyName, propertyValue))
46         log(fullPropertyName + ' *** children skipped (explicitly)');
47       else if (previousPropertyName = havePrintedChildren(fullPropertyName, propertyValue))
48         log(fullPropertyName + " *** children skipped, already printed above under '" + previousPropertyName + "'");
49       else
50         printProperties(propertyValue, fullPropertyName);
51     }
52   }
53 }
54
55 log('window : ' + typeof(window));
56 havePrintedChildren(window, 'window');
57 printProperties(window, 'window');
58
59 </script>