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.
5 document
.title
= 'page cycler';
7 // The __pages is assumed an array which containing the directories for
8 // various pages to exercise. Some page cycler tests don't have this variable.
11 var hasVariablePages
= (typeof __pages
!= 'undefined') &&
12 (__pages
instanceof Array
);
14 initialPage
= __pages
[0];
16 document
.cookie
= '__navigated_to_report=0; path=/';
17 document
.cookie
= '__pc_done=0; path=/';
19 document
.cookie
= '__pc_pages=' + __pages
+ '; path=/';
20 document
.cookie
= '__pc_timings=; path=/';
22 var options
= location
.search
.substring(1).split('&');
24 function getopt(name
) {
25 var r
= new RegExp('^' + name
+ '=');
26 for (var i
= 0; i
< options
.length
; ++i
) {
27 if (options
[i
].match(r
)) {
28 return options
[i
].substring(name
.length
+ 1);
35 var iterations
= document
.getElementById('iterations').value
;
36 window
.resizeTo(800, 800);
37 var ts
= (new Date()).getTime();
40 url
= initialPage
+ '/';
41 url
+= 'index.html?n=' + iterations
+ '&i=0&p=0&ts=' + ts
+ '&td=0';
42 window
.location
= url
;
45 function render_form() {
46 var form
= document
.createElement('FORM');
47 form
.onsubmit = function(e
) {
52 var label
= document
.createTextNode('Iterations: ');
53 form
.appendChild(label
);
55 var input
= document
.createElement('INPUT');
56 input
.setAttribute('id', 'iterations');
57 input
.setAttribute('type', 'number');
58 var iterations
= getopt('iterations');
59 input
.setAttribute('value', iterations
? iterations
: '5');
60 form
.appendChild(input
);
62 input
= document
.createElement('INPUT');
63 input
.setAttribute('type', 'submit');
64 input
.setAttribute('value', 'Start');
65 form
.appendChild(input
);
67 document
.body
.appendChild(form
);
72 // should we start automatically?
73 if (location
.search
.match('auto=1')) {
77 document
.write('<h3 style=\'color:red\'>WARNING: window.gc is not ' +
78 'defined. Test results may be unreliable! You must ' +
79 'started chrome also with <tt>--js-flags=\"--expose_gc\"' +
80 '</tt> for this test to work manually</h3>');