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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.h

Issue 2644343002: Add AllowUserAgentScript in ScriptPromiseResolver::resolveOrReject (Closed)
Patch Set: Remove isScriptForbidden check in HTMLMediaElement Created 3 years, 11 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 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 #ifndef ScriptPromiseResolver_h 5 #ifndef ScriptPromiseResolver_h
6 #define ScriptPromiseResolver_h 6 #define ScriptPromiseResolver_h
7 7
8 #include "bindings/core/v8/ScopedPersistent.h" 8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 template <typename T> 120 template <typename T>
121 void resolveOrReject(T value, ResolutionState newState) { 121 void resolveOrReject(T value, ResolutionState newState) {
122 if (m_state != Pending || !getScriptState()->contextIsValid() || 122 if (m_state != Pending || !getScriptState()->contextIsValid() ||
123 !getExecutionContext() || getExecutionContext()->isContextDestroyed()) 123 !getExecutionContext() || getExecutionContext()->isContextDestroyed())
124 return; 124 return;
125 ASSERT(newState == Resolving || newState == Rejecting); 125 ASSERT(newState == Resolving || newState == Rejecting);
126 m_state = newState; 126 m_state = newState;
127 127
128 ScriptState::Scope scope(m_scriptState.get()); 128 ScriptState::Scope scope(m_scriptState.get());
129 // TODO(aobzhirov): Converting value to the wrapper can trigger assert 129
130 // if the script is forbidden. 130 // Calling ToV8 in a ScriptForbiddenScope will trigger a RELEASE_ASSERT and
131 // The script check below will be unreachable in this case. 131 // cause a crash. ToV8 just invokes a constructor for wrapper creation,
132 m_value.set(m_scriptState->isolate(), 132 // which is safe (no author script can be run). Adding AllowUserAgentScript
133 ToV8(value, m_scriptState->context()->Global(), 133 // directly inside createWrapper could cause a perf impact (calling
134 m_scriptState->isolate())); 134 // isMainThread() every time a wrapper is created is expensive). Ideally,
135 // resolveOrReject shouldn't be called inside a ScriptForbiddenScope.
136 {
137 ScriptForbiddenScope::AllowUserAgentScript allowScript;
138 m_value.set(m_scriptState->isolate(),
139 ToV8(value, m_scriptState->context()->Global(),
haraken 2017/01/21 01:51:09 Are we pretty sure that we have no way to invoke a
adithyas 2017/01/23 15:43:30 If I understand correctly, the constructors called
140 m_scriptState->isolate()));
141 }
135 142
136 if (getExecutionContext()->isContextSuspended()) { 143 if (getExecutionContext()->isContextSuspended()) {
137 // Retain this object until it is actually resolved or rejected. 144 // Retain this object until it is actually resolved or rejected.
138 keepAliveWhilePending(); 145 keepAliveWhilePending();
139 return; 146 return;
140 } 147 }
141 // TODO(esprehn): This is a hack, instead we should RELEASE_ASSERT that 148 // TODO(esprehn): This is a hack, instead we should RELEASE_ASSERT that
142 // script is allowed, and v8 should be running the entry hooks below and 149 // script is allowed, and v8 should be running the entry hooks below and
143 // crashing if script is forbidden. We should then audit all users of 150 // crashing if script is forbidden. We should then audit all users of
144 // ScriptPromiseResolver and the related specs and switch to an async 151 // ScriptPromiseResolver and the related specs and switch to an async
(...skipping 21 matching lines...) Expand all
166 173
167 #if DCHECK_IS_ON() 174 #if DCHECK_IS_ON()
168 // True if promise() is called. 175 // True if promise() is called.
169 bool m_isPromiseCalled = false; 176 bool m_isPromiseCalled = false;
170 #endif 177 #endif
171 }; 178 };
172 179
173 } // namespace blink 180 } // namespace blink
174 181
175 #endif // ScriptPromiseResolver_h 182 #endif // ScriptPromiseResolver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698