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

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

Issue 2574523004: Don't touch the prototype chain to get the private script controller. (Closed)
Patch Set: Created 4 years 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 #include "bindings/core/v8/PrivateScriptRunner.h" 5 #include "bindings/core/v8/PrivateScriptRunner.h"
6 6
7 #include "bindings/core/v8/DOMWrapperWorld.h" 7 #include "bindings/core/v8/DOMWrapperWorld.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 #include "bindings/core/v8/V8PerContextData.h" 10 #include "bindings/core/v8/V8PerContextData.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 String scriptClassName, 50 String scriptClassName,
51 const char* source, 51 const char* source,
52 size_t size) { 52 size_t size) {
53 v8::Isolate* isolate = scriptState->isolate(); 53 v8::Isolate* isolate = scriptState->isolate();
54 v8::TryCatch block(isolate); 54 v8::TryCatch block(isolate);
55 String sourceString(source, size); 55 String sourceString(source, size);
56 String fileName = scriptClassName + ".js"; 56 String fileName = scriptClassName + ".js";
57 57
58 v8::Local<v8::Context> context = scriptState->context(); 58 v8::Local<v8::Context> context = scriptState->context();
59 v8::Local<v8::Object> global = context->Global(); 59 v8::Local<v8::Object> global = context->Global();
60 v8::Local<v8::Value> privateScriptController = 60 v8::Local<v8::String> key = v8String(isolate, "privateScriptController");
61 global->Get(context, v8String(isolate, "privateScriptController")) 61
62 .ToLocalChecked(); 62 if (global->HasOwnProperty(context, key).ToChecked()) {
63 RELEASE_ASSERT(privateScriptController->IsUndefined() || 63 v8::Local<v8::Value> privateScriptController =
64 privateScriptController->IsObject()); 64 global->Get(context, key).ToLocalChecked();
65 if (privateScriptController->IsObject()) { 65 CHECK(privateScriptController->IsObject());
66 v8::Local<v8::Object> privateScriptControllerObject = 66 v8::Local<v8::Object> privateScriptControllerObject =
67 privateScriptController.As<v8::Object>(); 67 privateScriptController.As<v8::Object>();
68 v8::Local<v8::Value> importFunctionValue = 68 v8::Local<v8::Value> importFunctionValue =
69 privateScriptControllerObject->Get(context, v8String(isolate, "import")) 69 privateScriptControllerObject->Get(context, v8String(isolate, "import"))
70 .ToLocalChecked(); 70 .ToLocalChecked();
71 if (importFunctionValue->IsUndefined()) { 71 if (importFunctionValue->IsUndefined()) {
72 v8::Local<v8::Function> function; 72 v8::Local<v8::Function> function;
73 // This is a memory leak, FunctionTemplates are eternal. 73 // This is a memory leak, FunctionTemplates are eternal.
74 if (!v8::FunctionTemplate::New(isolate, importFunction) 74 if (!v8::FunctionTemplate::New(isolate, importFunction)
75 ->GetFunction(context) 75 ->GetFunction(context)
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 rethrowExceptionInPrivateScript( 499 rethrowExceptionInPrivateScript(
500 scriptState->isolate(), block, scriptStateInUserScript, 500 scriptState->isolate(), block, scriptStateInUserScript,
501 ExceptionState::ExecutionContext, methodName, className); 501 ExceptionState::ExecutionContext, methodName, className);
502 block.ReThrow(); 502 block.ReThrow();
503 return v8::Local<v8::Value>(); 503 return v8::Local<v8::Value>();
504 } 504 }
505 return result; 505 return result;
506 } 506 }
507 507
508 } // namespace blink 508 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698