2 * Copyright (C) 2012 Purdue University
3 * Written by Gregor Richards
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
29 /* This kind of test is very difficult to generalize, so we just avoid
30 * browsers known not to work */
39 /* Since Chrome doesn't use the same JS engine as WebKit, it actually has
40 * different dependencies */
41 var rchrome = /Chrome[\/]([\w.]+)/;
42 var match = rchrome.exec(navigator.userAgent);
44 delete $.browser.webkit;
46 $.browser.version = match[1];
53 "msie": "Microsoft Internet Explorer",
58 "mozilla": "2.0 (e.g. Firefox 4.0)"
61 var real = "harness.html";
63 // version-number-based comparison
64 function versionCheck(min, real) {
65 var minComps = min.split(".");
66 var realComps = real.split(".");
67 while (realComps.length < minComps.length) realComps.push("0");
69 for (var i = 0; i < minComps.length; i++) {
70 var min = parseInt(minComps[i]);
71 var real = parseInt(realComps[i]);
72 if (real < min) return false;
73 else if (real > min) return true;
79 // test the browser version
80 window.onload = function() {
81 var badBrowser = false;
84 for (var browser in browserMin) {
85 var version = browserMin[browser];
86 if ($.browser[browser]) {
87 if (!versionCheck(version, $.browser.version)) {
89 goodVersion = version;
90 if (badBrowser in versionName) goodVersion = versionName[badBrowser];
91 badVersion = $.browser.version;
96 var output = document.getElementById("output");
98 // we don't like your browser
100 "Sorry, but your browser is not supported. The minimum version of <b>" +
101 browserName[badBrowser] +
102 "</b> required to run these benchmarks is <b>" +
104 "</b> (You are using <b>" +
106 "</b>). If you would like to attempt to run them anyway, <a href=\"" +
108 "\">click here</a>, but it is highly likely that they will not " +
109 "run, and if they do, the results may be unreliable.";
113 "Loading benchmarks ...";
114 window.location.href = real;