|
1 |
| -;(function(root) { |
2 |
| - 'use strict'; |
| 1 | +;(function() { |
| 2 | + |
| 3 | + /** Used as a safe reference for `undefined` in pre ES5 environments */ |
| 4 | + var undefined; |
| 5 | + |
| 6 | + /** Used as a reference to the global object */ |
| 7 | + var root = typeof global == 'object' && global || this; |
| 8 | + |
| 9 | + /** Method and object shortcuts */ |
| 10 | + var phantom = root.phantom, |
| 11 | + amd = root.define && define.amd, |
| 12 | + document = !phantom && root.document, |
| 13 | + hasOwnProperty = Object.prototype.hasOwnProperty, |
| 14 | + noop = function() {}; |
| 15 | + |
| 16 | + /** Detect if running in Java */ |
| 17 | + var isJava = !document && !!root.java; |
3 | 18 |
|
4 | 19 | /** Use a single "load" function */
|
5 |
| - var load = typeof require == 'function' ? require : root.load; |
| 20 | + var load = (typeof require == 'function' && !amd) |
| 21 | + ? require |
| 22 | + : (isJava && root.load) || noop; |
6 | 23 |
|
7 | 24 | /** The unit testing framework */
|
8 | 25 | var QUnit = (function() {
|
9 |
| - var noop = Function.prototype; |
10 | 26 | return root.QUnit || (
|
11 | 27 | root.addEventListener || (root.addEventListener = noop),
|
12 | 28 | root.setTimeout || (root.setTimeout = noop),
|
13 | 29 | root.QUnit = load('../vendor/qunit/qunit/qunit.js') || root.QUnit,
|
14 |
| - (load('../vendor/qunit-extras/qunit-extras.js') || { 'runInContext': noop }).runInContext(root), |
15 | 30 | addEventListener === noop && delete root.addEventListener,
|
16 | 31 | root.QUnit
|
17 | 32 | );
|
18 | 33 | }());
|
19 | 34 |
|
| 35 | + /** Load and install QUnit Extras */ |
| 36 | + var qa = load('../vendor/qunit-extras/qunit-extras.js'); |
| 37 | + if (qa) { |
| 38 | + qa.runInContext(root); |
| 39 | + } |
| 40 | + |
20 | 41 | /** The `platform` object to check */
|
21 | 42 | var platform = root.platform || (root.platform =
|
22 | 43 | load('../platform.js') ||
|
23 | 44 | root.platform
|
24 | 45 | );
|
25 | 46 |
|
26 |
| - /** Shortcut used to check for own properties of objects */ |
27 |
| - var hasOwnProperty = Object.prototype.hasOwnProperty; |
28 |
| - |
29 | 47 | /*--------------------------------------------------------------------------*/
|
30 | 48 |
|
31 | 49 | /**
|
|
1890 | 1908 | });
|
1891 | 1909 |
|
1892 | 1910 | test('supports loading Platform.js as a module', function() {
|
1893 |
| - if (root.define && define.amd) { |
1894 |
| - equal((platform2 || {}).description, platform.description); |
| 1911 | + if (amd) { |
| 1912 | + equal((platformModule || {}).description, platform.description); |
1895 | 1913 | } else {
|
1896 | 1914 | ok(true, 'test skipped');
|
1897 | 1915 | }
|
|
2022 | 2040 |
|
2023 | 2041 | /*--------------------------------------------------------------------------*/
|
2024 | 2042 |
|
2025 |
| - if (!root.document || root.phantom) { |
| 2043 | + if (!document) { |
2026 | 2044 | QUnit.config.noglobals = true;
|
2027 | 2045 | QUnit.start();
|
2028 | 2046 | }
|
2029 |
| -}(typeof global == 'object' && global || this)); |
| 2047 | +}.call(this)); |
0 commit comments