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 // TODO(aa): Remove this whole test when all the APIs have been converted to |
| 22 // the feature system. |
| 23 if (module.uses_feature_system) |
| 24 return; |
21 var namespace = module.namespace; | 25 var namespace = module.namespace; |
22 | 26 |
23 ["functions", "events"].forEach(function(section) { | 27 ["functions", "events"].forEach(function(section) { |
24 if (typeof(module[section]) == "undefined") | 28 if (typeof(module[section]) == "undefined") |
25 return; | 29 return; |
26 module[section].forEach(function(entry) { | 30 module[section].forEach(function(entry) { |
27 var path = namespace + "." + entry.name; | 31 var path = namespace + "." + entry.name; |
28 if (module.unprivileged || entry.unprivileged) { | 32 if (module.unprivileged || entry.unprivileged) { |
29 unprivilegedPaths.push(path); | 33 unprivilegedPaths.push(path); |
30 } else { | 34 } else { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return false; | 83 return false; |
80 } else if (!expectError) { | 84 } else if (!expectError) { |
81 return true; | 85 return true; |
82 } | 86 } |
83 } catch (err) { | 87 } catch (err) { |
84 if (!expectError) { | 88 if (!expectError) { |
85 logToConsoleAndStdout(" fail (did not expect error): " + path); | 89 logToConsoleAndStdout(" fail (did not expect error): " + path); |
86 return false; | 90 return false; |
87 } | 91 } |
88 var str = err.toString(); | 92 var str = err.toString(); |
89 if (str.search("can only be used in extension processes.") != -1) { | 93 if (str.search("cannot be used in this context.") != -1) { |
90 return true; | 94 return true; |
91 } else { | 95 } else { |
92 logToConsoleAndStdout( | 96 logToConsoleAndStdout( |
93 "fail: " + path + " (wrong error: '" + str + "')"); | 97 "fail: " + path + " (wrong error: '" + str + "')"); |
94 return false; | 98 return false; |
95 } | 99 } |
96 } | 100 } |
97 } | 101 } |
98 } | 102 } |
99 logToConsoleAndStdout(" fail (no error when we were expecting one): " + path); | 103 logToConsoleAndStdout(" fail (no error when we were expecting one): " + path); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 console.log(success ? "pass" : "fail"); | 153 console.log(success ? "pass" : "fail"); |
150 if (success) { | 154 if (success) { |
151 reportSuccess(); | 155 reportSuccess(); |
152 } else { | 156 } else { |
153 logToConsoleAndStdout("failures on:\n" + failures.join("\n") + | 157 logToConsoleAndStdout("failures on:\n" + failures.join("\n") + |
154 "\n\n\n>>> See comment in stubs_apitest.cc for a " + | 158 "\n\n\n>>> See comment in stubs_apitest.cc for a " + |
155 "hint about fixing this failure.\n\n"); | 159 "hint about fixing this failure.\n\n"); |
156 reportFailure(); | 160 reportFailure(); |
157 } | 161 } |
158 } | 162 } |
OLD | NEW |