1 function collectProperties()
3 // Collect properties of the top-level window, since touching the properties
4 // of a DOMWindow affects its internal C++ state.
5 collectPropertiesHelper(window, []);
7 propertiesToVerify.sort(function (a, b)
9 if (a.property < b.property)
11 if (a.property > b.property)
17 function emitExpectedResult(path, expected)
19 // Skip internals properties, since they aren't web accessible.
20 if (path[0] == 'internals'
21 || path[0] == 'propertiesToVerify' // Skip the list we're building...
22 || path[0] == 'clientInformation' // Just an alias for navigator.
23 || path[0] == 'testRunner' // Skip testRunner since they are only for testing.
24 || path[0] == 'layoutTestController' // Just an alias for testRunner.
25 || path[0] == 'eventSender') { // Skip eventSender since they are only for testing.
29 // Skip the properties which are hard to expect a stable result.
30 if (path[0] == 'accessibilityController' // we can hardly estimate the states of the cached WebAXObjects.
31 || path[0] == 'localStorage') { // local storage is not reliably cleared between tests.
35 // FIXME: Skip MemoryInfo for now, since it's not implemented as a DOMWindowProperty, and has
36 // no way of knowing when it's detached. Eventually this should have the same behavior.
37 if (path.length >= 2 && (path[0] == 'console' || path[0] == 'performance') && path[1] == 'memory')
40 // Skip things that are assumed to be constants.
41 if (path[path.length - 1].toUpperCase() == path[path.length - 1])
44 // Various special cases for legacy reasons. Please do not add entries to this list.
45 var propertyPath = path.join('.');
46 switch (propertyPath) {
48 expected = "'about:blank'";
50 case "location.origin":
53 case "location.pathname":
56 case "location.protocol":
57 expected = "'about:'";
59 case "navigator.appCodeName":
60 case "navigator.appName":
61 case "navigator.language":
62 case "navigator.onLine":
63 case "navigator.platform":
64 case "navigator.product":
65 case "navigator.productSub":
66 case "navigator.vendor":
67 expected = "window." + propertyPath;
69 case "screen.orientation":
70 expected = "'portrait-primary'";
74 insertExpectedResult(path, expected);
77 function collectPropertiesHelper(object, path)
80 throw 'Error: probably looping';
82 for (var property in object) {
84 var type = typeof(object[property]);
85 if (type == "object") {
86 if (object[property] === null) {
87 emitExpectedResult(path, "null");
88 } else if (!object[property].Window
89 && !(object[property] instanceof Node)
90 && !(object[property] instanceof MimeTypeArray)
91 && !(object[property] instanceof PluginArray)) {
92 // Skip some traversing through types that will end up in cycles...
93 collectPropertiesHelper(object[property], path);
95 } else if (type == "string") {
96 emitExpectedResult(path, "''");
97 } else if (type == "number") {
98 emitExpectedResult(path, "0");
99 } else if (type == "boolean") {
100 emitExpectedResult(path, "false");