| 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 // test_custom_bindings.js | 5 // test_custom_bindings.js |
| 6 // mini-framework for ExtensionApiTest browser tests | 6 // mini-framework for ExtensionApiTest browser tests |
| 7 | 7 |
| 8 var binding = require('binding').Binding.create('test'); | 8 var binding = require('binding').Binding.create('test'); |
| 9 | 9 |
| 10 var chrome = requireNative('chrome').GetChrome(); | 10 var chrome = requireNative('chrome').GetChrome(); |
| 11 var GetExtensionAPIDefinitions = | 11 var GetExtensionAPIDefinitionsForTest = |
| 12 requireNative('apiDefinitions').GetExtensionAPIDefinitions; | 12 requireNative('apiDefinitions').GetExtensionAPIDefinitionsForTest; |
| 13 var GetAvailability = requireNative('v8_context').GetAvailability; | 13 var GetAvailability = requireNative('v8_context').GetAvailability; |
| 14 var GetAPIFeatures = requireNative('test_features').GetAPIFeatures; | 14 var GetAPIFeatures = requireNative('test_features').GetAPIFeatures; |
| 15 | 15 |
| 16 binding.registerCustomHook(function(api) { | 16 binding.registerCustomHook(function(api) { |
| 17 var chromeTest = api.compiledApi; | 17 var chromeTest = api.compiledApi; |
| 18 var apiFunctions = api.apiFunctions; | 18 var apiFunctions = api.apiFunctions; |
| 19 | 19 |
| 20 chromeTest.tests = chromeTest.tests || []; | 20 chromeTest.tests = chromeTest.tests || []; |
| 21 | 21 |
| 22 var currentTest = null; | 22 var currentTest = null; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return chromeTest.callback(func, expectedError); | 283 return chromeTest.callback(func, expectedError); |
| 284 }); | 284 }); |
| 285 | 285 |
| 286 apiFunctions.setHandleRequest('runTests', function(tests) { | 286 apiFunctions.setHandleRequest('runTests', function(tests) { |
| 287 chromeTest.tests = tests; | 287 chromeTest.tests = tests; |
| 288 testCount = chromeTest.tests.length; | 288 testCount = chromeTest.tests.length; |
| 289 chromeTest.runNextTest(); | 289 chromeTest.runNextTest(); |
| 290 }); | 290 }); |
| 291 | 291 |
| 292 apiFunctions.setHandleRequest('getApiDefinitions', function() { | 292 apiFunctions.setHandleRequest('getApiDefinitions', function() { |
| 293 return GetExtensionAPIDefinitions().filter(function(api) { | 293 return GetExtensionAPIDefinitionsForTest(); |
| 294 return GetAvailability(api.namespace).is_available; | |
| 295 }); | |
| 296 }); | 294 }); |
| 297 | 295 |
| 298 apiFunctions.setHandleRequest('getApiFeatures', function() { | 296 apiFunctions.setHandleRequest('getApiFeatures', function() { |
| 299 return GetAPIFeatures(); | 297 return GetAPIFeatures(); |
| 300 }); | 298 }); |
| 301 }); | 299 }); |
| 302 | 300 |
| 303 exports.binding = binding.generate(); | 301 exports.binding = binding.generate(); |
| OLD | NEW |