blob: e6ee3b5b7654a3b94e3548a6b3c0a09f4d52b755 [file] [log] [blame]
<p>This test dumps all of the properties that are reachable from the window
object, along with their types.</p>
<hr>
<pre id="pre"></pre>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
var logBuffer = [];
function log(s)
{
logBuffer.push(s);
}
var pre = document.getElementById('pre');
function flushLog()
{
var logMessage = logBuffer.join("");
pre.appendChild(document.createTextNode(logMessage));
}
function tryEval(string)
{
try {
return eval(string);
} catch (e) {
return new String("Caught exception: " + e);
}
}
function typeOfNullAware(value)
{
if (typeof value == "object" && value == null) //;
return "null";
return typeof value;
}
function typeStringNullAware(value)
{
var valueType = typeOfNullAware(value);
return valueType == "object"
? Object.prototype.toString.call(value)
: "[" + valueType + "]";
}
var __skip__ = {
"window.__skip__" : 1,
"window.opener" : 1, // Work around DumpRenderTree bug where previous tests add window properties
"window.Components" : 1, // Work around Firefox exception
// Don't log DumpRenderTree injected objects
"window.layoutTestController" : 1, // Work around http://bugs.webkit.org/show_bug.cgi?id=11373
"window.GCController" : 1,
"window.appleScriptController" : 1,
"window.eventSender" : 1,
"window.navigationController" : 1,
"window.objCController" : 1,
"window.objCPlugin" : 1,
"window.objCPluginFunction" : 1,
"window.textInputController" : 1
};
function logValue(valueName)
{
var value = tryEval(valueName);
var valueType = typeOfNullAware(value);
// Don't taint the test with our own variables
if (value == logBuffer || value == pre)
return;
// Don't taint the test with our own properties
if (/__visitedByLogValue__/.test(valueName) || /__nameWhenVisitedByLogValue__/.test(valueName))
return;
if (__skip__[valueName])
return;
// Work around Firefox infinite recursion
if (/\.[0-9]/.test(valueName))
return;
// Avoid infinite recursion
if (valueType == "object" && value.__visitedByLogValue__) { //;
log(valueName + " [printed above as " + value.__nameWhenVisitedByLogValue__ + "]\n");
return;
}
log(valueName + " " + typeStringNullAware(value) + "\n");
if (valueType == "object") {
value.__visitedByLogValue__ = true;
value.__nameWhenVisitedByLogValue__ = valueName;
logProperties(value, valueName);
}
}
function logProperties(object, objectName)
{
var array = new Array;
for (var property in object) {
array.push(property);
}
array.sort();
for (var i = 0; i < array.length; i++) {
var property = array[i];
logValue(objectName + "." + property);
}
}
logValue('window');
logValue('window.getSelection()');
flushLog();
</script>