DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Untracked file

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
<?xml version="1.0" encoding="UTF-8"?>
<!-- vim: set shiftwidth=4 tabstop=4 autoindent noexpandtab: -->
<!-- ***** BEGIN LICENSE BLOCK *****
   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
   -
   - The contents of this file are subject to the Mozilla Public License Version
   - 1.1 (the "License"); you may not use this file except in compliance with
   - the License. You may obtain a copy of the License at
   - http://www.mozilla.org/MPL/
   -
   - Software distributed under the License is distributed on an "AS IS" basis,
   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
   - for the specific language governing rights and limitations under the
   - License.
   -
   - The Original Code is reftest-analyzer.html.
   -
   - The Initial Developer of the Original Code is the Mozilla Foundation.
   - Portions created by the Initial Developer are Copyright (C) 2008
   - the Initial Developer. All Rights Reserved.
   -
   - Contributor(s):
   -   L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (original author)
   -
   - Alternatively, the contents of this file may be used under the terms of
   - either the GNU General Public License Version 2 or later (the "GPL"), or
   - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
   - in which case the provisions of the GPL or the LGPL are applicable instead
   - of those above. If you wish to allow use of your version of this file only
   - under the terms of either the GPL or the LGPL, and not to allow others to
   - use your version of this file under the terms of the MPL, indicate your
   - decision by deleting the provisions above and replace them with the notice
   - and other provisions required by the LGPL or the GPL. If you do not delete
   - the provisions above, a recipient may use your version of this file under
   - the terms of any one of the MPL, the GPL or the LGPL.
   -
   - ***** END LICENSE BLOCK ***** -->
<!--

Features to add:
* make the left and right parts of the viewer independantly scrollable
* make the test list filterable
** default to only showing unexpecteds
* add other ways to highlight differences other than circling?
* add zoom/pan to images
* Add ability to load log via XMLHttpRequest (also triggered via URL param)
* color the test list based on pass/fail and expected/unexpected/random/skip
* ability to load multiple logs ?
** rename them by clicking on the name and editing
** turn the test list into a collapsing tree view
** move log loading into popup from viewer UI

