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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp

Issue 1912093002: Require that heap collections are used over traceable elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | third_party/WebKit/Source/platform/heap/HeapAllocator.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "bindings/core/v8/ToV8.h" 5 #include "bindings/core/v8/ToV8.h"
6 6
7 #include "bindings/core/v8/V8Binding.h" 7 #include "bindings/core/v8/V8Binding.h"
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "core/testing/GarbageCollectedScriptWrappable.h" 9 #include "core/testing/GarbageCollectedScriptWrappable.h"
10 #include "platform/heap/Heap.h" 10 #include "platform/heap/Heap.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 TEST_F(ToV8Test, heapVector) 217 TEST_F(ToV8Test, heapVector)
218 { 218 {
219 HeapVector<Member<GarbageCollectedScriptWrappable>> v; 219 HeapVector<Member<GarbageCollectedScriptWrappable>> v;
220 v.append(new GarbageCollectedScriptWrappable("hoge")); 220 v.append(new GarbageCollectedScriptWrappable("hoge"));
221 v.append(new GarbageCollectedScriptWrappable("fuga")); 221 v.append(new GarbageCollectedScriptWrappable("fuga"));
222 v.append(nullptr); 222 v.append(nullptr);
223 223
224 TEST_TOV8("hoge,fuga,", v); 224 TEST_TOV8("hoge,fuga,", v);
225 } 225 }
226 226
227 TEST_F(ToV8Test, stringHeapVectors)
228 {
229 HeapVector<String> stringVector;
230 stringVector.append("foo");
231 stringVector.append("bar");
232 TEST_TOV8("foo,bar", stringVector);
233
234 HeapVector<AtomicString> atomicStringVector;
235 atomicStringVector.append("quux");
236 atomicStringVector.append("bar");
237 TEST_TOV8("quux,bar", atomicStringVector);
238 }
239
240 TEST_F(ToV8Test, basicTypeHeapVectors)
241 {
242 HeapVector<int> intVector;
243 intVector.append(42);
244 intVector.append(23);
245 TEST_TOV8("42,23", intVector);
246
247 HeapVector<long> longVector;
248 longVector.append(31773);
249 longVector.append(404);
250 TEST_TOV8("31773,404", longVector);
251
252 HeapVector<unsigned> unsignedVector;
253 unsignedVector.append(1);
254 unsignedVector.append(2);
255 TEST_TOV8("1,2", unsignedVector);
256
257 HeapVector<unsigned long> unsignedLongVector;
258 unsignedLongVector.append(1001);
259 unsignedLongVector.append(2002);
260 TEST_TOV8("1001,2002", unsignedLongVector);
261
262 HeapVector<float> floatVector;
263 floatVector.append(0.125);
264 floatVector.append(1.);
265 TEST_TOV8("0.125,1", floatVector);
266
267 HeapVector<double> doubleVector;
268 doubleVector.append(2.3);
269 doubleVector.append(4.2);
270 TEST_TOV8("2.3,4.2", doubleVector);
271
272 HeapVector<bool> boolVector;
273 boolVector.append(true);
274 boolVector.append(true);
275 boolVector.append(false);
276 TEST_TOV8("true,true,false", boolVector);
277 }
278
279 TEST_F(ToV8Test, withScriptState) 227 TEST_F(ToV8Test, withScriptState)
280 { 228 {
281 ScriptValue value(m_scope.getScriptState(), v8::Number::New(m_scope.isolate( ), 1234.0)); 229 ScriptValue value(m_scope.getScriptState(), v8::Number::New(m_scope.isolate( ), 1234.0));
282 230
283 v8::Local<v8::Value> actual = toV8(value, m_scope.getScriptState()); 231 v8::Local<v8::Value> actual = toV8(value, m_scope.getScriptState());
284 EXPECT_FALSE(actual.IsEmpty()); 232 EXPECT_FALSE(actual.IsEmpty());
285 233
286 double actualAsNumber = actual.As<v8::Number>()->Value(); 234 double actualAsNumber = actual.As<v8::Number>()->Value();
287 EXPECT_EQ(1234.0, actualAsNumber); 235 EXPECT_EQ(1234.0, actualAsNumber);
288 } 236 }
289 237
290 } // namespace 238 } // namespace
291 239
292 } // namespace blink 240 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapAllocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698