| OLD | NEW |
| 1 function collectProperties() | 1 function collectProperties() |
| 2 { | 2 { |
| 3 // Collect properties of the top-level window, since touching the properties | 3 // Collect properties of the top-level window, since touching the properties |
| 4 // of a DOMWindow affects its internal C++ state. | 4 // of a DOMWindow affects its internal C++ state. |
| 5 collectPropertiesHelper(window, []); | 5 collectPropertiesHelper(window, []); |
| 6 | 6 |
| 7 propertiesToVerify.sort(function (a, b) | 7 propertiesToVerify.sort(function (a, b) |
| 8 { | 8 { |
| 9 if (a.property < b.property) | 9 if (a.property < b.property) |
| 10 return -1 | 10 return -1 |
| 11 if (a.property > b.property) | 11 if (a.property > b.property) |
| 12 return 1; | 12 return 1; |
| 13 return 0; | 13 return 0; |
| 14 }); | 14 }); |
| 15 } | 15 } |
| 16 | 16 |
| 17 function emitExpectedResult(path, expected) | 17 function emitExpectedResult(path, expected) |
| 18 { | 18 { |
| 19 // Skip internals properties, since they aren't web accessible. | 19 // Skip internals properties, since they aren't web accessible. |
| 20 if (path[0] == 'internals' | 20 if (path[0] == 'internals' |
| 21 || path[0] == 'propertiesToVerify' // Skip the list we're building... | 21 || path[0] == 'propertiesToVerify' // Skip the list we're building... |
| 22 || path[0] == 'clientInformation' // Just an alias for navigator. | 22 || path[0] == 'clientInformation' // Just an alias for navigator. |
| 23 // Skip testRunner since they are only for testing. | 23 || path[0] == 'testRunner' // Skip testRunner since they are only for te
sting. |
| 24 || path[0] == 'testRunner' | 24 || path[0] == 'layoutTestController' // Just an alias for testRunner. |
| 25 || path[0] == 'eventSender' // Skip eventSender since they are only for
testing. | 25 || path[0] == 'eventSender') { // Skip eventSender since they are only f
or testing. |
| 26 || path[0] == 'layoutTestController') { // Just an alias for testRunner. | |
| 27 return; | 26 return; |
| 28 } | 27 } |
| 29 | 28 |
| 29 // Skip the properties which are hard to expect a stable result. |
| 30 if (path[0] == 'accessibilityController' // we can hardly estimate the state
s of the cached WebAXObjects. |
| 31 || path[0] == 'localStorage') { // local storage is not reliably cleared
between tests. |
| 32 return; |
| 33 } |
| 34 |
| 30 // FIXME: Skip MemoryInfo for now, since it's not implemented as a DOMWindow
Property, and has | 35 // FIXME: Skip MemoryInfo for now, since it's not implemented as a DOMWindow
Property, and has |
| 31 // no way of knowing when it's detached. Eventually this should have the sam
e behavior. | 36 // no way of knowing when it's detached. Eventually this should have the sam
e behavior. |
| 32 if (path.length >= 2 && (path[0] == 'console' || path[0] == 'performance') &
& path[1] == 'memory') | 37 if (path.length >= 2 && (path[0] == 'console' || path[0] == 'performance') &
& path[1] == 'memory') |
| 33 return; | 38 return; |
| 34 | 39 |
| 35 // Skip things that are assumed to be constants. | 40 // Skip things that are assumed to be constants. |
| 36 if (path[path.length - 1].toUpperCase() == path[path.length - 1]) | 41 if (path[path.length - 1].toUpperCase() == path[path.length - 1]) |
| 37 return; | 42 return; |
| 38 | 43 |
| 39 // Various special cases for legacy reasons. Please do not add entries to th
is list. | 44 // Various special cases for legacy reasons. Please do not add entries to th
is list. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 68 | 73 |
| 69 insertExpectedResult(path, expected); | 74 insertExpectedResult(path, expected); |
| 70 } | 75 } |
| 71 | 76 |
| 72 function collectPropertiesHelper(object, path) | 77 function collectPropertiesHelper(object, path) |
| 73 { | 78 { |
| 74 if (path.length > 20) | 79 if (path.length > 20) |
| 75 throw 'Error: probably looping'; | 80 throw 'Error: probably looping'; |
| 76 | 81 |
| 77 for (var property in object) { | 82 for (var property in object) { |
| 78 // Skip the properties which are hard to expect a stable result. | |
| 79 // As for 'accessibilityController', we can hardly estimate the states | |
| 80 // of the cached WebAXObjects. | |
| 81 // FIXME: We can't access accessibilityController's properties here | |
| 82 // because some property accesses might crash (crbug/351195). | |
| 83 if (property == 'accessibilityController') | |
| 84 continue; | |
| 85 // As for 'localStorage', local storage is not reliably cleared between
tests. | |
| 86 if (property == 'localStorage') | |
| 87 continue; | |
| 88 path.push(property); | 83 path.push(property); |
| 89 var type = typeof(object[property]); | 84 var type = typeof(object[property]); |
| 90 if (type == "object") { | 85 if (type == "object") { |
| 91 if (object[property] === null) { | 86 if (object[property] === null) { |
| 92 emitExpectedResult(path, "null"); | 87 emitExpectedResult(path, "null"); |
| 93 } else if (!object[property].Window | 88 } else if (!object[property].Window |
| 94 && !(object[property] instanceof Node) | 89 && !(object[property] instanceof Node) |
| 95 && !(object[property] instanceof MimeTypeArray) | 90 && !(object[property] instanceof MimeTypeArray) |
| 96 && !(object[property] instanceof PluginArray)) { | 91 && !(object[property] instanceof PluginArray)) { |
| 97 // Skip some traversing through types that will end up in cycles
... | 92 // Skip some traversing through types that will end up in cycles
... |
| 98 collectPropertiesHelper(object[property], path); | 93 collectPropertiesHelper(object[property], path); |
| 99 } | 94 } |
| 100 } else if (type == "string") { | 95 } else if (type == "string") { |
| 101 emitExpectedResult(path, "''"); | 96 emitExpectedResult(path, "''"); |
| 102 } else if (type == "number") { | 97 } else if (type == "number") { |
| 103 emitExpectedResult(path, "0"); | 98 emitExpectedResult(path, "0"); |
| 104 } else if (type == "boolean") { | 99 } else if (type == "boolean") { |
| 105 emitExpectedResult(path, "false"); | 100 emitExpectedResult(path, "false"); |
| 106 } | 101 } |
| 107 path.pop(); | 102 path.pop(); |
| 108 } | 103 } |
| 109 } | 104 } |
| OLD | NEW |