-->
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Reftest analyzer</title>
	<style type="text/css"><![CDATA[

        #itemlist { width: 300px; }
        #images { position: fixed; top: 10px; left: 310px; }

	form#imgcontrols { margin: 0; display: block; }

	#itemlist > table { border-collapse: collapse; }
	#itemlist > table > tbody > tr > td { border: 1px solid; padding: 1px; }

	/*
	#itemlist > table > tbody > tr.pass > td.url { background: lime; }
	#itemlist > table > tbody > tr.fail > td.url { background: red; }
	*/

	]]></style>
	<script type="text/javascript"><![CDATA[

var XLINK_NS = "http://www.w3.org/1999/xlink";
var SVG_NS = "http://www.w3.org/2000/svg";

var gPhases = null;

var gIDCache = {};

function ID(id) {
	if (!(id in gIDCache))
		gIDCache[id] = document.getElementById(id);
	return gIDCache[id];
}

function load() {
	gPhases = [ ID("entry"), ID("loading"), ID("viewer") ];
}

function show_phase(phaseid) {
	for (var i in gPhases) {
		var phase = gPhases[i];
		phase.style.display = (phase.id == phaseid) ? "" : "none";
	}

	if (phase == "viewer")
		ID("images").style.display = "none";
}

function fileentry_changed() {
	show_phase("loading");
	var input = ID("fileentry");
	var files = input.files;
	var log = null;
	if (files.length > 0) {
		// Only handle the first file; don't handle multiple selection.
		// The parts of the log we care about are ASCII-only.  Since we
		// can ignore lines we don't care about, best to read in as
		// iso-8859-1, which guarantees we don't get decoding errors.
		log = files[0].getAsText("iso-8859-1");
	}
	// So the user can process the same filename again (after
	// overwriting the log), clear the value on the form input so we
	// will always get an onchange event.
	input.value = "";

	if (log)
		process_log(log);
	else
		show_phase("entry");
}

function log_pasted() {
	show_phase("loading");
	var entry = ID("logentry");
	var log = entry.value;
	entry.value = "";
	process_log(log);
}

var gTestItems;

function process_log(contents) {
	var lines = contents.split(/[\r\n]+/);
	gTestItems = [];
	for (var j in lines) {
		var line = lines[j];
		var match = line.match(/^REFTEST (.*)$/);
		if (!match)
			continue;
		line = match[1];
		match = line.match(/^(PASS|UNEXPECTED PASS|KNOWN FAIL|UNEXPECTED FAIL)( \(RESULT EXPECTED TO BE RANDOM\)| \(SKIP\)|): (.*)/);
		if (match) {
			var state = match[1];
			var extra = match[2];
			var url = match[3];
			gTestItems.push(
				{
					pass: !state.match(/FAIL$/),
					// only one of the following three should ever be true
					unexpected: !!state.match(/^UNEXPECTED/),
					random: (extra == " (RESULT EXPECTED TO BE RANDOM)"),
					skip: (extra == " (SKIP)"),
					url: url,
					images: []
				});
			continue;
		}
		match = line.match(/^  IMAGE[^:]*: (.*)$/);
		if (match) {
			var item = gTestItems[gTestItems.length - 1];
			item.images.push(match[1]);
		}
	}

	build_viewer();
}

function build_viewer() {
	if (gTestItems.length == 0) {
		show_phase("entry");
		return;
	}

	var cell = ID("itemlist");
	while (cell.childNodes.length > 0)
		cell.removeChild(cell.childNodes[cell.childNodes.length - 1]);

	var table = document.createElement("table");
	var tbody = document.createElement("tbody");
	table.appendChild(tbody);

	for (var i in gTestItems) {
		var item = gTestItems[i];

		// XXX skip expected pass items until we have filtering UI
		if (item.pass && !item.unexpected)
			continue;

		var tr = document.createElement("tr");
		var rowclass = item.pass ? "pass" : "fail";
		var td;
		var text;

		td = document.createElement("td");
		text = "";
		if (item.unexpected) { text += "!"; rowclass += " unexpected"; }
		if (item.random) { text += "R"; rowclass += " random"; }
		if (item.skip) { text += "S"; rowclass += " skip"; }
		td.appendChild(document.createTextNode(text));
		tr.appendChild(td);

		td = document.createElement("td");
		td.className = "url";
		// Only display part of URL after "/mozilla/".
		var match = item.url.match(/\/mozilla\/(.*)/);
		text = document.createTextNode(match ? match[1] : item.url);
		if (item.images.length > 0) {
			var a = document.createElement("a");
			a.href = "javascript:show_images(" + i + ")";
			a.appendChild(text);
			td.appendChild(a);
		} else {
			td.appendChild(text);
		}
		tr.appendChild(td);

		tbody.appendChild(tr);
	}

	cell.appendChild(table);

	show_phase("viewer");
}

function show_images(i) {
	var item = gTestItems[i];
	var cell = ID("images");

	ID("image1").style.display = "";
	ID("image2").style.display = "none";
	ID("diffrect").style.display = "none";
	ID("imgcontrols").reset();

	ID("image1").setAttributeNS(XLINK_NS, "xlink:href", item.images[0]);
	// Making the href be #image1 doesn't seem to work
	ID("feimage1").setAttributeNS(XLINK_NS, "xlink:href", item.images[0]);
	if (item.images.length == 1) {
		ID("imgcontrols").style.display = "none";
	} else {
		ID("imgcontrols").style.display = "";

		ID("image2").setAttributeNS(XLINK_NS, "xlink:href", item.images[1]);
		// Making the href be #image2 doesn't seem to work
		ID("feimage2").setAttributeNS(XLINK_NS, "xlink:href", item.images[1]);
	}

	cell.style.display = "";
}

function show_image(i) {
	if (i == 1) {
		ID("image1").style.display = "";
		ID("image2").style.display = "none";
	} else {
		ID("image1").style.display = "none";
		ID("image2").style.display = "";
	}
}

function show_differences(cb) {
	ID("diffrect").style.display = cb.checked ? "" : "none";
}

	]]></script>

</head>
<body onload="load()">

<div id="entry">

<h1>Reftest analyzer: load reftest log</h1>

<p>Either paste your log into this textarea:<br />
<textarea cols="80" rows="10" id="logentry" /><br/>
<input type="button" value="Process pasted log" onclick="log_pasted()" /></p>

<p>... or load it from a file:<br/>
<input type="file" id="fileentry" onchange="fileentry_changed()" />
</p>
</div>

