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

Side by Side Diff: chrome/common/extensions/user_script_unittest.cc

Issue 19624: Add early-injection capability to user scripts. I haven't yet (Closed)
Patch Set: Use new documentElementAvailable() callback Created 11 years, 10 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
« no previous file with comments | « chrome/common/extensions/user_script.cc ('k') | chrome/renderer/render_view.h » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "chrome/common/extensions/user_script.h" 7 #include "chrome/common/extensions/user_script.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 TEST(UserScriptTest, Pickle) { 73 TEST(UserScriptTest, Pickle) {
74 URLPattern pattern1; 74 URLPattern pattern1;
75 URLPattern pattern2; 75 URLPattern pattern2;
76 ASSERT_TRUE(pattern1.Parse("http://*/foo*")); 76 ASSERT_TRUE(pattern1.Parse("http://*/foo*"));
77 ASSERT_TRUE(pattern2.Parse("http://bar/baz*")); 77 ASSERT_TRUE(pattern2.Parse("http://bar/baz*"));
78 78
79 UserScript script1; 79 UserScript script1;
80 script1.set_url(GURL("chrome-user-script:/foo.user.js")); 80 script1.set_url(GURL("chrome-user-script:/foo.user.js"));
81 script1.set_run_location(UserScript::DOCUMENT_START);
81 script1.add_url_pattern(pattern1); 82 script1.add_url_pattern(pattern1);
82 script1.add_url_pattern(pattern2); 83 script1.add_url_pattern(pattern2);
83 84
84 Pickle pickle; 85 Pickle pickle;
85 script1.Pickle(&pickle); 86 script1.Pickle(&pickle);
86 87
87 void* iter = NULL; 88 void* iter = NULL;
88 UserScript script2; 89 UserScript script2;
89 script2.Unpickle(pickle, &iter); 90 script2.Unpickle(pickle, &iter);
90 91
91 EXPECT_EQ(script1.url(), script2.url()); 92 EXPECT_EQ(script1.url(), script2.url());
92 ASSERT_EQ(script1.globs().size(), script2.globs().size()); 93 ASSERT_EQ(script1.globs().size(), script2.globs().size());
93 for (size_t i = 0; i < script1.globs().size(); ++i) { 94 for (size_t i = 0; i < script1.globs().size(); ++i) {
94 EXPECT_EQ(script1.globs()[i], script2.globs()[i]); 95 EXPECT_EQ(script1.globs()[i], script2.globs()[i]);
95 } 96 }
96 ASSERT_EQ(script1.url_patterns().size(), script2.url_patterns().size()); 97 ASSERT_EQ(script1.url_patterns().size(), script2.url_patterns().size());
97 for (size_t i = 0; i < script1.url_patterns().size(); ++i) { 98 for (size_t i = 0; i < script1.url_patterns().size(); ++i) {
98 EXPECT_EQ(script1.url_patterns()[i].GetAsString(), 99 EXPECT_EQ(script1.url_patterns()[i].GetAsString(),
99 script2.url_patterns()[i].GetAsString()); 100 script2.url_patterns()[i].GetAsString());
100 } 101 }
101 } 102 }
103
104 TEST(UserScriptTest, Defaults) {
Matt Perry 2009/02/11 19:28:46 Do these defaults need to be this way for compatib
105 UserScript script;
106 ASSERT_EQ(FILE_PATH_LITERAL(""), script.path().value());
107 ASSERT_EQ("", script.url().spec());
108 ASSERT_EQ(0, script.url_patterns().size());
109 ASSERT_EQ(0, script.globs().size());
110 ASSERT_EQ(UserScript::DOCUMENT_END, script.run_location());
111 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/user_script.cc ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698