Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Window / window-properties-device-orientation.html
blob842c33206f68bcdf5d33d47604890310f7978769
1 <p>This test dumps all of the properties that are reachable from the window.DeviceMotionEvent window.ondevicemotion, window.DeviceOrientationEvent and window.ondeviceorientation objects, along with their types.
2 These properties are currently enabled by a runtime flag.</p>
3 <hr>
4 <pre id="pre"></pre>
6 <script>
7 if (window.testRunner)
8 testRunner.dumpAsText();
10 var logBuffer = [];
11 function log(s)
13 logBuffer.push(s);
16 var pre = document.getElementById('pre');
17 function flushLog()
19 var logMessage = logBuffer.join("");
20 pre.appendChild(document.createTextNode(logMessage));
23 function tryEval(string)
25 try {
26 return eval(string);
27 } catch (e) {
28 return new String("Caught exception: " + e);
32 function typeOfNullAware(value)
34 if (typeof value == "object" && value == null)
35 return "null";
36 return typeof value;
39 function typeStringNullAware(value)
41 var valueType = typeOfNullAware(value);
42 return valueType == "object"
43 ? Object.prototype.toString.call(value)
44 : "[" + valueType + "]";
47 function logValue(valueName)
49 var value = tryEval(valueName);
50 var valueType = typeOfNullAware(value);
52 // Don't taint the test with our own variables
53 if (value == logBuffer || value == pre)
54 return;
56 // Don't taint the test with our own properties
57 if (/__visitedByLogValue__/.test(valueName) || /__nameWhenVisitedByLogValue__/.test(valueName))
58 return;
60 // Work around Firefox infinite recursion
61 if (/\.[0-9]/.test(valueName))
62 return;
64 // Avoid infinite recursion
65 if (valueType == "object" && value.__visitedByLogValue__) {
66 log(valueName + " [printed above as " + value.__nameWhenVisitedByLogValue__ + "]\n");
67 return;
70 log(valueName + " " + typeStringNullAware(value) + "\n");
72 if (valueType == "object") {
73 value.__visitedByLogValue__ = true;
74 value.__nameWhenVisitedByLogValue__ = valueName;
75 logProperties(value, valueName);
79 function logProperties(object, objectName)
81 var array = new Array;
82 for (var property in object) {
83 array.push(property);
85 array.sort();
86 for (var i = 0; i < array.length; i++) {
87 var property = array[i];
88 logValue(objectName + "." + property);
92 logValue('window.DeviceMotionEvent');
93 logValue('window.ondevicemotion');
94 logValue('window.DeviceOrientationEvent');
95 logValue('window.ondeviceorientation');
96 flushLog();
97 </script>