OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 /** |
| 6 * @fileoverview Helper functions for use in tracing tests. |
| 7 */ |
| 8 cr.define('test_utils', function() { |
| 9 function getJSON(url, cb) { |
| 10 var req = new XMLHttpRequest(); |
| 11 req.open('GET', url, true); |
| 12 req.onreadystatechange = function(aEvt) { |
| 13 if (req.readyState == 4) { |
| 14 window.setTimeout(function() { |
| 15 if (req.status == 200) { |
| 16 var resp = JSON.parse(req.responseText); |
| 17 if (resp.traceEvents) |
| 18 cb(resp.traceEvents); |
| 19 else |
| 20 cb(resp); |
| 21 } else { |
| 22 console.log('Failed to load ' + url); |
| 23 } |
| 24 }, 0); |
| 25 } |
| 26 }; |
| 27 req.send(null); |
| 28 } |
| 29 return { |
| 30 getJSON: getJSON |
| 31 }; |
| 32 }); |
OLD | NEW |