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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 }
OLDNEW
« 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