OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 7 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
8 | 8 |
9 #include "chrome/browser/extensions/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
10 #include "chrome/common/extensions/url_pattern.h" | 10 #include "chrome/common/extensions/url_pattern.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 if (contexts & ExtensionMenuItem::FRAME) | 67 if (contexts & ExtensionMenuItem::FRAME) |
68 rv.frame_url = GURL("http://test.frame/"); | 68 rv.frame_url = GURL("http://test.frame/"); |
69 | 69 |
70 return rv; | 70 return rv; |
71 } | 71 } |
72 | 72 |
73 // Generates a URLPatternSet with a single pattern | 73 // Generates a URLPatternSet with a single pattern |
74 static URLPatternSet CreatePatternSet(const std::string& pattern) { | 74 static URLPatternSet CreatePatternSet(const std::string& pattern) { |
75 URLPattern target(URLPattern::SCHEME_HTTP); | 75 URLPattern target(URLPattern::SCHEME_HTTP); |
76 target.Parse(pattern, URLPattern::PARSE_LENIENT); | 76 target.Parse(pattern, URLPattern::IGNORE_PORTS); |
77 | 77 |
78 URLPatternSet rv; | 78 URLPatternSet rv; |
79 rv.AddPattern(target); | 79 rv.AddPattern(target); |
80 | 80 |
81 return rv; | 81 return rv; |
82 } | 82 } |
83 | 83 |
84 TEST_F(RenderViewContextMenuTest, TargetIgnoredForPage) { | 84 TEST_F(RenderViewContextMenuTest, TargetIgnoredForPage) { |
85 ContextMenuParams params = CreateParams(0); | 85 ContextMenuParams params = CreateParams(0); |
86 | 86 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 ExtensionMenuItem::ContextList contexts; | 232 ExtensionMenuItem::ContextList contexts; |
233 contexts.Add(ExtensionMenuItem::SELECTION); | 233 contexts.Add(ExtensionMenuItem::SELECTION); |
234 contexts.Add(ExtensionMenuItem::IMAGE); | 234 contexts.Add(ExtensionMenuItem::IMAGE); |
235 | 235 |
236 URLPatternSet patterns = CreatePatternSet("*://test.none/*"); | 236 URLPatternSet patterns = CreatePatternSet("*://test.none/*"); |
237 | 237 |
238 EXPECT_TRUE(ExtensionContextAndPatternMatch(params, contexts, patterns)); | 238 EXPECT_TRUE(ExtensionContextAndPatternMatch(params, contexts, patterns)); |
239 } | 239 } |
240 | 240 |
OLD | NEW |