OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 6 #include "base/string16.h" |
| 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 TEST(OmniboxView, TestStripSchemasUnsafeForPaste) { |
| 12 const char* urls[] = { |
| 13 "http://www.google.com?q=javascript:alert(0)", // Safe URL. |
| 14 "javAscript:alert(0)", // Unsafe JS URL. |
| 15 "jaVascript:\njavaScript: alert(0)" // Single strip unsafe. |
| 16 }; |
| 17 |
| 18 const char* expecteds[] = { |
| 19 "http://www.google.com?q=javascript:alert(0)", // Safe URL. |
| 20 "alert(0)", // Unsafe JS URL. |
| 21 "alert(0)" // Single strip unsafe. |
| 22 }; |
| 23 |
| 24 for (size_t i = 0; i < arraysize(urls); i++) { |
| 25 EXPECT_EQ(ASCIIToUTF16(expecteds[i]), |
| 26 OmniboxView::StripJavascriptSchemas(ASCIIToUTF16(urls[i]))); |
| 27 } |
| 28 } |
OLD | NEW |