<div id="loading" style="display:none">Loading log...</div>

<div id="viewer" style="display:none">
  <div id="itemlist"></div>
  <div id="images" style="display:none">
    <form id="imgcontrols">
    <label><input type="radio" name="which" value="0" onchange="show_image(1)" checked="checked" />Image 1</label>
    <label><input type="radio" name="which" value="1" onchange="show_image(2)" />Image 2</label>
    <label><input type="checkbox" onchange="show_differences(this)" />Circle differences</label>
    </form>
    <svg style="position: absolute; left: 300px; top: 50px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="800px" height="1000px" viewbox="0 0 800 1000" id="svg">
      <defs>
	<filter id="showDifferences" x="0%" y="0%" width="100%" height="100%">
	  <feImage id="feimage1" result="img1" xlink:href="#image1" />
	  <feImage id="feimage2" result="img2" xlink:href="#image2" />
	  <!-- inv1 and inv2 are the images with RGB inverted -->
	  <feComponentTransfer result="inv1" in="img1">
	    <feFuncR type="linear" slope="-1" intercept="1" />
	    <feFuncG type="linear" slope="-1" intercept="1" />
	    <feFuncB type="linear" slope="-1" intercept="1" />
	  </feComponentTransfer>
	  <feComponentTransfer result="inv2" in="img2">
	    <feFuncR type="linear" slope="-1" intercept="1" />
	    <feFuncG type="linear" slope="-1" intercept="1" />
	    <feFuncB type="linear" slope="-1" intercept="1" />
	  </feComponentTransfer>
	  <!-- w1 will have non-white pixels anywhere that img2
	       is brighter than img1, and w2 for the reverse.
	       It would be nice not to have to go through these
	       intermediate states, but feComposite
	       type="arithmetic" can't transform the RGB channels
	       and leave the alpha channel untouched. -->
	  <feComposite result="w1" in="img1" in2="inv2" operator="arithmetic" k2="1" k3="1" />
	  <feComposite result="w2" in="img2" in2="inv1" operator="arithmetic" k2="1" k3="1" />
	  <!-- c1 will have non-black pixels anywhere that img2
	       is brighter than img1, and c2 for the reverse -->
	  <feComponentTransfer result="c1" in="w1">
	    <feFuncR type="linear" slope="-1" intercept="1" />
	    <feFuncG type="linear" slope="-1" intercept="1" />
	    <feFuncB type="linear" slope="-1" intercept="1" />
	  </feComponentTransfer>
	  <feComponentTransfer result="c2" in="w2">
	    <feFuncR type="linear" slope="-1" intercept="1" />
	    <feFuncG type="linear" slope="-1" intercept="1" />
	    <feFuncB type="linear" slope="-1" intercept="1" />
	  </feComponentTransfer>
	  <!-- c will be nonblack (and fully on) for every pixel+component where there are differences -->
	  <feComposite result="c" in="c1" in2="c2" operator="arithmetic" k2="255" k3="255" />
	  <!-- a will be opaque for every pixel with differences and transparent for all others -->
	  <feColorMatrix result="a" type="matrix" values="0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  1 1 1 0 0" />
	  
	  <!-- a, dilated by 4 pixels -->
	  <feMorphology result="dila4" in="a" operator="dilate" radius="4" />
	  <!-- a, dilated by 1 pixel -->
	  <feMorphology result="dila1" in="a" operator="dilate" radius="1" />
	  
	  <!-- all the pixels in the 3-pixel dilation of a but not in the 1-pixel dilation of a, to highlight the diffs -->
	  <feComposite result="highlight" in="dila4" in2="dila1" operator="out" />

	  <feFlood result="red" flood-color="red" />
	  <feComposite result="redhighlight" in="red" in2="highlight" operator="in" />
	  <feFlood result="black" flood-color="black" flood-opacity="0.5" />
	  <feMerge>
	    <feMergeNode in="black" />
	    <feMergeNode in="redhighlight" />
	  </feMerge>
	</filter>
      </defs>
      <image x="0" y="0" width="100%" height="100%" id="image1" />
      <image x="0" y="0" width="100%" height="100%" id="image2" />
      <rect id="diffrect" filter="url(#showDifferences)" x="0" y="0" width="100%" height="100%" />
    </svg>
  </div>
</div>

</body>
</html>