From 354c860da0a6c629de73037bd1ab3c4f51613e64 Mon Sep 17 00:00:00 2001
From: Lloyd Hilaiel <lloyd@hilaiel.com>
Date: Fri, 30 Mar 2012 15:21:20 -0600
Subject: [PATCH] (cache unit tests, issue #1353) check for proper
 X-Frame-Options headers on initial request as well as 304 response

---
 tests/cache-header-tests.js | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/tests/cache-header-tests.js b/tests/cache-header-tests.js
index 198b42630..4713b0d6b 100755
--- a/tests/cache-header-tests.js
+++ b/tests/cache-header-tests.js
@@ -45,6 +45,14 @@ function doRequest(path, headers, cb) {
   req.end();
 }
 
+function hasProperFramingHeaders(r, path) {
+  if (['/communication_iframe', '/relay'].indexOf(path) !== -1) {
+    assert.strictEqual(r.headers['x-frame-options'], undefined);
+  } else {
+    assert.strictEqual(r.headers['x-frame-options'],"DENY");
+  }
+}
+
 function hasProperCacheHeaders(path) {
   return {
     topic: function() {
@@ -64,6 +72,8 @@ function hasProperCacheHeaders(path) {
     },
     "returns 200 with content": function(err, r) {
       assert.strictEqual(r.statusCode, 200);
+      // check X-Frame-Option headers
+      hasProperFramingHeaders(r, path);
       // ensure vary headers
       assert.strictEqual(r.headers['vary'], 'Accept-Encoding,Accept-Language');
       // ensure public, max-age=0
@@ -82,13 +92,7 @@ function hasProperCacheHeaders(path) {
         }, this.callback);
       },
       "returns a 304": function(err, r) {
-        if (! err) {
-          if (['/communication_iframe', '/relay'].indexOf(path) !== -1) {
-            assert.strictEqual(r.headers['x-frame-options'], undefined);
-          } else {
-            assert.strictEqual(r.headers['x-frame-options'],"DENY");
-          }
-        }
+        if (!err) hasProperFramingHeaders(r, path);
         assert.strictEqual(r.statusCode, 304);
       }
     },
-- 
GitLab