| 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 var apiFeatures = chrome.test.getApiFeatures(); | 17 var apiFeatures = chrome.test.getApiFeatures(); |
| 18 function isAvailableToContentScripts(namespace, path) { | 18 function isAvailableToContentScripts(namespace, path) { |
| 19 function checkContexts(contextList) { |
| 20 return contextList == 'all' || |
| 21 contextList.indexOf('content_script') != -1; |
| 22 } |
| 19 if (apiFeatures.hasOwnProperty(path)) | 23 if (apiFeatures.hasOwnProperty(path)) |
| 20 return apiFeatures[path]['contexts'].indexOf('content_script') != -1 | 24 return checkContexts(apiFeatures[path]['contexts']); |
| 21 return apiFeatures.hasOwnProperty(namespace) && | 25 return apiFeatures.hasOwnProperty(namespace) && |
| 22 apiFeatures[namespace]['contexts'].indexOf('content_script') != -1; | 26 checkContexts(apiFeatures[namespace]['contexts']); |
| 23 } | 27 } |
| 24 | 28 |
| 25 console.log("got api response"); | 29 console.log("got api response"); |
| 26 var privilegedPaths = []; | 30 var privilegedPaths = []; |
| 27 var unprivilegedPaths = []; | 31 var unprivilegedPaths = []; |
| 28 apis.forEach(function(module) { | 32 apis.forEach(function(module) { |
| 29 var namespace = module.namespace; | 33 var namespace = module.namespace; |
| 30 | 34 |
| 31 ["functions", "events"].forEach(function(section) { | 35 ["functions", "events"].forEach(function(section) { |
| 32 if (typeof(module[section]) == "undefined") | 36 if (typeof(module[section]) == "undefined") |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 console.log(success ? "pass" : "fail"); | 158 console.log(success ? "pass" : "fail"); |
| 155 if (success) { | 159 if (success) { |
| 156 reportSuccess(); | 160 reportSuccess(); |
| 157 } else { | 161 } else { |
| 158 logToConsoleAndStdout("failures on:\n" + failures.join("\n") + | 162 logToConsoleAndStdout("failures on:\n" + failures.join("\n") + |
| 159 "\n\n\n>>> See comment in stubs_apitest.cc for a " + | 163 "\n\n\n>>> See comment in stubs_apitest.cc for a " + |
| 160 "hint about fixing this failure.\n\n"); | 164 "hint about fixing this failure.\n\n"); |
| 161 reportFailure(); | 165 reportFailure(); |
| 162 } | 166 } |
| 163 } | 167 } |
| OLD | NEW |