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 chrome.test.getConfig(function(config) {
6 runAllTests('http://www.test.com:' + config.testServer.port);
9 function runAllTests(testServerUrl) {
10 chrome.test.runTests([
11 function dumpLogsTest() {
12 chrome.logPrivate.dumpLogs(function(fileEntry) {
13 if (!fileEntry.name.match(/\.tar\.gz$/g)) {
14 chrome.test.fail('Invalid file type: '+ fileEntry.name);
18 fileEntry.file(function(file) {
19 var reader = new FileReader();
20 reader.onloadend = function(e) {
21 if (this.result.byteLength > 0)
22 chrome.test.succeed();
24 chrome.test.fail('Invalid log file content');
26 reader.readAsArrayBuffer(file);
29 chrome.test.fail('File reading error');
33 function captureNetworkEvents() {
34 chrome.logPrivate.onCapturedEvents.addListener(function(entries) {
35 for (var i = 0; i < entries.length; i++) {
36 // Find our XHR request from below:
37 if (entries[i].params && entries[i].params.url &&
38 entries[i].params.url.match(/www\.test\.com/g)) {
39 chrome.logPrivate.stopEventRecorder('network', function() {
40 chrome.test.succeed();
45 chrome.logPrivate.startEventRecorder('network', 'capture', function() {
46 var req = new XMLHttpRequest();
47 req.onreadystatechange = function() {}
48 req.open('GET', testServerUrl, true);