| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 var apiFeatures = chrome.test.getApiFeatures(); | 5 var apiFeatures = chrome.test.getApiFeatures(); |
| 6 | 6 |
| 7 // Returns a list of all chrome.foo.bar API paths available to an app. | 7 // Returns a list of all chrome.foo.bar API paths available to an app. |
| 8 function getApiPaths() { | 8 function getApiPaths() { |
| 9 var apiPaths = []; | 9 var apiPaths = []; |
| 10 var apiDefinitions = chrome.test.getApiDefinitions(); | 10 var apiDefinitions = chrome.test.getApiDefinitions(); |
| 11 apiDefinitions.forEach(function(module) { | 11 apiDefinitions.forEach(function(module) { |
| 12 var namespace = module.namespace; | 12 var namespace = module.namespace; |
| 13 var apiFeature = apiFeatures[namespace]; | 13 var apiFeature = apiFeatures[namespace]; |
| 14 if (Array.isArray(apiFeature)) | 14 if (Array.isArray(apiFeature)) |
| 15 apiFeature = apiFeatures[namespace][0]; | 15 apiFeature = apiFeatures[namespace][0]; |
| 16 | 16 |
| 17 // Skip internal APIs. | 17 // Skip internal APIs. |
| 18 if (apiFeature.internal) | 18 if (apiFeature.internal) |
| 19 return; | 19 return; |
| 20 | 20 |
| 21 // Get the API functions and events. | 21 // Get the API functions and events. |
| 22 [module.functions, module.events].forEach(function(section) { | 22 [module.functions, module.events].forEach(function(section) { |
| 23 if (typeof(section) == "undefined") | 23 if (typeof(section) == "undefined") |
| 24 return; | 24 return; |
| 25 // Pieces of the module don't inherit from Array/Object. | 25 section.forEach(function(entry) { |
| 26 Array.prototype.forEach.call(section, function(entry) { | |
| 27 apiPaths.push(namespace + "." + entry.name); | 26 apiPaths.push(namespace + "." + entry.name); |
| 28 }); | 27 }); |
| 29 }); | 28 }); |
| 30 | 29 |
| 31 // Get the API properties. | 30 // Get the API properties. |
| 32 if (module.properties) { | 31 if (module.properties) { |
| 33 Object.getOwnPropertyNames(module.properties).forEach(function(propName) { | 32 Object.getOwnPropertyNames(module.properties).forEach(function(propName) { |
| 34 apiPaths.push(namespace + "." + propName); | 33 apiPaths.push(namespace + "." + propName); |
| 35 }); | 34 }); |
| 36 } | 35 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 console.log("failures on:\n" + failures.join("\n") + | 73 console.log("failures on:\n" + failures.join("\n") + |
| 75 "\n\n\n>>> See comment in stubs_apitest.cc for a " + | 74 "\n\n\n>>> See comment in stubs_apitest.cc for a " + |
| 76 "hint about fixing this failure.\n\n"); | 75 "hint about fixing this failure.\n\n"); |
| 77 chrome.test.notifyFail("failed"); | 76 chrome.test.notifyFail("failed"); |
| 78 } | 77 } |
| 79 } | 78 } |
| 80 | 79 |
| 81 chrome.app.runtime.onLaunched.addListener(function() { | 80 chrome.app.runtime.onLaunched.addListener(function() { |
| 82 doTest(); | 81 doTest(); |
| 83 }); | 82 }); |
| OLD | NEW |