فهرست منبع

Fix bug with about:blank

Gaël Métais 10 سال پیش
والد
کامیت
41bc676b12
2فایلهای تغییر یافته به همراه16 افزوده شده و 0 حذف شده
  1. 5 0
      lib/tools/weightChecker/weightChecker.js
  2. 11 0
      test/core/weightCheckerTest.js

+ 5 - 0
lib/tools/weightChecker/weightChecker.js

@@ -185,6 +185,11 @@ var WeightChecker = function() {
             return deferred.promise;
         }
 
+        if (entry.url === 'about:blank') {
+            onError('not downloading about:blank');
+            return deferred.promise;
+        }
+
 
         debug('Downloading %s', entry.url);
 

+ 11 - 0
test/core/weightCheckerTest.js

@@ -56,6 +56,16 @@ describe('weightChecker', function() {
                 isImage: true,
                 type: 'image',
                 contentType: 'image/svg+xml'
+            },
+            {
+                method: 'GET',
+                url: 'about:blank',
+                requestHeaders: {
+                    'User-Agent': 'something',
+                   Referer: 'http://www.google.fr/',
+                   Accept: '*/*'
+                },
+                status: 200
             }
         ];
 
@@ -84,6 +94,7 @@ describe('weightChecker', function() {
             data.toolsResults.weightChecker.offenders.totalWeight.byType.html.requests.length.should.equal(1);
             data.toolsResults.weightChecker.offenders.totalWeight.byType.js.requests.length.should.equal(1);
             data.toolsResults.weightChecker.offenders.totalWeight.byType.image.requests.length.should.equal(2);
+            data.toolsResults.weightChecker.offenders.totalWeight.byType.other.requests.length.should.equal(1);
 
             data.toolsResults.weightChecker.offenders.should.have.a.property('imageOptimization');
             data.toolsResults.weightChecker.offenders.imageOptimization.totalGain.should.be.above(0);