Verify that Referer Policy within Content-Disposition:attachment sandbox is always...
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Dec 2015 01:11:45 +0000 (01:11 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Dec 2015 01:11:45 +0000 (01:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152260
<rdar://problem/23884579>

Reviewed by Andy Estes.

* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-expected.txt: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always-expected.txt: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always.html: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default-expected.txt: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default.html: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never-expected.txt: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never.html: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-expected.txt: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade-expected.txt: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade.html: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer.html: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin-expected.txt: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin.html: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url-expected.txt: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url.html: Added.
* http/tests/contentdispositionattachmentsandbox/referer-header-stripped.html: Added.
* http/tests/contentdispositionattachmentsandbox/resources/referer-header-stripped-frame.php: Added.
* http/tests/contentdispositionattachmentsandbox/resources/referer-header-stripped.js: Added.
* http/tests/contentdispositionattachmentsandbox/resources/subresource-request-not-include-referer-header-frame.php: Removed.
* http/tests/contentdispositionattachmentsandbox/subresource-request-not-include-referer-header-expected.txt: Removed.
* http/tests/contentdispositionattachmentsandbox/subresource-request-not-include-referer-header.html: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194128 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always.html [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default.html [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never.html [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade.html [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer.html [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin.html [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url.html [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped.html [new file with mode: 0644]
LayoutTests/http/tests/contentdispositionattachmentsandbox/resources/referer-header-stripped-frame.php [moved from LayoutTests/http/tests/contentdispositionattachmentsandbox/resources/subresource-request-not-include-referer-header-frame.php with 67% similarity]
LayoutTests/http/tests/contentdispositionattachmentsandbox/resources/referer-header-stripped.js [moved from LayoutTests/http/tests/contentdispositionattachmentsandbox/subresource-request-not-include-referer-header.html with 66% similarity]
LayoutTests/http/tests/contentdispositionattachmentsandbox/subresource-request-not-include-referer-header-expected.txt [deleted file]

index ed6dac733e8a2c9924665830f9449a9619087115..afab15c77a0372e4cab036a3d6d8993c1fdb5df3 100644 (file)
@@ -1,3 +1,33 @@
+2015-12-15  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Verify that Referer Policy within Content-Disposition:attachment sandbox is always ReferrerPolicyNever
+        https://bugs.webkit.org/show_bug.cgi?id=152260
+        <rdar://problem/23884579>
+
+        Reviewed by Andy Estes.
+
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-expected.txt: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always-expected.txt: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always.html: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default-expected.txt: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default.html: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never-expected.txt: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never.html: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-expected.txt: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade-expected.txt: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade.html: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer.html: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin-expected.txt: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin.html: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url-expected.txt: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url.html: Added.
+        * http/tests/contentdispositionattachmentsandbox/referer-header-stripped.html: Added.
+        * http/tests/contentdispositionattachmentsandbox/resources/referer-header-stripped-frame.php: Added.
+        * http/tests/contentdispositionattachmentsandbox/resources/referer-header-stripped.js: Added.
+        * http/tests/contentdispositionattachmentsandbox/resources/subresource-request-not-include-referer-header-frame.php: Removed.
+        * http/tests/contentdispositionattachmentsandbox/subresource-request-not-include-referer-header-expected.txt: Removed.
+        * http/tests/contentdispositionattachmentsandbox/subresource-request-not-include-referer-header.html: Removed.
+
 2015-12-15  Timothy Horton  <timothy_horton@apple.com>
 
         Rebaseline some page overlay tests for WK1
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-expected.txt b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-expected.txt
new file mode 100644 (file)
index 0000000..fd8d2a9
--- /dev/null
@@ -0,0 +1,8 @@
+This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always-expected.txt b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always-expected.txt
new file mode 100644 (file)
index 0000000..fd8d2a9
--- /dev/null
@@ -0,0 +1,8 @@
+This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always.html b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always.html
new file mode 100644 (file)
index 0000000..ef71805
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<script src="resources/referer-header-stripped.js"></script>
+<p>This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.</p>
+<iframe src="resources/referer-header-stripped-frame.php?referrer=always" onload="navigation()"></iframe>
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default-expected.txt b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default-expected.txt
new file mode 100644 (file)
index 0000000..fd8d2a9
--- /dev/null
@@ -0,0 +1,8 @@
+This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default.html b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default.html
new file mode 100644 (file)
index 0000000..1cb50a4
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<script src="resources/referer-header-stripped.js"></script>
+<p>This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.</p>
+<iframe src="resources/referer-header-stripped-frame.php?referrer=default" onload="navigation()"></iframe>
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never-expected.txt b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never-expected.txt
new file mode 100644 (file)
index 0000000..fd8d2a9
--- /dev/null
@@ -0,0 +1,8 @@
+This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never.html b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-never.html
new file mode 100644 (file)
index 0000000..29833e4
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<script src="resources/referer-header-stripped.js"></script>
+<p>This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.</p>
+<iframe src="resources/referer-header-stripped-frame.php?referrer=never" onload="navigation()"></iframe>
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-expected.txt b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-expected.txt
new file mode 100644 (file)
index 0000000..fd8d2a9
--- /dev/null
@@ -0,0 +1,8 @@
+This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade-expected.txt b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade-expected.txt
new file mode 100644 (file)
index 0000000..fd8d2a9
--- /dev/null
@@ -0,0 +1,8 @@
+This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade.html b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer-when-downgrade.html
new file mode 100644 (file)
index 0000000..be3c915
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<script src="resources/referer-header-stripped.js"></script>
+<p>This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.</p>
+<iframe src="resources/referer-header-stripped-frame.php?referrer=no-referrer-when-downgrade" onload="navigation()"></iframe>
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer.html b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-no-referrer.html
new file mode 100644 (file)
index 0000000..7fe5c19
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<script src="resources/referer-header-stripped.js"></script>
+<p>This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.</p>
+<iframe src="resources/referer-header-stripped-frame.php?referrer=no-referrer" onload="navigation()"></iframe>
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin-expected.txt b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin-expected.txt
new file mode 100644 (file)
index 0000000..fd8d2a9
--- /dev/null
@@ -0,0 +1,8 @@
+This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin.html b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-origin.html
new file mode 100644 (file)
index 0000000..72bca14
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<script src="resources/referer-header-stripped.js"></script>
+<p>This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.</p>
+<iframe src="resources/referer-header-stripped-frame.php?referrer=origin" onload="navigation()"></iframe>
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url-expected.txt b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url-expected.txt
new file mode 100644 (file)
index 0000000..fd8d2a9
--- /dev/null
@@ -0,0 +1,8 @@
+This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url.html b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-unsafe-url.html
new file mode 100644 (file)
index 0000000..1be1476
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<script src="resources/referer-header-stripped.js"></script>
+<p>This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.</p>
+<iframe src="resources/referer-header-stripped-frame.php?referrer=unsafe-url" onload="navigation()"></iframe>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped.html b/LayoutTests/http/tests/contentdispositionattachmentsandbox/referer-header-stripped.html
new file mode 100644 (file)
index 0000000..9f134b7
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<script src="resources/referer-header-stripped.js"></script>
+<p>This test verifies that a link redirected by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.</p>
+<iframe src="resources/referer-header-stripped-frame.php" onload="navigation()"></iframe>
@@ -3,12 +3,14 @@ header("Content-Disposition: attachment; filename=test.html");
 header("Content-Type: text/html");
 ?>
 <!DOCTYPE html>
+<head>
+<?php if (isset($_GET['referrer'])) print("<meta name=\"referrer\" content=\"" . $_GET['referrer'] . "\">\n"); ?>
 <style>
 a {
     display: block;
     width: 100vw;
     height: 100vh;
 }
-
 </style>
+</head>
 <a href="echo-http-referer.php">Link to echo-http-referer.php</a>
\ No newline at end of file
similarity index 66%
rename from LayoutTests/http/tests/contentdispositionattachmentsandbox/subresource-request-not-include-referer-header.html
rename to LayoutTests/http/tests/contentdispositionattachmentsandbox/resources/referer-header-stripped.js
index a587ee643a0e0489877ea4dba6c08fd25055f5de..8a4ecc6988c0d9f42ca7a1fb882bf6d531526271 100644 (file)
@@ -1,5 +1,3 @@
-<!DOCTYPE html>
-<script>
 if (window.internals)
     internals.settings.setContentDispositionAttachmentSandboxEnabled(true);
 
@@ -11,7 +9,7 @@ if (window.testRunner) {
 
 function navigation() {
     // Due to the sandbox, it's not possible to run script in the iframe or even access its contentDocument.
-    var element = document.getElementById('iframe');
+    var element = document.getElementsByTagName("iframe")[0];
     var x = element.offsetLeft + 10;
     var y = element.offsetTop + 10;
 
@@ -25,7 +23,4 @@ function navigation() {
         if (testRunner.runUIScript)
             testRunner.runUIScript("(function() { uiController.singleTapAtPoint(" + x + ", " + y + "); })()");
     }
-}
-</script>
-<p>This test verifies that a subresource loaded by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.</p>
-<iframe id='iframe' src="resources/subresource-request-not-include-referer-header-frame.php" onload="navigation()"></iframe>
+}
\ No newline at end of file
diff --git a/LayoutTests/http/tests/contentdispositionattachmentsandbox/subresource-request-not-include-referer-header-expected.txt b/LayoutTests/http/tests/contentdispositionattachmentsandbox/subresource-request-not-include-referer-header-expected.txt
deleted file mode 100644 (file)
index 2638d01..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-This test verifies that a subresource loaded by a document which is loaded with Content-Disposition:attachment will not have http referer. Tess passes if no referer is printed.
-
-
-
---------
-Frame: 'iframe'
---------
-