Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: build/android/pylib/results/presentation/javascript/main_html.js

Issue 2799153008: Add back buttons and load new 'pages' by calling javascript. (Closed)
Patch Set: remove url manipulation so that we can refresh Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/pylib/results/presentation/template/main.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function getArguments() { 5 function getArguments() {
6 // Returns the URL arguments as a dictionary. 6 // Returns the URL arguments as a dictionary.
7 args = {} 7 args = {}
8 var s = location.search; 8 var s = location.search;
9 if (s) { 9 if (s) {
10 var vals = s.substring(1).split('&'); 10 var vals = s.substring(1).split('&');
11 for (var i = 0; i < vals.length; i++) { 11 for (var i = 0; i < vals.length; i++) {
12 var pair = vals[i].split('='); 12 var pair = vals[i].split('=');
13 args[pair[0]] = pair[1]; 13 args[pair[0]] = pair[1];
14 } 14 }
15 } 15 }
16 return args; 16 return args;
17 } 17 }
18 18
19 function showSuiteTable(show_the_table) { 19 function showSuiteTable(show_the_table) {
20 document.getElementById('suite-table').style.display = ( 20 document.getElementById('suite-table').style.display = (
21 show_the_table ? 'table' : 'none'); 21 show_the_table ? 'table' : 'none');
22 } 22 }
23 23
24 function showTestTable(show_the_table) { 24 function showTestTable(show_the_table) {
25 document.getElementById('test-table').style.display = ( 25 document.getElementById('test-table').style.display = (
26 show_the_table ? 'table' : 'none'); 26 show_the_table ? 'table' : 'none');
27 } 27 }
28 28
29 function showTestsOfOneSuiteOnly(suite_name) { 29 function showTestsOfOneSuiteOnly(suite_name, push_state) {
30 setTitle('Test Results of Suite: ' + suite_name) 30 setTitle('Test Results of Suite: ' + suite_name)
31 show_all = (suite_name == 'TOTAL') 31 show_all = (suite_name == 'TOTAL')
32 var testTableBlocks = document.getElementById('test-table') 32 var testTableBlocks = document.getElementById('test-table')
33 .getElementsByClassName('row_block'); 33 .getElementsByClassName('row_block');
34 Array.prototype.slice.call(testTableBlocks) 34 Array.prototype.slice.call(testTableBlocks)
35 .forEach(function(testTableBlock) { 35 .forEach(function(testTableBlock) {
36 if (!show_all) { 36 if (!show_all) {
37 var table_block_in_suite = (testTableBlock.firstElementChild 37 var table_block_in_suite = (testTableBlock.firstElementChild
38 .firstElementChild.firstElementChild.innerHTML) 38 .firstElementChild.firstElementChild.innerHTML)
39 .startsWith(suite_name); 39 .startsWith(suite_name);
40 if (!table_block_in_suite) { 40 if (!table_block_in_suite) {
41 testTableBlock.style.display = 'none'; 41 testTableBlock.style.display = 'none';
42 return; 42 return;
43 } 43 }
44 } 44 }
45 testTableBlock.style.display = 'table-row-group'; 45 testTableBlock.style.display = 'table-row-group';
46 }); 46 });
47 showTestTable(true); 47 showTestTable(true);
48 showSuiteTable(false); 48 showSuiteTable(false);
49 window.scrollTo(0, 0);
jbudorick 2017/04/11 17:52:47 Why are we now scrolling to the top?
BigBossZhiling 2017/04/11 18:37:51 Acknowledged.
50 if (push_state) {
jbudorick 2017/04/11 17:52:47 Should this & replace_state be in these two functi
BigBossZhiling 2017/04/11 18:37:51 Done.
51 history.pushState({suite: suite_name}, suite_name, '');
52 }
49 } 53 }
50 54
51 function showSuiteTableOnly() { 55 function showSuiteTableOnly(replace_state) {
52 setTitle('Suites Summary') 56 setTitle('Suites Summary')
53 showTestTable(false); 57 showTestTable(false);
54 showSuiteTable(true); 58 showSuiteTable(true);
59 window.scrollTo(0, 0);
60 if (replace_state) {
61 history.replaceState({}, 'suite_table', '');
62 }
63 }
64
65 function setBrowserBackButtonLogic() {
66 window.onpopstate = function(event) {
67 if (!event.state || !event.state.suite) {
68 showSuiteTableOnly(false);
69 } else {
70 showTestsOfOneSuiteOnly(event.state.suite, false);
71 }
72 };
55 } 73 }
56 74
57 function setTitle(title) { 75 function setTitle(title) {
58 document.getElementById('summary-header').textContent = title; 76 document.getElementById('summary-header').textContent = title;
59 } 77 }
60 78
61 function sortByColumn(head) { 79 function sortByColumn(head) {
62 var table = head.parentNode.parentNode.parentNode; 80 var table = head.parentNode.parentNode.parentNode;
63 var rowBlocks = Array.prototype.slice.call( 81 var rowBlocks = Array.prototype.slice.call(
64 table.getElementsByTagName('tbody')); 82 table.getElementsByTagName('tbody'));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 (b_rows.length - b_success_or_skipped) / btotal_minus_skipped); 177 (b_rows.length - b_success_or_skipped) / btotal_minus_skipped);
160 } 178 }
161 return asc * (avalue - bvalue); 179 return asc * (avalue - bvalue);
162 }); 180 });
163 181
164 for (var i = 0; i < rowBlocks.length; i++) { 182 for (var i = 0; i < rowBlocks.length; i++) {
165 table.appendChild(rowBlocks[i]); 183 table.appendChild(rowBlocks[i]);
166 } 184 }
167 } 185 }
168 186
169 function loadPage() {
170 var args = getArguments();
171 if ('suite' in args) {
172 // The user wants to visit detailed 'subpage' of that suite.
173 showTestsOfOneSuiteOnly(args['suite']);
174 } else {
175 // The user wants to visit the summary of all suites.
176 showSuiteTableOnly();
177 }
178 }
179
180 function reportIssues() { 187 function reportIssues() {
181 var url = 'https://bugs.chromium.org/p/chromium/issues/entry?' + 188 var url = 'https://bugs.chromium.org/p/chromium/issues/entry?' +
182 'labels=Pri-2,Type-Bug,Restrict-View-Google&' + 189 'labels=Pri-2,Type-Bug,Restrict-View-Google&' +
183 'summary=Result Details Feedback:&' + 190 'summary=Result Details Feedback:&' +
184 'comment=Please check out: ' + window.location; 191 'comment=Please check out: ' + window.location;
185 var newWindow = window.open(url, '_blank'); 192 var newWindow = window.open(url, '_blank');
186 newWindow.focus(); 193 newWindow.focus();
187 } 194 }
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/results/presentation/template/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698