Skip to content

Commit

Permalink
Merge pull request #803 from w3c/dump-json
Browse files Browse the repository at this point in the history
add option to just dump JSON to a textarea
  • Loading branch information
jgraham committed Mar 26, 2014
2 parents e3e1838 + 44924dd commit 3c0abe6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
12 changes: 9 additions & 3 deletions tools/runner/index.html
Expand Up @@ -54,19 +54,19 @@ <h2 class='panel-title'>Runner Options</h2>
<div class="form-group">
<label for="th" class="col-sm-3 control-label">JavaScript tests</label>
<div class="col-sm-9">
<input type=checkbox checked value="testharness" id='th'>
<input type=checkbox checked value="testharness" id='th' class='test-type'>
</div>
</div>
<div class="form-group">
<label for="ref" class="col-sm-3 control-label">Reference tests</label>
<div class="col-sm-9">
<input type=checkbox checked value="reftest" id='ref'>
<input type=checkbox checked value="reftest" id='ref' class='test-type'>
</div>
</div>
<div class="form-group">
<label for="man" class="col-sm-3 control-label">Manual tests</label>
<div class="col-sm-9">
<input type=checkbox checked value="manual" id='man'>
<input type=checkbox checked value="manual" id='man' class='test-type'>
</div>
</div>
<div class="form-group">
Expand All @@ -75,6 +75,12 @@ <h2 class='panel-title'>Runner Options</h2>
<input value="/" id='path' class='path form-control' disabled>
</div>
</div>
<div class="form-group">
<label for="dumpit" class="col-sm-3 control-label">Dump JSON (debug)</label>
<div class="col-sm-9">
<input type=checkbox id='dumpit'>
</div>
</div>
<div class="form-group" style='padding-top: 20px'>
<div class="col-sm-offset-3 col-sm-9">
<button type="button" class="btn btn-success toggleStart" disabled>Start</button>
Expand Down
16 changes: 14 additions & 2 deletions tools/runner/runner.js
Expand Up @@ -190,7 +190,19 @@ VisualOutput.prototype = {
this.meter.classList.remove("progress-striped", "active");
//add the json serialization of the results
var a = this.elem.querySelector(".jsonResults");
var blob = new Blob([this.runner.results.to_json()], { type: "application/json" });
var json = this.runner.results.to_json();
var ta = this.elem.querySelector("textarea");
if (ta) {
ta.parentNode.removeChild(ta);
}
if (document.getElementById("dumpit").checked) {
ta = document.createElement("textarea");
ta.style.width = "100%";
ta.setAttribute("rows", "50");
this.elem.appendChild(ta);
ta.textContent = json;
}
var blob = new Blob([json], { type: "application/json" });
a.href = window.URL.createObjectURL(blob);
a.download = "runner-results.json";
a.textContent = "Download JSON results";
Expand Down Expand Up @@ -309,7 +321,7 @@ function TestControl(elem, runner) {
this.pause_button = this.elem.querySelector("button.togglePause");
this.start_button = this.elem.querySelector("button.toggleStart");
this.type_checkboxes = Array.prototype.slice.call(
this.elem.querySelectorAll("input[type=checkbox]"));
this.elem.querySelectorAll("input[type=checkbox].test-type"));
this.runner = runner;
this.runner.done_callbacks.push(this.on_done.bind(this));
this.set_start();
Expand Down

0 comments on commit 3c0abe6

Please sign in to comment.