1 <p>This test dumps all of the properties that are reachable from the window.performance object, along with their types.
</p>
7 testRunner
.dumpAsText();
15 var pre
= document
.getElementById('pre');
18 var logMessage
= logBuffer
.join("");
19 pre
.appendChild(document
.createTextNode(logMessage
));
22 function tryEval(string
)
27 return new String("Caught exception: " + e
);
31 function typeOfNullAware(value
)
33 if (typeof value
== "object" && value
== null) //;
38 function typeStringNullAware(value
)
40 var valueType
= typeOfNullAware(value
);
41 return valueType
== "object"
42 ? Object
.prototype.toString
.call(value
)
43 : "[" + valueType
+ "]";
46 function logValue(valueName
)
48 var value
= tryEval(valueName
);
49 var valueType
= typeOfNullAware(value
);
51 // Don't taint the test with our own variables
52 if (value
== logBuffer
|| value
== pre
)
55 // Don't taint the test with our own properties
56 if (/__visitedByLogValue__/.test(valueName
) || /__nameWhenVisitedByLogValue__/.test(valueName
))
59 // Work around Firefox infinite recursion
60 if (/\.[0-9]/.test(valueName
))
63 // Avoid infinite recursion
64 if (valueType
== "object" && value
.__visitedByLogValue__
) { //;
65 log(valueName
+ " [printed above as " + value
.__nameWhenVisitedByLogValue__
+ "]\n");
69 log(valueName
+ " " + typeStringNullAware(value
) + "\n");
71 if (valueType
== "object") {
72 value
.__visitedByLogValue__
= true;
73 value
.__nameWhenVisitedByLogValue__
= valueName
;
74 logProperties(value
, valueName
);
78 function logProperties(object
, objectName
)
80 var array
= new Array
;
81 for (var property
in object
) {
85 for (var i
= 0; i
< array
.length
; i
++) {
86 var property
= array
[i
];
87 logValue(objectName
+ "." + property
);
91 logValue('window.performance');
92 window
.performance
.timing
= 'timing is not replaceable';
93 logValue('window.performance.timing');
94 // PerformanceTiming supports a serializer.
95 var jsonizedTiming
= JSON
.parse(JSON
.stringify(window
.performance
.timing
));
96 logValue('jsonizedTiming');
97 // PerformanceEntry supports a serializer.
98 window
.performance
.measure('request');
99 var jsonizedEntry
= JSON
.parse(JSON
.stringify(window
.performance
.getEntriesByName('request')[0]));
100 logValue('jsonizedEntry');
101 window
.performance
.navigation
= 'navigation is not replaceable';
102 logValue('window.performance.navigation');
103 window
.performance
= 'performance is replaceable';
104 logValue('window.performance');