| OLD | NEW |
| 1 | 1 |
| 2 // Helper function to log message to both the local console and to the | 2 // Helper function to log message to both the local console and to the |
| 3 // background page, so that the latter can output the message via the | 3 // background page, so that the latter can output the message via the |
| 4 // chrome.test.log() function. | 4 // chrome.test.log() function. |
| 5 function logToConsoleAndStdout(msg) { | 5 function logToConsoleAndStdout(msg) { |
| 6 console.log(msg); | 6 console.log(msg); |
| 7 chrome.extension.sendRequest("log: " + msg); | 7 chrome.extension.sendRequest("log: " + msg); |
| 8 } | 8 } |
| 9 | 9 |
| 10 // We ask the background page to get the extension API to test against. When it | 10 // We ask the background page to get the extension API to test against. When it |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // Iterate over each component of the path, making sure all but the last part | 59 // Iterate over each component of the path, making sure all but the last part |
| 60 // is defined. The last part should either be defined or throw an error on | 60 // is defined. The last part should either be defined or throw an error on |
| 61 // attempted access. | 61 // attempted access. |
| 62 var module = chrome; | 62 var module = chrome; |
| 63 for (var i = 0; i < parts.length; i++) { | 63 for (var i = 0; i < parts.length; i++) { |
| 64 if (i < parts.length - 1) { | 64 if (i < parts.length - 1) { |
| 65 // Not the last component, so expect non-null / no exception. | 65 // Not the last component, so expect non-null / no exception. |
| 66 try { | 66 try { |
| 67 module = module[parts[i]]; | 67 module = module[parts[i]]; |
| 68 } catch (err) { | 68 } catch (err) { |
| 69 logToConsoleAndStdout("testPath failed on subcomponent of " + path); | 69 logToConsoleAndStdout("testPath failed on " + |
| 70 parts.slice(0, i+1).join('.') + '(' + err + ')'); |
| 70 return false; | 71 return false; |
| 71 } | 72 } |
| 72 } else { | 73 } else { |
| 73 // This is the last component - we expect it to either be defined or | 74 // This is the last component - we expect it to either be defined or |
| 74 // to throw an error on access. | 75 // to throw an error on access. |
| 75 try { | 76 try { |
| 76 if (typeof(module[parts[i]]) == "undefined" && | 77 if (typeof(module[parts[i]]) == "undefined" && |
| 77 path != "extension.lastError") { | 78 path != "extension.lastError") { |
| 78 logToConsoleAndStdout(" fail (undefined and not throwing error): " + | 79 logToConsoleAndStdout(" fail (undefined and not throwing error): " + |
| 79 path); | 80 path); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if (success) { | 153 if (success) { |
| 153 reportSuccess(); | 154 reportSuccess(); |
| 154 } else { | 155 } else { |
| 155 logToConsoleAndStdout("failures on:\n" + failures.join("\n") + | 156 logToConsoleAndStdout("failures on:\n" + failures.join("\n") + |
| 156 "\n\n\n>>> See comment in stubs_apitest.cc for a " + | 157 "\n\n\n>>> See comment in stubs_apitest.cc for a " + |
| 157 "hint about fixing this failure.\n\n"); | 158 "hint about fixing this failure.\n\n"); |
| 158 reportFailure(); | 159 reportFailure(); |
| 159 } | 160 } |
| 160 } | 161 } |
| 161 | 162 |
| OLD | NEW |