Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Window / window-properties-performance.html
blob9662090241e54273cdb52c89b9640a0c7037fa35
1 <p>This test dumps all of the properties that are reachable from the window.performance object, along with their types.</p>
2 <hr>
3 <pre id="pre"></pre>
5 <script>
6 if (window.testRunner)
7 testRunner.dumpAsText();
9 var logBuffer = [];
10 function log(s)
12 logBuffer.push(s);
15 var pre = document.getElementById('pre');
16 function flushLog()
18 var logMessage = logBuffer.join("");
19 pre.appendChild(document.createTextNode(logMessage));
22 function tryEval(string)
24 try {
25 return eval(string);
26 } catch (e) {
27 return new String("Caught exception: " + e);
31 function typeOfNullAware(value)
33 if (typeof value == "object" && value == null) //;
34 return "null";
35 return typeof value;
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)
53 return;
55 // Don't taint the test with our own properties
56 if (/__visitedByLogValue__/.test(valueName) || /__nameWhenVisitedByLogValue__/.test(valueName))
57 return;
59 // Work around Firefox infinite recursion
60 if (/\.[0-9]/.test(valueName))
61 return;
63 // Avoid infinite recursion
64 if (valueType == "object" && value.__visitedByLogValue__) { //;
65 log(valueName + " [printed above as " + value.__nameWhenVisitedByLogValue__ + "]\n");
66 return;
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) {
82 array.push(property);
84 array.sort();
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');
105 flushLog();
106 </script>