| <p>This test dumps all of the properties that are reachable from the window.performance object, along with their types.</p> |
| <hr> |
| <pre id="pre"></pre> |
| |
| <script> |
| if (window.testRunner) |
| testRunner.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 + "]"; |
| } |
| |
| 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; |
| |
| // 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.performance'); |
| window.performance.timing = 'timing is not replaceable'; |
| logValue('window.performance.timing'); |
| window.performance.navigation = 'navigation is not replaceable'; |
| logValue('window.performance.navigation'); |
| window.performance = 'performance is replaceable'; |
| logValue('window.performance'); |
| flushLog(); |
| </script> |