|
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 | |
Peter Kasting
2011/08/05 20:10:22
Nit: Extra newline
Tom Sepez
2011/08/05 20:26:09
Done.
| |
13 const char* urls[] = { | |
14 "http://www.google.com?q=javascript:alert(0)", // Safe URL. | |
15 "javAscript:alert(0)", // Unsafe JS URL. | |
Peter Kasting
2011/08/05 20:10:22
Can you also add one more like:
" jav\nascript:
Tom Sepez
2011/08/05 20:26:09
Flunks. The compaction occurs above this method.
Peter Kasting
2011/08/05 20:28:18
Ah, I see. Nah, just leave this testcase out.
| |
16 "jaVascript:\njavaScript: alert(0)", // Single strip unsafe. | |
17 }; | |
18 | |
19 const char* expecteds[] = { | |
20 "http://www.google.com?q=javascript:alert(0)", // Safe URL. | |
21 "alert(0)", // Unsafe JS URL. | |
22 "alert(0)", // Single strip unsafe. | |
23 }; | |
24 | |
25 for (size_t i = 0; i < arraysize(urls); i++) { | |
26 string16 url = ASCIIToUTF16(urls[i]); | |
Peter Kasting
2011/08/05 20:10:22
Nit: I'd probably roll at least these first two di
Tom Sepez
2011/08/05 20:26:09
Done.
| |
27 string16 expected = ASCIIToUTF16(expecteds[i]); | |
28 string16 result = OmniboxView::StripJavascriptSchemas(url); | |
29 EXPECT_EQ(expected, result); | |
30 } | |
31 } | |
OLD | NEW |