// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. /** * This view displays the progress and results from the "connection tester". * * - Has an input box to specify the URL. * - Has a button to start running the tests. * - Shows the set of experiments that have been run so far, and their * result. */ var TestView = (function() { 'use strict'; // We inherit from DivView. var superClass = DivView; /** * @constructor */ function TestView() { assertFirstConstructorCall(TestView); // Call superclass's constructor. superClass.call(this, TestView.MAIN_BOX_ID); this.urlInput_ = $(TestView.URL_INPUT_ID); this.summaryDiv_ = $(TestView.SUMMARY_DIV_ID); var form = $(TestView.FORM_ID); form.addEventListener('submit', this.onSubmitForm_.bind(this), false); // Register to test information as it's received. g_browser.addConnectionTestsObserver(this); } // ID for special HTML element in category_tabs.html TestView.TAB_HANDLE_ID = 'tab-handle-tests'; // IDs for special HTML elements in test_view.html TestView.MAIN_BOX_ID = 'test-view-tab-content'; TestView.FORM_ID = 'test-view-connection-tests-form'; TestView.URL_INPUT_ID = 'test-view-url-input'; TestView.SUMMARY_DIV_ID = 'test-view-summary'; // Needed by tests. TestView.SUBMIT_BUTTON_ID = 'test-view-connection-tests-submit'; cr.addSingletonGetter(TestView); TestView.prototype = { // Inherit the superclass's methods. __proto__: superClass.prototype, onSubmitForm_: function(event) { g_browser.sendStartConnectionTests(this.urlInput_.value); event.preventDefault(); }, /** * Callback for when the connection tests have begun. */ onStartedConnectionTestSuite: function() { this.summaryDiv_.innerHTML = ''; var p = addNode(this.summaryDiv_, 'p'); addTextNode(p, 'Started connection test suite suite on '); timeutil.addNodeWithDate(p, new Date()); // Add a table that will hold the individual test results. var table = addNode(this.summaryDiv_, 'table'); table.className = 'styled-table'; var thead = addNode(table, 'thead'); thead.innerHTML = '