Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions runner/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
<label class="col-sm-3 control-label">Test types to include</label>
<div class="col-sm-9">
<label>
<input type=checkbox checked value="testharness" id='th' class='test-type'>
<input type=checkbox value="testharness" id='th' class='test-type test_types'>
JavaScript tests
</label>
<label>
<input type=checkbox checked value="reftest" id='ref' class='test-type'>
<input type=checkbox value="reftest" id='ref' class='test-type test_types'>
Reftests
</label>
<label>
<input type=checkbox checked value="manual" id='man' class='test-type'>
<input type=checkbox value="manual" id='man' class='test-type test_types'>
Manual tests
</label>
</div>
Expand Down Expand Up @@ -71,6 +71,10 @@
<input type=checkbox id='dumpit'>
Dump JSON
</label>
<label>
<input type=checkbox id='send_query'>
Send query string
</label>
</div>
</div>

Expand All @@ -85,6 +89,7 @@
</div>

<div class="instructions">
<h2>Instructions</h2>
<p>
To run a set of
<a href="https://github.com/w3c/web-platform-tests/blob/master/README.md">web-platform-tests</a>
Expand Down Expand Up @@ -118,6 +123,24 @@
Tests will run in a new window. For reftests and manual tests it’s best
to put that window side-by-side with this one.
</p>
<h2>URL Options</h2>
<p>It is possible to specify most control options via the URL query string. Options for the query string are:</p>
<dl class="options">
<dt>path</dt>
<dd>The folder or subfolders to select from. Multiple values are permitted separated by commas or with multiple instances of the parameter (e.g., <code>path=/2dcontext,/editing</code> or <code>path=/2dcontext&amp;path=/editing</code>)</dd>
<dt>test_types</dt>
<dd>The types of tests to select. Values are "testharness", "reftest", and "manual". Multiple values are permitted as with <code>path</code> above. Defaults to all three.</dd>
<dt>use_regex</dt>
<dd>Boolean. If present then the Use regular expressions option will be selected. Defaults to off.</dd>
<dt>dumpit</dt>
<dd>Boolean. If present then the Dump JSON option will be selected. Defaults to off.</dd>
<dt>render</dt>
<dd>Boolean. If present then the Show output option will be selected. Defaults to off.</dd>
<dt>send_query</dt>
<dd>Boolean. If present then the Send query string option will be selected. Defaults to off.</dd>
<dt>autorun</dt>
<dd>Boolean. If present then the tests matching the selection criteria will be automatically executed. Defaults to off. NOTE: autorun=1 is also permitted for legacy reasons.</dd>
</dl>
</div>

<div id="output">
Expand Down
9 changes: 9 additions & 0 deletions runner/runner.css
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,12 @@ td.ERROR {
background: black;
padding: 8px;
}

dl.options dt {
font: fixed;
font-weight: bold;
}

dl.options dd {
margin-left: 2em;
}
67 changes: 58 additions & 9 deletions runner/runner.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*jshint nonew: false */
/*jshint eqeqeq: false, nonew: false */
(function() {
"use strict";
var runner;
var testharness_properties = {output:false,
send_query:false,
timeout_multiplier:1};

function Manifest(path) {
Expand Down Expand Up @@ -191,7 +192,7 @@ function VisualOutput(elem, runner) {
this.display_filter_state[display_filter_input.value] = display_filter_input.checked;
display_filter_input.addEventListener("change", function(e) {
visual_output.apply_display_filter(e.target.value, e.target.checked);
})
});
}
}

Expand Down Expand Up @@ -328,7 +329,9 @@ VisualOutput.prototype = {
a.href = window.URL.createObjectURL(blob);
a.download = "runner-results.json";
a.textContent = "Download JSON results";
if (!a.getAttribute("download")) a.textContent += " (right-click and save as to download)";
if (!a.getAttribute("download")) {
a.textContent += " (right-click and save as to download)";
}
a.style.display = "inline";
},

