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

Side by Side Diff: Source/bindings/v8/ScriptPromiseTest.cpp

Issue 180743013: Ensure DOMWrapperWorld always exists in all webkit_unit_tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/ScriptPromiseResolverTest.cpp ('k') | Source/bindings/v8/V8Binding.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 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 29 matching lines...) Expand all
40 #include <v8.h> 40 #include <v8.h>
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 namespace { 44 namespace {
45 45
46 class ScriptPromiseTest : public testing::Test { 46 class ScriptPromiseTest : public testing::Test {
47 public: 47 public:
48 ScriptPromiseTest() 48 ScriptPromiseTest()
49 : m_isolate(v8::Isolate::GetCurrent()) 49 : m_isolate(v8::Isolate::GetCurrent())
50 , m_handleScope(m_isolate)
51 , m_context(m_isolate, v8::Context::New(m_isolate))
52 , m_contextScope(m_context.newLocal(m_isolate))
53 { 50 {
54 } 51 }
55 52
56 void SetUp() 53 void SetUp()
57 { 54 {
58 // FIXME: Create a new world and pass it to V8PerContextData. 55 m_scope = V8BindingTestScope::create(m_isolate);
59 m_perContextData = V8PerContextData::create(m_context.newLocal(m_isolate ), 0);
60 } 56 }
61 57
62 void TearDown() 58 void TearDown()
63 { 59 {
64 m_perContextData.clear(); 60 m_scope.clear();
65 } 61 }
66 62
67 V8PromiseCustom::PromiseState state(ScriptPromise promise) 63 V8PromiseCustom::PromiseState state(ScriptPromise promise)
68 { 64 {
69 return V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise.v8 Value().As<v8::Object>())); 65 return V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise.v8 Value().As<v8::Object>()));
70 } 66 }
71 67
72 protected: 68 protected:
73 v8::Isolate* m_isolate; 69 v8::Isolate* m_isolate;
74 v8::HandleScope m_handleScope; 70
75 ScopedPersistent<v8::Context> m_context; 71 private:
76 v8::Context::Scope m_contextScope; 72 OwnPtr<V8BindingTestScope> m_scope;
77 OwnPtr<V8PerContextData> m_perContextData;
78 }; 73 };
79 74
80 TEST_F(ScriptPromiseTest, castPromise) 75 TEST_F(ScriptPromiseTest, castPromise)
81 { 76 {
82 ScriptPromise promise = ScriptPromise::createPending(); 77 ScriptPromise promise = ScriptPromise::createPending();
83 ScriptPromise newPromise(ScriptValue(promise.v8Value(), m_isolate)); 78 ScriptPromise newPromise(ScriptValue(promise.v8Value(), m_isolate));
84 79
85 ASSERT_FALSE(promise.hasNoValue()); 80 ASSERT_FALSE(promise.hasNoValue());
86 EXPECT_EQ(V8PromiseCustom::Pending, state(promise)); 81 EXPECT_EQ(V8PromiseCustom::Pending, state(promise));
87 EXPECT_EQ(promise.v8Value(), newPromise.v8Value()); 82 EXPECT_EQ(promise.v8Value(), newPromise.v8Value());
(...skipping 12 matching lines...) Expand all
100 ASSERT_TRUE(V8PromiseCustom::isPromise(promise2.v8Value(), m_isolate)); 95 ASSERT_TRUE(V8PromiseCustom::isPromise(promise2.v8Value(), m_isolate));
101 96
102 EXPECT_EQ(V8PromiseCustom::Fulfilled, state(promise1)); 97 EXPECT_EQ(V8PromiseCustom::Fulfilled, state(promise1));
103 EXPECT_EQ(V8PromiseCustom::Fulfilled, state(promise2)); 98 EXPECT_EQ(V8PromiseCustom::Fulfilled, state(promise2));
104 EXPECT_NE(promise1.v8Value(), promise2.v8Value()); 99 EXPECT_NE(promise1.v8Value(), promise2.v8Value());
105 } 100 }
106 101
107 } // namespace 102 } // namespace
108 103
109 } // namespace WebCore 104 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptPromiseResolverTest.cpp ('k') | Source/bindings/v8/V8Binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698