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 nativesPromise = requireAsync('testNatives'); | |
6 var sendRequestNatives = requireNative('sendRequest'); | 5 var sendRequestNatives = requireNative('sendRequest'); |
7 | 6 |
8 function registerHooks(api) { | 7 function registerHooks(api) { |
9 var chromeTest = api.compiledApi; | 8 var chromeTest = api.compiledApi; |
10 var apiFunctions = api.apiFunctions; | 9 var apiFunctions = api.apiFunctions; |
11 | 10 |
12 apiFunctions.setHandleRequest('notifyPass', function() { | 11 apiFunctions.setHandleRequest('notifyPass', function() { |
13 nativesPromise.then(function(natives) { | 12 requireAsync('testNatives').then(function(natives) { |
14 natives.NotifyPass(); | 13 natives.NotifyPass(); |
15 }); | 14 }); |
16 }); | 15 }); |
17 | 16 |
18 apiFunctions.setHandleRequest('notifyFail', function(message) { | 17 apiFunctions.setHandleRequest('notifyFail', function(message) { |
19 nativesPromise.then(function(natives) { | 18 requireAsync('testNatives').then(function(natives) { |
20 natives.NotifyFail(message); | 19 natives.NotifyFail(message); |
21 }); | 20 }); |
22 }); | 21 }); |
23 | 22 |
24 apiFunctions.setHandleRequest('log', function() { | 23 apiFunctions.setHandleRequest('log', function() { |
25 nativesPromise.then(function(natives) { | 24 requireAsync('testNatives').then(function(natives) { |
26 natives.Log($Array.join(arguments, ' ')); | 25 natives.Log($Array.join(arguments, ' ')); |
27 }); | 26 }); |
28 }); | 27 }); |
29 | 28 |
30 } | 29 } |
31 | 30 |
32 function testDone(runNextTest) { | 31 function testDone(runNextTest) { |
33 // Use a promise here to allow previous test contexts to be eligible for | 32 // Use a promise here to allow previous test contexts to be eligible for |
34 // garbage collection. | 33 // garbage collection. |
35 Promise.resolve().then(function() { | 34 Promise.resolve().then(function() { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 */ | 137 */ |
139 TimeoutManager.prototype.clearTimeout_ = function(timeoutId) { | 138 TimeoutManager.prototype.clearTimeout_ = function(timeoutId) { |
140 if (this.timeouts_[timeoutId]) | 139 if (this.timeouts_[timeoutId]) |
141 delete this.timeouts_[timeoutId]; | 140 delete this.timeouts_[timeoutId]; |
142 }; | 141 }; |
143 | 142 |
144 exports.registerHooks = registerHooks; | 143 exports.registerHooks = registerHooks; |
145 exports.testDone = testDone; | 144 exports.testDone = testDone; |
146 exports.exportTests = exportTests; | 145 exports.exportTests = exportTests; |
147 exports.TimeoutManager = TimeoutManager; | 146 exports.TimeoutManager = TimeoutManager; |
OLD | NEW |