Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1036)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/view-source-navigation-block.html

Issue 1917073002: Block webpages from navigating to view-source URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add layout and browser tests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/security/view-source-navigation-block.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/view-source-navigation-block.html b/third_party/WebKit/LayoutTests/http/tests/security/view-source-navigation-block.html
new file mode 100644
index 0000000000000000000000000000000000000000..fcaa2950834784fa665ee2a5553d9c2df91eb97a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/view-source-navigation-block.html
@@ -0,0 +1,27 @@
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>view-source navigation should be blocked</title>
+</head>
+<script>
+window.onunload = function() {
+ console.error('FAIL');
+ testRunner.notifyDone();
Nate Chapin 2016/05/27 23:57:32 Nit: if (window.testRunner)
+}
+function test() {
+ window.location = "view-source:about:blank";
+ setTimeout(function() {
+ if (window.testRunner) {
+ document.getElementById("result").innerHTML = "PASS";
+ testRunner.notifyDone();
+ }
+ }, 1000);
meacer 2016/05/23 23:57:47 This is ugly as it uses setTimeout with a non-zero
Charlie Reis 2016/05/24 22:54:17 Yeah, we shouldn't do this. Maybe there's an erro
Nate Chapin 2016/05/27 23:57:32 This is a bit tougher because it's view-source. No
meacer 2016/05/31 23:57:54 Looks like queueLoad triggers a browser initiated
Charlie Reis 2016/06/01 22:59:51 Do we actually need a layout test for this? You'v
+}
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+document.addEventListener('DOMContentLoaded', test, false);
+</script>
+<div id="result"></div>
+</html>

Powered by Google App Engine
This is Rietveld 408576698