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

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

Issue 2605853002: Remove an isContextInitialized() check from ScriptController::executeScriptInIsolatedWorld (Closed)
Patch Set: Created 3 years, 12 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 | no next file » | 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) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 void ScriptController::executeScriptInIsolatedWorld( 465 void ScriptController::executeScriptInIsolatedWorld(
466 int worldID, 466 int worldID,
467 const HeapVector<ScriptSourceCode>& sources, 467 const HeapVector<ScriptSourceCode>& sources,
468 int extensionGroup, 468 int extensionGroup,
469 Vector<v8::Local<v8::Value>>* results) { 469 Vector<v8::Local<v8::Value>>* results) {
470 ASSERT(worldID > 0); 470 ASSERT(worldID > 0);
471 471
472 RefPtr<DOMWrapperWorld> world = 472 RefPtr<DOMWrapperWorld> world =
473 DOMWrapperWorld::ensureIsolatedWorld(isolate(), worldID, extensionGroup); 473 DOMWrapperWorld::ensureIsolatedWorld(isolate(), worldID, extensionGroup);
474 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); 474 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world);
475 if (!isolatedWorldWindowProxy->isContextInitialized()) 475 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState();
476 if (!scriptState->contextIsValid())
476 return; 477 return;
477
478 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState();
479 v8::Context::Scope scope(scriptState->context()); 478 v8::Context::Scope scope(scriptState->context());
480 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size()); 479 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size());
481 480
482 for (size_t i = 0; i < sources.size(); ++i) { 481 for (size_t i = 0; i < sources.size(); ++i) {
483 v8::Local<v8::Value> evaluationResult = 482 v8::Local<v8::Value> evaluationResult =
484 executeScriptAndReturnValue(scriptState->context(), sources[i]); 483 executeScriptAndReturnValue(scriptState->context(), sources[i]);
485 if (evaluationResult.IsEmpty()) 484 if (evaluationResult.IsEmpty())
486 evaluationResult = 485 evaluationResult =
487 v8::Local<v8::Value>::New(isolate(), v8::Undefined(isolate())); 486 v8::Local<v8::Value>::New(isolate(), v8::Undefined(isolate()));
488 if (!v8CallBoolean(resultArray->CreateDataProperty(scriptState->context(), 487 if (!v8CallBoolean(resultArray->CreateDataProperty(scriptState->context(),
489 i, evaluationResult))) 488 i, evaluationResult)))
490 return; 489 return;
491 } 490 }
492 491
493 if (results) { 492 if (results) {
494 for (size_t i = 0; i < resultArray->Length(); ++i) { 493 for (size_t i = 0; i < resultArray->Length(); ++i) {
495 v8::Local<v8::Value> value; 494 v8::Local<v8::Value> value;
496 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) 495 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value))
497 return; 496 return;
498 results->push_back(value); 497 results->push_back(value);
499 } 498 }
500 } 499 }
501 } 500 }
502 501
503 } // namespace blink 502 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698