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

Unified Diff: chrome/browser/ui/omnibox/omnibox_view_unittest.cc

Issue 7585016: Add unit test for javascript: URL stripping (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/omnibox/omnibox_view_unittest.cc
===================================================================
--- chrome/browser/ui/omnibox/omnibox_view_unittest.cc (revision 0)
+++ chrome/browser/ui/omnibox/omnibox_view_unittest.cc (revision 0)
@@ -0,0 +1,28 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/omnibox/omnibox_view.h"
+#include "base/string16.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(OmniboxView, TestStripSchemasUnsafeForPaste) {
+ const char* urls[] = {
+ "http://www.google.com?q=javascript:alert(0)", // Safe URL.
+ "javAscript:alert(0)", // Unsafe JS URL.
+ "jaVascript:\njavaScript: alert(0)" // Single strip unsafe.
+ };
+
+ const char* expecteds[] = {
+ "http://www.google.com?q=javascript:alert(0)", // Safe URL.
+ "alert(0)", // Unsafe JS URL.
+ "alert(0)" // Single strip unsafe.
+ };
+
+ for (size_t i = 0; i < arraysize(urls); i++) {
+ EXPECT_EQ(ASCIIToUTF16(expecteds[i]),
+ OmniboxView::StripJavascriptSchemas(ASCIIToUTF16(urls[i])));
+ }
+}
Property changes on: chrome/browser/ui/omnibox/omnibox_view_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698