Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / extensions / test / data / unit_test_environment_specific_bindings.js
blob245d050d6325400bc5c7722c790620dc9a8d83aa
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
3 // found in the LICENSE file.
5 var nativesPromise = requireAsync('testNatives');
7 function registerHooks(api) {
8   var chromeTest = api.compiledApi;
9   var apiFunctions = api.apiFunctions;
11   apiFunctions.setHandleRequest('notifyPass', function() {
12     nativesPromise.then(function(natives) {
13       natives.NotifyPass();
14     });
15   });
17   apiFunctions.setHandleRequest('notifyFail', function(message) {
18     nativesPromise.then(function(natives) {
19       natives.NotifyFail(message);
20     });
21   });
23   apiFunctions.setHandleRequest('log', function() {
24     nativesPromise.then(function(natives) {
25       natives.Log($Array.join(arguments, ' '));
26     });
27   });
31 function testDone(runNextTest) {
32     // Use a promise here to allow previous test contexts to be eligible for
33     // garbage collection.
34     Promise.resolve().then(function() {
35       runNextTest();
36     });
39 function exportTests(tests, runTests, exports) {
40   $Array.forEach(tests, function(test) {
41     exports[test.name] = function() {
42       runTests([test]);
43       return true;
44     }
45   });
48 exports.registerHooks = registerHooks;
49 exports.testDone = testDone;
50 exports.exportTests = exportTests;