df0d11759c77527951e8c143aabe81d4a0e9a26c
[motion.git] / public / bower_components / lodash / test / index.html
1 <!doctype html>
2 <html lang="en">
3   <head>
4     <meta charset="utf-8">
5     <title>lodash Test Suite</title>
6     <link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
7     <style>
8       #exports, #module {
9         display: none;
10       }
11     </style>
12   </head>
13   <body>
14     <script>
15       // Avoid reporting tests to Sauce Labs when script errors occur.
16       if (location.port == '9001') {
17         window.onerror = function(message) {
18           if (window.QUnit) {
19             QUnit.config.done.length = 0;
20           }
21           global_test_results = { 'message': message };
22         };
23       }
24     </script>
25     <script src="../node_modules/lodash/lodash.js"></script>
26     <script>var lodashStable = _.noConflict();</script>
27     <script src="../node_modules/qunitjs/qunit/qunit.js"></script>
28     <script src="../node_modules/qunit-extras/qunit-extras.js"></script>
29     <script src="../node_modules/platform/platform.js"></script>
30     <script src="./asset/test-ui.js"></script>
31     <div id="qunit"></div>
32     <div id="exports"></div>
33     <div id="module"></div>
34     <script>
35       function setProperty(object, key, value) {
36         try {
37           Object.defineProperty(object, key, {
38             'configurable': true,
39             'enumerable': false,
40             'writable': true,
41             'value': value
42           });
43         } catch (e) {
44           object[key] = value;
45         }
46         return object;
47       }
48
49       function addBizarroMethods() {
50         var funcProto = Function.prototype,
51             objectProto = Object.prototype;
52
53         var hasOwnProperty = objectProto.hasOwnProperty,
54             fnToString = funcProto.toString,
55             nativeString = fnToString.call(objectProto.toString),
56             noop = function() {},
57             propertyIsEnumerable = objectProto.propertyIsEnumerable,
58             reToString = /toString/g;
59
60         function constant(value) {
61           return function() {
62             return value;
63           };
64         }
65
66         function createToString(funcName) {
67           return constant(nativeString.replace(reToString, funcName));
68         }
69
70         // Allow bypassing native checks.
71         setProperty(funcProto, 'toString', (function() {
72           function wrapper() {
73             setProperty(funcProto, 'toString', fnToString);
74             var result = hasOwnProperty.call(this, 'toString') ? this.toString() : fnToString.call(this);
75             setProperty(funcProto, 'toString', wrapper);
76             return result;
77           }
78           return wrapper;
79         }()));
80
81         // Add prototype extensions.
82         funcProto._method = noop;
83
84         // Set bad shims.
85         setProperty(Object, '_create', Object.create);
86         setProperty(Object, 'create', (function() {
87           function object() {}
88           return function(prototype) {
89             if (prototype === Object(prototype)) {
90               object.prototype = prototype;
91               var result = new object;
92               object.prototype = undefined;
93             }
94             return result || {};
95           };
96         }()));
97
98         setProperty(Object, '_getOwnPropertySymbols', Object.getOwnPropertySymbols);
99         setProperty(Object, 'getOwnPropertySymbols', undefined);
100
101         setProperty(objectProto, '_propertyIsEnumerable', propertyIsEnumerable);
102         setProperty(objectProto, 'propertyIsEnumerable', function(key) {
103           return !(key == 'valueOf' && this && this.valueOf === 1) && _propertyIsEnumerable.call(this, key);
104         });
105
106         setProperty(window, '_Map', window.Map);
107         if (_Map) {
108           setProperty(window, 'Map', (function(Map) {
109             var count = 0;
110             return function() {
111               if (count++) {
112                 return new Map;
113               }
114               var result = {};
115               setProperty(window, 'Map', Map);
116               return result;
117             };
118           }(_Map)));
119
120           setProperty(Map, 'toString', createToString('Map'));
121         }
122         setProperty(window, '_Set', window.Set);
123         setProperty(window, 'Set', noop);
124
125         setProperty(window, '_Symbol', window.Symbol);
126         setProperty(window, 'Symbol', undefined);
127
128         setProperty(window, '_WeakMap', window.WeakMap);
129         setProperty(window, 'WeakMap', noop);
130
131         // Fake `WinRTError`.
132         setProperty(window, 'WinRTError', Error);
133
134         // Fake free variable `global`.
135         setProperty(window, 'exports', window);
136         setProperty(window, 'global', window);
137         setProperty(window, 'module', {});
138       }
139
140       function removeBizarroMethods() {
141         var funcProto = Function.prototype,
142             objectProto = Object.prototype;
143
144         setProperty(objectProto, 'propertyIsEnumerable', objectProto._propertyIsEnumerable);
145
146         if (Object._create) {
147           Object.create = Object._create;
148         } else {
149           delete Object.create;
150         }
151         if (Object._getOwnPropertySymbols) {
152           Object.getOwnPropertySymbols = Object._getOwnPropertySymbols;
153         } else {
154           delete Object.getOwnPropertySymbols;
155         }
156         if (_Map) {
157           Map = _Map;
158         } else {
159           setProperty(window, 'Map', undefined);
160         }
161         if (_Set) {
162           Set = _Set;
163         } else {
164           setProperty(window, 'Set', undefined);
165         }
166         if (_Symbol) {
167           Symbol = _Symbol;
168         }
169         if (_WeakMap) {
170           WeakMap = _WeakMap;
171         } else {
172           setProperty(window, 'WeakMap', undefined);
173         }
174         setProperty(window, '_Map', undefined);
175         setProperty(window, '_Set', undefined);
176         setProperty(window, '_Symbol', undefined);
177         setProperty(window, '_WeakMap', undefined);
178
179         setProperty(window, 'WinRTError', undefined);
180
181         setProperty(window, 'exports', document.getElementById('exports'));
182         setProperty(window, 'global', undefined);
183         setProperty(window, 'module', document.getElementById('module'));
184
185         delete funcProto._method;
186         delete Object._create;
187         delete Object._getOwnPropertySymbols;
188         delete objectProto._propertyIsEnumerable;
189       }
190
191       // Load lodash to expose it to the bad extensions/shims.
192       if (!ui.isModularize) {
193         addBizarroMethods();
194         document.write('<script src="' + ui.buildPath + '"><\/script>');
195       }
196     </script>
197     <script>
198       // Store lodash to test for bad extensions/shims.
199       if (!ui.isModularize) {
200         var lodashBizarro = window._;
201         window._ = undefined;
202         removeBizarroMethods();
203       }
204       // Load test scripts.
205       document.write((ui.isForeign || ui.urlParams.loader == 'none')
206         ? '<script src="' + ui.buildPath + '"><\/script><script src="test.js"><\/script>'
207         : '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
208       );
209     </script>
210     <script>
211       var lodashModule,
212           shimmedModule,
213           underscoreModule;
214
215       (function() {
216         if (window.curl) {
217           curl.config({ 'apiName': 'require' });
218         }
219         if (ui.isForeign || !window.require) {
220           return;
221         }
222         var reBasename = /[\w.-]+$/,
223             basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
224             modulePath = ui.buildPath.replace(/\.js$/, ''),
225             moduleMain = modulePath.match(reBasename)[0],
226             locationPath = modulePath.replace(reBasename, '').replace(/^\/|\/$/g, ''),
227             shimmedLocationPath = './abc/../' + locationPath,
228             underscoreLocationPath = './xyz/../' + locationPath,
229             uid = +new Date;
230
231         function getConfig() {
232           var result = {
233             'baseUrl': './',
234             'urlArgs': 't=' + uid++,
235             'waitSeconds': 0,
236             'paths': {},
237             'packages': [{
238               'name': 'test',
239               'location': basePath + 'test',
240               'main': 'test',
241               'config': {
242                 // Work around no global being exported.
243                 'exports': 'QUnit',
244                 'loader': 'curl/loader/legacy'
245               }
246             }],
247             'shim': {
248               'shimmed': {
249                 'exports': '_'
250               }
251             }
252           };
253
254           if (ui.isModularize) {
255             result.packages.push({
256               'name': 'lodash',
257               'location': locationPath,
258               'main': moduleMain
259             }, {
260               'name': 'shimmed',
261               'location': shimmedLocationPath,
262               'main': moduleMain
263             }, {
264               'name': 'underscore',
265               'location': underscoreLocationPath,
266               'main': moduleMain
267             });
268           } else {
269             result.paths.lodash = modulePath;
270             result.paths.shimmed = shimmedLocationPath + '/' + moduleMain;
271             result.paths.underscore = underscoreLocationPath + '/' + moduleMain;
272           }
273           return result;
274         }
275
276         function loadTests() {
277           require(getConfig(), ['test'], function() {
278             QUnit.start();
279           });
280         }
281
282         function loadModulesAndTests() {
283           require(getConfig(), ['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
284             lodashModule = lodash;
285             lodashModule.moduleName = 'lodash';
286
287             if (shimmed) {
288               shimmedModule = shimmed.result(shimmed, 'noConflict') || shimmed;
289               shimmedModule.moduleName = 'shimmed';
290             }
291             if (underscore) {
292               underscoreModule = underscore.result(underscore, 'noConflict') || underscore;
293               underscoreModule.moduleName = 'underscore';
294             }
295             window._ = lodash;
296
297             if (ui.isModularize) {
298               require(getConfig(), [
299                 'lodash/_baseEach',
300                 'lodash/_isIndex',
301                 'lodash/_isIterateeCall'
302               ], function(baseEach, isIndex, isIterateeCall) {
303                 lodash._baseEach = baseEach;
304                 lodash._isIndex = isIndex;
305                 lodash._isIterateeCall = isIterateeCall;
306                 loadTests();
307               });
308             } else {
309               loadTests();
310             }
311           });
312         }
313
314         QUnit.config.autostart = false;
315
316         if (window.requirejs) {
317           addBizarroMethods();
318           require(getConfig(), ['lodash'], function(lodash) {
319             lodashBizarro = lodash.result(lodash, 'noConflict') || lodash;
320             delete requirejs.s.contexts._;
321
322             removeBizarroMethods();
323             loadModulesAndTests();
324           });
325         } else {
326           loadModulesAndTests();
327         }
328       }());
329
330       // Set a more readable browser name.
331       window.onload = function() {
332         var timeoutId = setInterval(function() {
333           var ua = document.getElementById('qunit-userAgent');
334           if (ua) {
335             ua.innerHTML = platform;
336             clearInterval(timeoutId);
337           }
338         }, 16);
339       };
340     </script>
341   </body>
342 </html>