Expand Down Expand Up @@ -361,7 +364,7 @@ VisualOutput.prototype = {
this.display_filter_state[test_status] = display_state;
var result_cells = this.elem.querySelectorAll(".results > table tr td." + test_status);
for (var i = 0; i < result_cells.length; ++i) {
this.apply_display_filter_to_result_row(result_cells[i].parentNode, display_state)
this.apply_display_filter_to_result_row(result_cells[i].parentNode, display_state);
}
},

Expand Down Expand Up @@ -474,6 +477,7 @@ function TestControl(elem, runner) {
}.bind(this));
this.timeout_input = this.elem.querySelector(".timeout_multiplier");
this.render_checkbox = this.elem.querySelector(".render");
this.send_query_checkbox = this.elem.querySelector("#send_query");
this.runner = runner;
this.runner.done_callbacks.push(this.on_done.bind(this));
this.set_start();
Expand Down Expand Up @@ -544,6 +548,7 @@ TestControl.prototype = {

get_testharness_settings: function() {
return {timeout_multiplier: parseFloat(this.timeout_input.value),
send_query: this.send_query_checkbox.checked,
output: this.render_checkbox.checked};
},

Expand Down Expand Up @@ -598,6 +603,7 @@ Results.prototype = {

function Runner(manifest_path) {
this.server = location.protocol + "//" + location.host;
this.query_string = location.search;
this.manifest = new Manifest(manifest_path);
this.path = null;
this.test_types = null;
Expand Down Expand Up @@ -679,7 +685,7 @@ Runner.prototype = {
if (this.test_types.length < 3) {
tests = this.test_types.join(" tests or ") + " tests";
}
var message = "No " + tests + " found in this path."
var message = "No " + tests + " found in this path.";
document.querySelector(".path").setCustomValidity(message);
this.done();
}
Expand Down Expand Up @@ -748,6 +754,9 @@ Runner.prototype = {
if (this.test_window.location === null) {
this.open_test_window();
}
if (window.testharness_properties.send_query) {
path += this.query_string;
}
this.test_window.location.href = this.server + path;
},

Expand All @@ -767,32 +776,72 @@ Runner.prototype = {

function parseOptions() {
var options = {
test_types: ["testharness", "reftest", "manual"]
test_types: []
};

var optionstrings = location.search.substring(1).split("&");
for (var i = 0, il = optionstrings.length; i < il; ++i) {
var opt = optionstrings[i];
//TODO: fix this for complex-valued options
options[opt.substring(0, opt.indexOf("="))] =
opt.substring(opt.indexOf("=") + 1);
if (opt.indexOf("=") !== -1) {
var name = opt.substring(0, opt.indexOf("="));
var val = opt.substring(opt.indexOf("=")+1) ;
if (options[name] && Array.isArray(options[name])) {
if (val.indexOf(',') !== -1) {
val.split(",").forEach(function(l) {
options[name].push(l);
});
} else {
options[name].push(val);
}
} else if (options[name]) {
options[name] += "," + val;
} else {
options[name] = val;
}
} else {
options[opt] = true;
}
}

if (options.test_types.length === 0) {
options.test_types = ["testharness", "reftest", "manual"];
}

return options;
}

function setup() {
var options = parseOptions();


if (options.path) {
document.getElementById('path').value = options.path;
}
var setupOptions = [ 'test_types', 'send_query', 'dumpit', 'use_regex', 'render' ];
setupOptions.forEach(function(v) {
if (options[v]) {
if (Array.isArray(options[v])) {
// the item is an array so the name is a class
options[v].forEach(function(cv) {
var sel = "."+v+"[value="+cv+"]";
var ref = document.querySelector(sel);
if (ref) {
ref.checked = true;
}
});
} else {
document.getElementById(v).checked = true;
}
}
});

runner = new Runner("/MANIFEST.json", options);
var test_control = new TestControl(document.getElementById("testControl"), runner);
new ManualUI(document.getElementById("manualUI"), runner);
new VisualOutput(document.getElementById("output"), runner);

if (options.autorun === "1") {
if (options.autorun || options.autorun === "1") {
runner.start(test_control.get_path(),
test_control.get_test_types(),
test_control.get_testharness_settings(),
Expand Down