Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup test.js and test/index.html.

  • Loading branch information...
commit 63c5cb6eae6baf5b082dc809dbe847bd6e0cb4d6 1 parent 985bdb6
@jdalton jdalton authored
Showing with 28 additions and 20 deletions.
  1. +21 −13 test/index.html
  2. +7 −7 test/test.js
View
34 test/index.html
@@ -34,11 +34,6 @@
}
}());
- // load the nanosecond timer
- if (!/[?&]nojava=true(?:&|$)/.test(location.search)) {
- document.write('<applet code="nano" archive="../nano.jar"></applet>');
- }
-
// avoid syntax errors for `QUnit.throws` in older Firefoxes
document.write(platform.name == 'Firefox' && /^1\b/.test(platform.version)
? '<script src="../vendor/qunit/qunit/qunit-1.8.0.js"><\/script>'
@@ -46,11 +41,18 @@
);
</script>
<script>
- // load test.js if not using require.js
- document.write(/[?&]norequire=true(?:&|$)/.test(location.search)
- ? '<script src="test.js"><\/script>'
- : '<script src="../vendor/requirejs/require.js"><\/script>'
- );
+ // populate `QUnit.urlParams`
+ QUnit.urlParams.nojava = /[?&]nojava=true(?:&|$)/.test(location.search);
+ QUnit.urlParams.norequire = /[?&]norequire=true(?:&|$)/.test(location.search);
+
+ // load the nanosecond timer
+ if (!QUnit.urlParams.nojava) {
+ document.write('<applet code="nano" archive="../nano.jar"></applet>');
+ }
+ // load require.js
+ if (!QUnit.urlParams.norequire) {
+ document.write('<script src="../vendor/requirejs/require.js"><\/script>');
+ }
</script>
<script>
// load Benchmark as a module
@@ -67,16 +69,22 @@
['benchmark', 'platform'], function(Benchmark, platform) {
Benchmark2 = Benchmark;
Benchmark2.platform = platform;
- require(['test.js']);
});
- // set a more readable browser name
window.onload = function() {
var timeoutId = setInterval(function() {
var ua = document.getElementById('qunit-userAgent');
- if (ua) {
+ if (ua && (Benchmark2 || !window.require)) {
+ var sibling = document.getElementsByTagName('script')[0],
+ script = document.createElement('script');
+
+ // set a more readable browser name
ua.innerHTML = platform;
clearInterval(timeoutId);
+
+ // load test.js
+ script.src = 'test.js?t=' + (+new Date);
+ sibling.parentNode.insertBefore(script, sibling);
}
}, 15);
};
View
14 test/test.js
@@ -95,7 +95,7 @@
if (window.document) {
equal(String(Benchmark.platform), navigator.userAgent);
} else {
- skipTest(1)
+ skipTest(1);
}
});
@@ -103,7 +103,7 @@
if (window.document && window.require) {
equal((Benchmark2 || {}).version, Benchmark.version);
} else {
- skipTest(1)
+ skipTest(1);
}
});
@@ -112,7 +112,7 @@
var platform = (Benchmark2 || {}).platform || {};
equal(typeof platform.name, 'string');
} else {
- skipTest(1)
+ skipTest(1);
}
});
}());
@@ -372,7 +372,7 @@
var clone = Benchmark.deepClone(object);
ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object);
} else {
- skipTest(1)
+ skipTest(1);
}
});
@@ -384,7 +384,7 @@
var clone = Benchmark.deepClone(object);
ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object);
} else {
- skipTest(1)
+ skipTest(1);
}
});
@@ -396,7 +396,7 @@
var clone = Benchmark.deepClone(object);
ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object);
} else {
- skipTest(1)
+ skipTest(1);
}
});
@@ -436,7 +436,7 @@
!(descriptor.configurable && descriptor.enumerable && descriptor.writable));
}
else {
- skipTest(1)
+ skipTest(1);
}
});
}());
Please sign in to comment.
Something went wrong with that request. Please try again.