OLD | NEW |
(Empty) | |
| 1 function collectProperties() |
| 2 { |
| 3 // Collect properties of the top-level window, since touching the properties |
| 4 // of a DOMWindow affects its internal C++ state. |
| 5 collectPropertiesHelper(window, []); |
| 6 |
| 7 propertiesToVerify.sort(function (a, b) |
| 8 { |
| 9 if (a.property < b.property) |
| 10 return -1 |
| 11 if (a.property > b.property) |
| 12 return 1; |
| 13 return 0; |
| 14 }); |
| 15 } |
| 16 |
| 17 function emitExpectedResult(path, expected) |
| 18 { |
| 19 if (path[0] == 'internals' // Skip internals properties, since they aren't w
eb accessible. |
| 20 || path[0] == 'propertiesToVerify' // Skip the list we're building... |
| 21 || path[0] == 'clientInformation') // Just an alias for navigator. |
| 22 return; |
| 23 // FIXME: Skip MemoryInfo for now, since it's not implemented as a DOMWindow
Property, and has |
| 24 // no way of knowing when it's detached. Eventually this should have the sam
e behavior. |
| 25 if (path.length >= 2 && (path[0] == 'console' || path[0] == 'performance') &
& path[1] == 'memory') |
| 26 return; |
| 27 // Skip things that are assumed to be constants. |
| 28 if (path[path.length - 1].toUpperCase() == path[path.length - 1]) |
| 29 return; |
| 30 |
| 31 // Various special cases... |
| 32 var propertyPath = path.join('.'); |
| 33 switch (propertyPath) { |
| 34 case "location.href": |
| 35 expected = "'about:blank'"; |
| 36 break; |
| 37 case "location.origin": |
| 38 expected = "'null'"; |
| 39 break; |
| 40 case "location.pathname": |
| 41 expected = "'blank'"; |
| 42 break; |
| 43 case "location.protocol": |
| 44 expected = "'about:'"; |
| 45 break; |
| 46 case "navigator.appCodeName": |
| 47 case "navigator.appName": |
| 48 case "navigator.language": |
| 49 case "navigator.onLine": |
| 50 case "navigator.platform": |
| 51 case "navigator.product": |
| 52 case "navigator.productSub": |
| 53 case "navigator.vendor": |
| 54 expected = "window." + propertyPath; |
| 55 break; |
| 56 } |
| 57 |
| 58 insertExpectedResult(path, expected); |
| 59 } |
| 60 |
| 61 function collectPropertiesHelper(object, path) |
| 62 { |
| 63 if (path.length > 20) |
| 64 throw 'Error: probably looping'; |
| 65 for (var property in object) { |
| 66 if (!object[property]) |
| 67 continue; |
| 68 path.push(property); |
| 69 var type = typeof(object[property]); |
| 70 if (type == "object") { |
| 71 // Skip some traversing through types that will end up in cycles... |
| 72 if (!object[property].Window |
| 73 && !(object[property] instanceof Node) |
| 74 && !(object[property] instanceof MimeTypeArray) |
| 75 && !(object[property] instanceof PluginArray)) { |
| 76 collectPropertiesHelper(object[property], path); |
| 77 } |
| 78 } else if (type == "string") { |
| 79 emitExpectedResult(path, "''"); |
| 80 } else if (type == "number") { |
| 81 emitExpectedResult(path, "0"); |
| 82 } else if (type == "boolean") { |
| 83 emitExpectedResult(path, "false"); |
| 84 } |
| 85 path.pop(); |
| 86 } |
| 87 } |
| 88 |
OLD | NEW |