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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 8702002: Strip invalid characters (line breaks, tabs), javascript:schemes from the copied text while pasti... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); 750 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
751 ASSERT_EQ(text, omnibox_view->model()->keyword()); 751 ASSERT_EQ(text, omnibox_view->model()->keyword());
752 ASSERT_TRUE(omnibox_view->GetText().empty()); 752 ASSERT_TRUE(omnibox_view->GetText().empty());
753 753
754 // Revert to keyword hint mode. 754 // Revert to keyword hint mode.
755 omnibox_view->model()->ClearKeyword(string16()); 755 omnibox_view->model()->ClearKeyword(string16());
756 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); 756 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
757 ASSERT_EQ(text, omnibox_view->model()->keyword()); 757 ASSERT_EQ(text, omnibox_view->model()->keyword());
758 ASSERT_EQ(text, omnibox_view->GetText()); 758 ASSERT_EQ(text, omnibox_view->GetText());
759 759
760 // Keyword shouldn't be accepted by pasting. 760 // Keyword shouldn't be accepted by pressing space with a trailing
761 // Simulate pasting a whitespace to the end of content. 761 // whitespace.
762 omnibox_view->OnBeforePossibleChange();
763 omnibox_view->model()->on_paste();
764 omnibox_view->SetWindowTextAndCaretPos( 762 omnibox_view->SetWindowTextAndCaretPos(
765 text + char16(' '), text.length() + 1); 763 text + char16(' '), text.length() + 1);
766 omnibox_view->OnAfterPossibleChange();
767 // Should be still in keyword hint mode.
768 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
769 ASSERT_EQ(text, omnibox_view->model()->keyword());
770 ASSERT_EQ(text + char16(' '), omnibox_view->GetText());
771
772 // Keyword shouldn't be accepted by pressing space with a trailing
773 // whitespace.
774 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); 764 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0));
775 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); 765 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
776 ASSERT_EQ(text, omnibox_view->model()->keyword()); 766 ASSERT_EQ(text, omnibox_view->model()->keyword());
777 ASSERT_EQ(text + ASCIIToUTF16(" "), omnibox_view->GetText()); 767 ASSERT_EQ(text + ASCIIToUTF16(" "), omnibox_view->GetText());
778 768
779 // Keyword shouldn't be accepted by deleting the trailing space. 769 // Keyword shouldn't be accepted by deleting the trailing space.
780 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); 770 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0));
781 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); 771 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
782 ASSERT_EQ(text, omnibox_view->model()->keyword()); 772 ASSERT_EQ(text, omnibox_view->model()->keyword());
783 ASSERT_EQ(text + char16(' '), omnibox_view->GetText()); 773 ASSERT_EQ(text + char16(' '), omnibox_view->GetText());
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 PersistKeywordModeOnTabSwitch) { 1398 PersistKeywordModeOnTabSwitch) {
1409 PersistKeywordModeOnTabSwitch(); 1399 PersistKeywordModeOnTabSwitch();
1410 } 1400 }
1411 1401
1412 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, 1402 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest,
1413 CtrlKeyPressedWithInlineAutocompleteTest) { 1403 CtrlKeyPressedWithInlineAutocompleteTest) {
1414 CtrlKeyPressedWithInlineAutocompleteTest(); 1404 CtrlKeyPressedWithInlineAutocompleteTest();
1415 } 1405 }
1416 1406
1417 #endif 1407 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698