OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/string16.h" | 7 #include "base/string16.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
12 #include "ui/base/clipboard/clipboard.h" | 12 #include "ui/base/clipboard/clipboard.h" |
13 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 13 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class OmniboxViewTest : public PlatformTest { | 17 class OmniboxViewTest : public PlatformTest { |
18 public: | 18 public: |
19 virtual void TearDown() OVERRIDE { | 19 virtual void TearDown() OVERRIDE { |
20 ui::Clipboard::DestroyClipboardForCurrentThread(); | 20 ui::Clipboard::DestroyClipboardForCurrentThread(); |
21 } | 21 } |
22 | 22 |
23 private: | 23 private: |
24 // Windows requires a message loop for clipboard access. | 24 // Windows requires a message loop for clipboard access. |
25 MessageLoopForUI message_loop_; | 25 base::MessageLoopForUI message_loop_; |
26 }; | 26 }; |
27 | 27 |
28 TEST_F(OmniboxViewTest, TestStripSchemasUnsafeForPaste) { | 28 TEST_F(OmniboxViewTest, TestStripSchemasUnsafeForPaste) { |
29 const char* urls[] = { | 29 const char* urls[] = { |
30 "http://www.google.com?q=javascript:alert(0)", // Safe URL. | 30 "http://www.google.com?q=javascript:alert(0)", // Safe URL. |
31 "javAscript:alert(0)", // Unsafe JS URL. | 31 "javAscript:alert(0)", // Unsafe JS URL. |
32 "jaVascript:\njavaScript: alert(0)" // Single strip unsafe. | 32 "jaVascript:\njavaScript: alert(0)" // Single strip unsafe. |
33 }; | 33 }; |
34 | 34 |
35 const char* expecteds[] = { | 35 const char* expecteds[] = { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 ui::Clipboard::BUFFER_STANDARD); | 132 ui::Clipboard::BUFFER_STANDARD); |
133 clipboard_writer.WriteText(kWrappedAddress); | 133 clipboard_writer.WriteText(kWrappedAddress); |
134 } | 134 } |
135 | 135 |
136 const string16 kFixedAddress(ASCIIToUTF16( | 136 const string16 kFixedAddress(ASCIIToUTF16( |
137 "1600 Amphitheatre Parkway Mountain View, CA")); | 137 "1600 Amphitheatre Parkway Mountain View, CA")); |
138 EXPECT_EQ(kFixedAddress, OmniboxView::GetClipboardText()); | 138 EXPECT_EQ(kFixedAddress, OmniboxView::GetClipboardText()); |
139 } | 139 } |
140 | 140 |
141 } // namespace | 141 } // namespace |
OLD | NEW |