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

Side by Side Diff: src/contexts.cc

Issue 10837358: Throw a more descriptive exception when blocking 'eval' via CSP. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add SetErrorMessageForCodeGenerationFromStrings API function. Created 8 years, 3 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 | « src/contexts.h ('k') | src/messages.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 ASSERT(IsNativeContext()); 298 ASSERT(IsNativeContext());
299 return get(OPTIMIZED_FUNCTIONS_LIST); 299 return get(OPTIMIZED_FUNCTIONS_LIST);
300 } 300 }
301 301
302 302
303 void Context::ClearOptimizedFunctions() { 303 void Context::ClearOptimizedFunctions() {
304 set(OPTIMIZED_FUNCTIONS_LIST, GetHeap()->undefined_value()); 304 set(OPTIMIZED_FUNCTIONS_LIST, GetHeap()->undefined_value());
305 } 305 }
306 306
307 307
308 Handle<Object> Context::ErrorMessageForCodeGenerationFromStrings() {
309 Handle<Object> result(error_message_for_code_gen_from_strings());
310 if (result->IsUndefined()) {
311 const char* error =
312 "Code generation from strings disallowed for this context";
313 Isolate* isolate = Isolate::Current();
314 result = isolate->factory()->NewStringFromAscii(i::CStrVector(error));
315 }
316 return result;
317 }
318
319
308 #ifdef DEBUG 320 #ifdef DEBUG
309 bool Context::IsBootstrappingOrValidParentContext( 321 bool Context::IsBootstrappingOrValidParentContext(
310 Object* object, Context* child) { 322 Object* object, Context* child) {
311 // During bootstrapping we allow all objects to pass as 323 // During bootstrapping we allow all objects to pass as
312 // contexts. This is necessary to fix circular dependencies. 324 // contexts. This is necessary to fix circular dependencies.
313 if (Isolate::Current()->bootstrapper()->IsActive()) return true; 325 if (Isolate::Current()->bootstrapper()->IsActive()) return true;
314 if (!object->IsContext()) return false; 326 if (!object->IsContext()) return false;
315 Context* context = Context::cast(object); 327 Context* context = Context::cast(object);
316 return context->IsNativeContext() || context->IsGlobalContext() || 328 return context->IsNativeContext() || context->IsGlobalContext() ||
317 context->IsModuleContext() || !child->IsModuleContext(); 329 context->IsModuleContext() || !child->IsModuleContext();
318 } 330 }
319 331
320 332
321 bool Context::IsBootstrappingOrGlobalObject(Object* object) { 333 bool Context::IsBootstrappingOrGlobalObject(Object* object) {
322 // During bootstrapping we allow all objects to pass as global 334 // During bootstrapping we allow all objects to pass as global
323 // objects. This is necessary to fix circular dependencies. 335 // objects. This is necessary to fix circular dependencies.
324 Isolate* isolate = Isolate::Current(); 336 Isolate* isolate = Isolate::Current();
325 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || 337 return isolate->heap()->gc_state() != Heap::NOT_IN_GC ||
326 isolate->bootstrapper()->IsActive() || 338 isolate->bootstrapper()->IsActive() ||
327 object->IsGlobalObject(); 339 object->IsGlobalObject();
328 } 340 }
329 #endif 341 #endif
330 342
331 } } // namespace v8::internal 343 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698