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

Side by Side Diff: Source/bindings/core/v8/V8BindingForTesting.cpp

Issue 1013413002: [bindings] Refactor ScriptStateForTesting, V8TestingScope into V8BindingForTesting.h/cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Combined all testing files into one! Created 5 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 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 "config.h" 5 #include "config.h"
6 #include "bindings/core/v8/V8TestingScope.h" 6 #include "bindings/core/v8/V8BindingForTesting.h"
7 7
8 #include "bindings/core/v8/DOMWrapperWorld.h" 8 #include "bindings/core/v8/DOMWrapperWorld.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 PassRefPtr<ScriptStateForTesting> ScriptStateForTesting::create(v8::Handle<v8::C ontext> context, PassRefPtr<DOMWrapperWorld> world)
13 {
14 RefPtr<ScriptStateForTesting> scriptState = adoptRef(new ScriptStateForTesti ng(context, world));
15 // This ref() is for keeping this ScriptState alive as long as the v8::Conte xt is alive.
16 // This is deref()ed in the weak callback of the v8::Context.
Nico 2015/08/29 21:42:48 This seems to not work, see http://build.chromium.
haraken 2015/08/30 01:26:07 I think this is an issue of ScriptPromisePropertyT
17 scriptState->ref();
18 return scriptState;
19 }
20
21 ScriptStateForTesting::ScriptStateForTesting(v8::Handle<v8::Context> context, Pa ssRefPtr<DOMWrapperWorld> world)
22 : ScriptState(context, world)
23 {
24 }
25
26 ExecutionContext* ScriptStateForTesting::executionContext() const
27 {
28 return m_executionContext;
29 }
30
31 void ScriptStateForTesting::setExecutionContext(ExecutionContext* executionConte xt)
32 {
33 m_executionContext = executionContext;
34 }
35
12 V8TestingScope::V8TestingScope(v8::Isolate* isolate) 36 V8TestingScope::V8TestingScope(v8::Isolate* isolate)
13 : m_handleScope(isolate) 37 : m_handleScope(isolate)
14 , m_contextScope(v8::Context::New(isolate)) 38 , m_contextScope(v8::Context::New(isolate))
15 // We reuse the main world since the main world is guaranteed to be register ed to ScriptController. 39 // We reuse the main world since the main world is guaranteed to be register ed to ScriptController.
16 , m_scriptState(ScriptStateForTesting::create(isolate->GetCurrentContext(), &DOMWrapperWorld::mainWorld())) 40 , m_scriptState(ScriptStateForTesting::create(isolate->GetCurrentContext(), &DOMWrapperWorld::mainWorld()))
17 { 41 {
18 } 42 }
19 43
20 V8TestingScope::~V8TestingScope() 44 V8TestingScope::~V8TestingScope()
21 { 45 {
22 m_scriptState->disposePerContextData(); 46 m_scriptState->disposePerContextData();
23 } 47 }
24 48
25 ScriptState* V8TestingScope::scriptState() const 49 ScriptState* V8TestingScope::scriptState() const
26 { 50 {
27 return m_scriptState.get(); 51 return m_scriptState.get();
28 } 52 }
29 53
30 v8::Isolate* V8TestingScope::isolate() const 54 v8::Isolate* V8TestingScope::isolate() const
31 { 55 {
32 return m_scriptState->isolate(); 56 return m_scriptState->isolate();
33 } 57 }
34 58
35 } // namespace blink 59 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8BindingForTesting.h ('k') | Source/bindings/core/v8/V8BindingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698