OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Helper function to log message to both the local console and to the | 5 // Helper function to log message to both the local console and to the |
6 // background page, so that the latter can output the message via the | 6 // background page, so that the latter can output the message via the |
7 // chrome.test.log() function. | 7 // chrome.test.log() function. |
8 function logToConsoleAndStdout(msg) { | 8 function logToConsoleAndStdout(msg) { |
9 console.log(msg); | 9 console.log(msg); |
10 chrome.extension.sendRequest("log: " + msg); | 10 chrome.extension.sendRequest("log: " + msg); |
11 } | 11 } |
12 | 12 |
13 // We ask the background page to get the extension API to test against. When it | 13 // We ask the background page to get the extension API to test against. When it |
14 // responds we start the test. | 14 // responds we start the test. |
15 console.log("asking for api ..."); | 15 console.log("asking for api ..."); |
16 chrome.extension.sendRequest("getApi", function(apis) { | 16 chrome.extension.sendRequest("getApi", function(apis) { |
17 console.log("got api response"); | 17 console.log("got api response"); |
18 var privilegedPaths = []; | 18 var privilegedPaths = []; |
19 var unprivilegedPaths = []; | 19 var unprivilegedPaths = []; |
20 apis.forEach(function(module) { | 20 apis.forEach(function(module) { |
21 var namespace = module.namespace; | 21 var namespace = module.namespace; |
22 | 22 |
23 ["functions", "events"].forEach(function(section) { | 23 ["functions", "events"].forEach(function(section) { |
24 if (typeof(module[section]) == "undefined") | 24 if (typeof(module[section]) == "undefined") |
25 return; | 25 return; |
26 module[section].forEach(function(entry) { | 26 module[section].forEach(function(entry) { |
| 27 // Ignore entries that are not applicable to the manifest that we're |
| 28 // running under. |
| 29 if (entry.maximumManifestVersion && entry.maximumManifestVersion < 2) { |
| 30 return; |
| 31 } |
| 32 |
27 var path = namespace + "." + entry.name; | 33 var path = namespace + "." + entry.name; |
28 if (module.unprivileged || entry.unprivileged) { | 34 if (module.unprivileged || entry.unprivileged) { |
29 unprivilegedPaths.push(path); | 35 unprivilegedPaths.push(path); |
30 } else { | 36 } else { |
31 privilegedPaths.push(path); | 37 privilegedPaths.push(path); |
32 } | 38 } |
33 }); | 39 }); |
34 }); | 40 }); |
35 | 41 |
36 if (module.properties) { | 42 if (module.properties) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 console.log(success ? "pass" : "fail"); | 157 console.log(success ? "pass" : "fail"); |
152 if (success) { | 158 if (success) { |
153 reportSuccess(); | 159 reportSuccess(); |
154 } else { | 160 } else { |
155 logToConsoleAndStdout("failures on:\n" + failures.join("\n") + | 161 logToConsoleAndStdout("failures on:\n" + failures.join("\n") + |
156 "\n\n\n>>> See comment in stubs_apitest.cc for a " + | 162 "\n\n\n>>> See comment in stubs_apitest.cc for a " + |
157 "hint about fixing this failure.\n\n"); | 163 "hint about fixing this failure.\n\n"); |
158 reportFailure(); | 164 reportFailure(); |
159 } | 165 } |
160 } | 166 } |
OLD | NEW |