1 // Copyright (c) 2013 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. 4 5 function addTests() { 6 common.tester.addAsyncTest('get_url', function(test) { 7 test.log('Clicking the button'); 8 document.getElementById('button').dispatchEvent(new MouseEvent('click')); 9 10 var outputEl = document.getElementById('output'); 11 outputEl.textContent = ''; 12 13 test.log('Waiting for the URL to load.'); 14 var intervalId = window.setInterval(function() { 15 if (!outputEl.textContent) 16 return; 17 18 window.clearInterval(intervalId); 19 test.log('Output box changed...'); 20 var expectedMessage = 'part of the test output'; 21 if (outputEl.textContent.indexOf(expectedMessage) === -1) { 22 test.fail('Expected to find "' + expectedMessage + '" in the output,' + 23 'instead got "' + outputEl.textContent + '"'); 24 return; 25 } else { 26 test.log('OK, found "' + expectedMessage + '".'); 27 } 28 29 test.pass(); 30 }, 100); 31 }); 32 } 33