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.
6 var currentTest = null;
8 function dispatchClick(id) {
9 currentTest.log('Clicking button "' + id + '".');
10 $(id).dispatchEvent(new MouseEvent('click'));
13 function setInputValue(id, value) {
14 currentTest.log('Setting input box "' + id + '" to "' + value + '".');
18 function clearResult() {
19 $('result').textContent = '';
22 function getResult() {
23 return $('result').textContent;
26 function waitForResult(expected) {
27 var intervalId = window.setInterval(function() {
28 var actual = parseInt(getResult());
31 currentTest.log('No result yet, waiting.');
36 window.clearInterval(intervalId);
38 if (actual === expected) {
39 currentTest.log('Got expected value (' + expected + ').');
42 currentTest.fail('Unexpected value ' + actual + ', expected ' +
48 common.tester.addAsyncTest('async_message', function(test) {
51 setInputValue('addend1', 1234);
52 setInputValue('addend2', 2345);
53 dispatchClick('addAsync');
57 common.tester.addAsyncTest('sync_message', function(test) {
60 setInputValue('addend1', 42);
61 setInputValue('addend2', 314);
62 dispatchClick('addSync');