
Tinytest.add(
  'Loader - Load all critical files first',
  function (test) {
    var scripts = document.getElementsByTagName('script');
    scripts = Array.prototype.slice.call(scripts);
    scripts = scripts.slice(0, 6).map(getSrc);
    var expected = [
      '/packages/zones/assets/utils.js',
      '/packages/zones/assets/before.js',
      '/packages/zones/assets/zone.js',
      '/packages/zones/assets/tracer.js',
      '/packages/zones/assets/after.js',
      '/packages/zones/assets/reporters.js',
    ];
    test.equal(expected, scripts);

    function getSrc(el) {
      return el.src.replace(location.origin, '');
    }
  }
);

Tinytest.add(
  'Loader - do not override some functions',
  function (test) {
    var expected = 'function requestAnimationFrame() { [native code] }';
    if(requestAnimationFrame) {
      test.equal(expected, requestAnimationFrame.toString());
    }
  }
);

@@ -1,265 +1,21 @@
 %0A
-Tinytest.add(%0A  'Loader - Load all critical files first',%0A  function (test) %7B%0A    var scripts = document.getElementsByTagName('script');%0A    scripts = Array.prototype.slice.call(scripts);%0A    scripts = scripts.slice(0, 6).map(getSrc);%0A    var expected
+var SCRIPTS
  = %5B%0A
-    
   '/
@@ -43,28 +43,24 @@
 /utils.js',%0A
-    
   '/packages
@@ -81,28 +81,24 @@
 before.js',%0A
-    
   '/packages
@@ -117,28 +117,24 @@
 s/zone.js',%0A
-    
   '/packages
@@ -151,36 +151,32 @@
 ets/tracer.js',%0A
-    
   '/packages/zon
@@ -196,20 +196,16 @@
 er.js',%0A
-    
   '/pack
@@ -241,38 +241,269 @@
 s',%0A
-    %5D;%0A    test.equal(expected
+%5D;%0A%0ATinytest.add(%0A  'Loader - Load all critical files first',%0A  function (test) %7B%0A    var scripts = document.getElementsByTagName('script');%0A    scripts = Array.prototype.slice.call(scripts);%0A    scripts = scripts.slice(0, 6).map(getSrc);%0A    test.equal(SCRIPTS
 , sc
@@ -844,24 +844,1210 @@
 String());%0A    %7D%0A  %7D%0A);%0A
+%0ATinytest.addAsync(%0A  'Loader - do not load if Zone is disabled',%0A  function (test, next) %7B%0A    // disable it and see whether zones don't get loaded%0A    Meteor.call('zone-off', function () %7B%0A      $.get(location.href, function (html, status) %7B%0A        // append the html to a temporary container to search%0A        var scripts = $('%3Cdiv%3E').append(html).find('script');%0A        scripts = Array.prototype.slice.call(scripts);%0A        scripts = scripts.slice(0, 6).map(getSrc);%0A        scripts.forEach(function (path) %7B%0A          test.equal(SCRIPTS.indexOf(path), -1);%0A        %7D);%0A%0A        // enable it and test whether zones scripts are loaded%0A        Meteor.call('zone-on', function () %7B%0A          $.get(location.href, function (html, status) %7B%0A            // append the html to a temporary container to search%0A            var scripts = $('%3Cdiv%3E').append(html).find('script');%0A            scripts = Array.prototype.slice.call(scripts);%0A            scripts = scripts.slice(0, 6).map(getSrc);%0A            test.equal(SCRIPTS, scripts);%0A            next();%0A          %7D);%0A        %7D);%0A%0A      %7D);%0A    %7D);%0A%0A    function getSrc(el) %7B%0A      return el.src.replace(location.origin, '');%0A    %7D%0A  %7D%0A);%0A

Test enable/disable zones