Bug 1433617 - Cache control headers added to png image. r=ckerschb, a=test-only
authorvinoth <cegvinoth@gmail.com>
Sun, 25 Mar 2018 10:44:59 +0200
changeset 462863 2ac29892c9698adddf973a8dd33c4a2186617350
parent 462862 c750b5f15c2b0ef8b2b22faca0c2257f0d9dd6b6
child 462864 6fc09a406b3b2feeb4731d4c11f29be680229b1c
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb, test-only
bugs1433617
milestone60.0
Bug 1433617 - Cache control headers added to png image. r=ckerschb, a=test-only
testing/web-platform/meta/MANIFEST.json
testing/web-platform/meta/content-security-policy/prefetch-src/prefetch-allowed.html.ini
testing/web-platform/tests/content-security-policy/prefetch-src/prefetch-allowed.html
testing/web-platform/tests/content-security-policy/support/file-prefetch-allowed.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -211445,16 +211445,21 @@
      {}
     ]
    ],
    "content-security-policy/support/fail.png": [
     [
      {}
     ]
    ],
+   "content-security-policy/support/file-prefetch-allowed.html": [
+    [
+     {}
+    ]
+   ],
    "content-security-policy/support/fonts.css": [
     [
      {}
     ]
    ],
    "content-security-policy/support/import-scripts.js": [
     [
      {}
@@ -414787,17 +414792,17 @@
    "f353383d7539fbd09c40587181a328571241962a",
    "testharness"
   ],
   "content-security-policy/plugin-types/plugintypes-nourl-blocked.sub.html": [
    "cae24a6958eae450d1b21a47f4e13c407cac33be",
    "testharness"
   ],
   "content-security-policy/prefetch-src/prefetch-allowed.html": [
-   "8c88fefbffb6f5270b64cd8d81b405857a9c1123",
+   "45e002cde6f0e61cfc4876fad6d5af7341fec346",
    "testharness"
   ],
   "content-security-policy/prefetch-src/prefetch-blocked.html": [
    "0c228cef4140a4a9ca5e7704cf4356e13e8f844a",
    "testharness"
   ],
   "content-security-policy/prefetch-src/prefetch-header-allowed.html": [
    "8b3e0d248e70c2d7587b0ff560f41a42b5bf92f4",
@@ -415738,16 +415743,20 @@
   "content-security-policy/support/fail.js": [
    "90d888b42df7812ab893788918fac7cdaf27d1d6",
    "support"
   ],
   "content-security-policy/support/fail.png": [
    "13c3f17f61fa30ac6d7c5c54bd73a6f93d1611c1",
    "support"
   ],
+  "content-security-policy/support/file-prefetch-allowed.html": [
+   "13e9e4ef7ad82d1f9404381a3eeb2a00c319b52a",
+   "support"
+  ],
   "content-security-policy/support/fonts.css": [
    "4577fb4f580bfd9c723e1a5ee0f9d8438ce41ac9",
    "support"
   ],
   "content-security-policy/support/import-scripts.js": [
    "79a3767181ce25e78a574f8bd51f8bc796bee0b8",
    "support"
   ],
--- a/testing/web-platform/meta/content-security-policy/prefetch-src/prefetch-allowed.html.ini
+++ b/testing/web-platform/meta/content-security-policy/prefetch-src/prefetch-allowed.html.ini
@@ -1,5 +1,3 @@
 [prefetch-allowed.html]
   prefs: [security.mixed_content.upgrade_display_content:false]
-  [Prefetch succeeds when allowed by prefetch-src]
-    expected: FAIL
-
+  comment: prefetch-src is not supported via meta tag but the test is passing as the tests only tests that 'self' works
--- a/testing/web-platform/tests/content-security-policy/prefetch-src/prefetch-allowed.html
+++ b/testing/web-platform/tests/content-security-policy/prefetch-src/prefetch-allowed.html
@@ -1,23 +1,30 @@
 <!DOCTYPE html>
 <html>
 <head>
-  <meta http-equiv="Content-Security-Policy" content="prefetch-src 'self'">
   <script src='/resources/testharness.js'></script>
   <script src='/resources/testharnessreport.js'></script>
   <script src='/content-security-policy/support/testharness-helper.js'></script>
   <script src='/content-security-policy/support/prefetch-helper.js'></script>
   <script>
     async_test(t => {
-      let url = window.origin + '/content-security-policy/support/pass.png';
+      var win = window.open('/content-security-policy/support/' +
+                            'file-prefetch-allowed.html');
+      win.addEventListener('load', function () {
+        // Cache control headers are added,since they are needed 
+        // to enable prefetching.
+        let url = '/content-security-policy/support/pass.png' +
+                                  '?pipe=header(Cache-Control, max-age=604800)';
 
-      let link = document.createElement('link');
-      link.rel = 'prefetch';
-      link.href = url;
-
-      assert_link_prefetches(t, link);
+        // Link element is created on the new opened window.
+        let link = win.document.createElement('link');
+        link.rel = 'prefetch';
+        link.href = url;
+        assert_link_prefetches(t, link);
+        win.close();
+      }, false);
     }, 'Prefetch succeeds when allowed by prefetch-src');
   </script>
 </head>
 <body>
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/support/file-prefetch-allowed.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <!-- CSP directive 'prefetch-src' is not supported via meta tag though -->
+  <meta http-equiv="Content-Security-Policy" content="prefetch-src 'self'">
+</head>
+<body>
+</body>
+</html>