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

Side by Side Diff: third_party/WebKit/Source/bindings/modules/v8/V8BindingForModulesTest.cpp

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 ASSERT_TRUE(expected == idbKey->number()); 98 ASSERT_TRUE(expected == idbKey->number());
99 } 99 }
100 100
101 class IDBKeyFromValueAndKeyPathTest : public testing::Test { 101 class IDBKeyFromValueAndKeyPathTest : public testing::Test {
102 public: 102 public:
103 IDBKeyFromValueAndKeyPathTest() 103 IDBKeyFromValueAndKeyPathTest()
104 : m_scope(v8::Isolate::GetCurrent()) 104 : m_scope(v8::Isolate::GetCurrent())
105 { 105 {
106 } 106 }
107 107
108 ScriptState* scriptState() const { return m_scope.scriptState(); } 108 ScriptState* getScriptState() const { return m_scope.getScriptState(); }
109 109
110 private: 110 private:
111 V8TestingScope m_scope; 111 V8TestingScope m_scope;
112 }; 112 };
113 113
114 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) 114 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue)
115 { 115 {
116 v8::Isolate* isolate = scriptState()->isolate(); 116 v8::Isolate* isolate = getScriptState()->isolate();
117 117
118 // object = { foo: "zoo" } 118 // object = { foo: "zoo" }
119 v8::Local<v8::Object> object = v8::Object::New(isolate); 119 v8::Local<v8::Object> object = v8::Object::New(isolate);
120 ASSERT_TRUE(v8CallBoolean(object->Set(scriptState()->context(), v8AtomicStri ng(isolate, "foo"), v8AtomicString(isolate, "zoo")))); 120 ASSERT_TRUE(v8CallBoolean(object->Set(getScriptState()->context(), v8AtomicS tring(isolate, "foo"), v8AtomicString(isolate, "zoo"))));
121 121
122 ScriptValue scriptValue(scriptState(), object); 122 ScriptValue scriptValue(getScriptState(), object);
123 123
124 checkKeyPathStringValue(isolate, scriptValue, "foo", "zoo"); 124 checkKeyPathStringValue(isolate, scriptValue, "foo", "zoo");
125 checkKeyPathNullValue(isolate, scriptValue, "bar"); 125 checkKeyPathNullValue(isolate, scriptValue, "bar");
126 } 126 }
127 127
128 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) 128 TEST_F(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue)
129 { 129 {
130 v8::Isolate* isolate = scriptState()->isolate(); 130 v8::Isolate* isolate = getScriptState()->isolate();
131 131
132 // object = { foo: 456 } 132 // object = { foo: 456 }
133 v8::Local<v8::Object> object = v8::Object::New(isolate); 133 v8::Local<v8::Object> object = v8::Object::New(isolate);
134 ASSERT_TRUE(v8CallBoolean(object->Set(scriptState()->context(), v8AtomicStri ng(isolate, "foo"), v8::Number::New(isolate, 456)))); 134 ASSERT_TRUE(v8CallBoolean(object->Set(getScriptState()->context(), v8AtomicS tring(isolate, "foo"), v8::Number::New(isolate, 456))));
135 135
136 ScriptValue scriptValue(scriptState(), object); 136 ScriptValue scriptValue(getScriptState(), object);
137 137
138 checkKeyPathNumberValue(isolate, scriptValue, "foo", 456); 138 checkKeyPathNumberValue(isolate, scriptValue, "foo", 456);
139 checkKeyPathNullValue(isolate, scriptValue, "bar"); 139 checkKeyPathNullValue(isolate, scriptValue, "bar");
140 } 140 }
141 141
142 TEST_F(IDBKeyFromValueAndKeyPathTest, SubProperty) 142 TEST_F(IDBKeyFromValueAndKeyPathTest, SubProperty)
143 { 143 {
144 v8::Isolate* isolate = scriptState()->isolate(); 144 v8::Isolate* isolate = getScriptState()->isolate();
145 145
146 // object = { foo: { bar: "zee" } } 146 // object = { foo: { bar: "zee" } }
147 v8::Local<v8::Object> object = v8::Object::New(isolate); 147 v8::Local<v8::Object> object = v8::Object::New(isolate);
148 v8::Local<v8::Object> subProperty = v8::Object::New(isolate); 148 v8::Local<v8::Object> subProperty = v8::Object::New(isolate);
149 ASSERT_TRUE(v8CallBoolean(subProperty->Set(scriptState()->context(), v8Atomi cString(isolate, "bar"), v8AtomicString(isolate, "zee")))); 149 ASSERT_TRUE(v8CallBoolean(subProperty->Set(getScriptState()->context(), v8At omicString(isolate, "bar"), v8AtomicString(isolate, "zee"))));
150 ASSERT_TRUE(v8CallBoolean(object->Set(scriptState()->context(), v8AtomicStri ng(isolate, "foo"), subProperty))); 150 ASSERT_TRUE(v8CallBoolean(object->Set(getScriptState()->context(), v8AtomicS tring(isolate, "foo"), subProperty)));
151 151
152 ScriptValue scriptValue(scriptState(), object); 152 ScriptValue scriptValue(getScriptState(), object);
153 153
154 checkKeyPathStringValue(isolate, scriptValue, "foo.bar", "zee"); 154 checkKeyPathStringValue(isolate, scriptValue, "foo.bar", "zee");
155 checkKeyPathNullValue(isolate, scriptValue, "bar"); 155 checkKeyPathNullValue(isolate, scriptValue, "bar");
156 } 156 }
157 157
158 class InjectIDBKeyTest : public IDBKeyFromValueAndKeyPathTest { 158 class InjectIDBKeyTest : public IDBKeyFromValueAndKeyPathTest {
159 }; 159 };
160 160
161 TEST_F(InjectIDBKeyTest, ImplicitValues) 161 TEST_F(InjectIDBKeyTest, ImplicitValues)
162 { 162 {
163 v8::Isolate* isolate = scriptState()->isolate(); 163 v8::Isolate* isolate = getScriptState()->isolate();
164 { 164 {
165 v8::Local<v8::String> string = v8String(isolate, "string"); 165 v8::Local<v8::String> string = v8String(isolate, "string");
166 ScriptValue value = ScriptValue(scriptState(), string); 166 ScriptValue value = ScriptValue(getScriptState(), string);
167 checkInjectionIgnored(scriptState(), IDBKey::createNumber(123), value, " length"); 167 checkInjectionIgnored(getScriptState(), IDBKey::createNumber(123), value , "length");
168 } 168 }
169 { 169 {
170 v8::Local<v8::Array> array = v8::Array::New(isolate); 170 v8::Local<v8::Array> array = v8::Array::New(isolate);
171 ScriptValue value = ScriptValue(scriptState(), array); 171 ScriptValue value = ScriptValue(getScriptState(), array);
172 checkInjectionIgnored(scriptState(), IDBKey::createNumber(456), value, " length"); 172 checkInjectionIgnored(getScriptState(), IDBKey::createNumber(456), value , "length");
173 } 173 }
174 } 174 }
175 175
176 TEST_F(InjectIDBKeyTest, TopLevelPropertyStringValue) 176 TEST_F(InjectIDBKeyTest, TopLevelPropertyStringValue)
177 { 177 {
178 v8::Isolate* isolate = scriptState()->isolate(); 178 v8::Isolate* isolate = getScriptState()->isolate();
179 179
180 // object = { foo: "zoo" } 180 // object = { foo: "zoo" }
181 v8::Local<v8::Object> object = v8::Object::New(isolate); 181 v8::Local<v8::Object> object = v8::Object::New(isolate);
182 ASSERT_TRUE(v8CallBoolean(object->Set(scriptState()->context(), v8AtomicStri ng(isolate, "foo"), v8AtomicString(isolate, "zoo")))); 182 ASSERT_TRUE(v8CallBoolean(object->Set(getScriptState()->context(), v8AtomicS tring(isolate, "foo"), v8AtomicString(isolate, "zoo"))));
183 183
184 ScriptValue scriptObject(scriptState(), object); 184 ScriptValue scriptObject(getScriptState(), object);
185 checkInjection(scriptState(), IDBKey::createString("myNewKey"), scriptObject , "bar"); 185 checkInjection(getScriptState(), IDBKey::createString("myNewKey"), scriptObj ect, "bar");
186 checkInjection(scriptState(), IDBKey::createNumber(1234), scriptObject, "bar "); 186 checkInjection(getScriptState(), IDBKey::createNumber(1234), scriptObject, " bar");
187 187
188 checkInjectionDisallowed(scriptState(), scriptObject, "foo.bar"); 188 checkInjectionDisallowed(getScriptState(), scriptObject, "foo.bar");
189 } 189 }
190 190
191 TEST_F(InjectIDBKeyTest, SubProperty) 191 TEST_F(InjectIDBKeyTest, SubProperty)
192 { 192 {
193 v8::Isolate* isolate = scriptState()->isolate(); 193 v8::Isolate* isolate = getScriptState()->isolate();
194 194
195 // object = { foo: { bar: "zee" } } 195 // object = { foo: { bar: "zee" } }
196 v8::Local<v8::Object> object = v8::Object::New(isolate); 196 v8::Local<v8::Object> object = v8::Object::New(isolate);
197 v8::Local<v8::Object> subProperty = v8::Object::New(isolate); 197 v8::Local<v8::Object> subProperty = v8::Object::New(isolate);
198 ASSERT_TRUE(v8CallBoolean(subProperty->Set(scriptState()->context(), v8Atomi cString(isolate, "bar"), v8AtomicString(isolate, "zee")))); 198 ASSERT_TRUE(v8CallBoolean(subProperty->Set(getScriptState()->context(), v8At omicString(isolate, "bar"), v8AtomicString(isolate, "zee"))));
199 ASSERT_TRUE(v8CallBoolean(object->Set(scriptState()->context(), v8AtomicStri ng(isolate, "foo"), subProperty))); 199 ASSERT_TRUE(v8CallBoolean(object->Set(getScriptState()->context(), v8AtomicS tring(isolate, "foo"), subProperty)));
200 200
201 ScriptValue scriptObject(scriptState(), object); 201 ScriptValue scriptObject(getScriptState(), object);
202 checkInjection(scriptState(), IDBKey::createString("myNewKey"), scriptObject , "foo.baz"); 202 checkInjection(getScriptState(), IDBKey::createString("myNewKey"), scriptObj ect, "foo.baz");
203 checkInjection(scriptState(), IDBKey::createNumber(789), scriptObject, "foo. baz"); 203 checkInjection(getScriptState(), IDBKey::createNumber(789), scriptObject, "f oo.baz");
204 checkInjection(scriptState(), IDBKey::createDate(4567), scriptObject, "foo.b az"); 204 checkInjection(getScriptState(), IDBKey::createDate(4567), scriptObject, "fo o.baz");
205 checkInjection(scriptState(), IDBKey::createDate(4567), scriptObject, "bar") ; 205 checkInjection(getScriptState(), IDBKey::createDate(4567), scriptObject, "ba r");
206 checkInjection(scriptState(), IDBKey::createArray(IDBKey::KeyArray()), scrip tObject, "foo.baz"); 206 checkInjection(getScriptState(), IDBKey::createArray(IDBKey::KeyArray()), sc riptObject, "foo.baz");
207 checkInjection(scriptState(), IDBKey::createArray(IDBKey::KeyArray()), scrip tObject, "bar"); 207 checkInjection(getScriptState(), IDBKey::createArray(IDBKey::KeyArray()), sc riptObject, "bar");
208 208
209 checkInjectionDisallowed(scriptState(), scriptObject, "foo.bar.baz"); 209 checkInjectionDisallowed(getScriptState(), scriptObject, "foo.bar.baz");
210 checkInjection(scriptState(), IDBKey::createString("zoo"), scriptObject, "fo o.xyz.foo"); 210 checkInjection(getScriptState(), IDBKey::createString("zoo"), scriptObject, "foo.xyz.foo");
211 } 211 }
212 212
213 } // namespace 213 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698