Chromium Code Reviews| Index: extensions/test/data/test_unittest_custom_bindings.js |
| diff --git a/extensions/renderer/resources/test_custom_bindings.js b/extensions/test/data/test_unittest_custom_bindings.js |
| similarity index 87% |
| copy from extensions/renderer/resources/test_custom_bindings.js |
| copy to extensions/test/data/test_unittest_custom_bindings.js |
| index 5fd45495247c5def8a319ef9895dd59d07155640..d84c290d1d18ebb4d79bd85d172e97b9bcfdba09 100644 |
| --- a/extensions/renderer/resources/test_custom_bindings.js |
| +++ b/extensions/test/data/test_unittest_custom_bindings.js |
| @@ -2,21 +2,14 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -// test_custom_bindings.js |
| -// mini-framework for ExtensionApiTest browser tests |
| +// test_unittest_custom_bindings.js |
| +// An implementation of chrome.test for ApiTestBase unit tests. |
| +// This is a fork of src/extensions/renderer/resources/test_custom_bindings.js. |
|
not at google - send to devlin
2014/07/18 15:09:14
I'm not sure about this. It seems like you could a
Sam McNally
2014/07/21 03:56:28
Done.
|
| var binding = require('binding').Binding.create('test'); |
| -var chrome = requireNative('chrome').GetChrome(); |
| -var GetExtensionAPIDefinitionsForTest = |
| - requireNative('apiDefinitions').GetExtensionAPIDefinitionsForTest; |
| -var GetAvailability = requireNative('v8_context').GetAvailability; |
| -var GetAPIFeatures = requireNative('test_features').GetAPIFeatures; |
| +var nativesPromise = requireAsync('testNatives'); |
| var uncaughtExceptionHandler = require('uncaught_exception_handler'); |
| -var userGestures = requireNative('user_gestures'); |
| - |
| -var RunWithNativesEnabledModuleSystem = |
| - requireNative('v8_context').RunWithNativesEnabledModuleSystem; |
| binding.registerCustomHook(function(api) { |
| var chromeTest = api.compiledApi; |
| @@ -36,10 +29,30 @@ binding.registerCustomHook(function(api) { |
| return test ? (test.name || test.generatedName) : "(no test)"; |
| } |
| + apiFunctions.setHandleRequest('notifyPass', function() { |
| + nativesPromise.then(function(natives) { |
| + natives.NotifyPass(); |
| + }); |
| + }); |
| + |
| + apiFunctions.setHandleRequest('notifyFail', function(message) { |
| + nativesPromise.then(function(natives) { |
| + natives.NotifyFail(message); |
| + }); |
| + }); |
| + |
| + apiFunctions.setHandleRequest('log', function() { |
| + nativesPromise.then(function(natives) { |
| + natives.Log($Array.join(arguments, ' ')); |
| + }); |
| + }); |
| + |
| function testDone() { |
| - // Use setTimeout here to allow previous test contexts to be |
| - // eligible for garbage collection. |
| - setTimeout(chromeTest.runNextTest, 0); |
| + // Use a promise here to allow previous test contexts to be eligible for |
| + // garbage collection. |
| + Promise.resolve().then(function() { |
| + chromeTest.runNextTest(); |
| + }); |
| } |
| function allTestsDone() { |
| @@ -126,7 +139,7 @@ binding.registerCustomHook(function(api) { |
| }); |
| apiFunctions.setHandleRequest('runWithModuleSystem', function(callback) { |
| - RunWithNativesEnabledModuleSystem(callback); |
| + throw new Error('Not implemented'); |
| }); |
| apiFunctions.setHandleRequest('assertTrue', function(test, message) { |
| @@ -324,31 +337,36 @@ binding.registerCustomHook(function(api) { |
| }); |
| apiFunctions.setHandleRequest('runTests', function(tests) { |
| - chromeTest.tests = tests; |
| - testCount = chromeTest.tests.length; |
| - chromeTest.runNextTest(); |
| + var testWrappers = {}; |
| + $Array.forEach(tests, function(testCase) { |
| + testWrappers[testName(testCase)] = function() { |
| + chromeTest.tests = [testCase]; |
| + testCount = 1; |
| + chromeTest.runNextTest(); |
| + return true; |
| + } |
| + }); |
| + return testWrappers; |
| }); |
| apiFunctions.setHandleRequest('getApiDefinitions', function() { |
| - return GetExtensionAPIDefinitionsForTest(); |
| + throw new Error('Not implemented'); |
| }); |
| apiFunctions.setHandleRequest('getApiFeatures', function() { |
| - return GetAPIFeatures(); |
| + throw new Error('Not implemented'); |
| }); |
| apiFunctions.setHandleRequest('isProcessingUserGesture', function() { |
| - return userGestures.IsProcessingUserGesture(); |
| + throw new Error('Not implemented'); |
| }); |
| apiFunctions.setHandleRequest('runWithUserGesture', function(callback) { |
| - chromeTest.assertEq(typeof(callback), 'function'); |
| - return userGestures.RunWithUserGesture(callback); |
| + throw new Error('Not implemented'); |
| }); |
| apiFunctions.setHandleRequest('runWithoutUserGesture', function(callback) { |
| - chromeTest.assertEq(typeof(callback), 'function'); |
| - return userGestures.RunWithoutUserGesture(callback); |
| + throw new Error('Not implemented'); |
| }); |
| apiFunctions.setHandleRequest('setExceptionHandler', function(callback) { |
| @@ -358,3 +376,4 @@ binding.registerCustomHook(function(api) { |
| }); |
| exports.binding = binding.generate(); |
| + |
|
not at google - send to devlin
2014/07/18 15:09:14
not this
Sam McNally
2014/07/21 03:56:28
Done.
|