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

Side by Side Diff: Source/core/testing/v8/WebCoreTestSupport.cpp

Issue 1215953003: Construct Internals with a ScriptState (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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 | « Source/core/testing/Internals.idl ('k') | 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 25 matching lines...) Expand all
36 using namespace blink; 36 using namespace blink;
37 37
38 namespace WebCoreTestSupport { 38 namespace WebCoreTestSupport {
39 39
40 v8::Local<v8::Value> createInternalsObject(v8::Local<v8::Context> context) 40 v8::Local<v8::Value> createInternalsObject(v8::Local<v8::Context> context)
41 { 41 {
42 ScriptState* scriptState = ScriptState::from(context); 42 ScriptState* scriptState = ScriptState::from(context);
43 v8::Local<v8::Object> global = scriptState->context()->Global(); 43 v8::Local<v8::Object> global = scriptState->context()->Global();
44 ExecutionContext* executionContext = scriptState->executionContext(); 44 ExecutionContext* executionContext = scriptState->executionContext();
45 if (executionContext->isDocument()) 45 if (executionContext->isDocument())
46 return toV8(Internals::create(toDocument(executionContext)), global, scr iptState->isolate()); 46 return toV8(Internals::create(scriptState), global, scriptState->isolate ());
47 return v8::Local<v8::Value>(); 47 return v8::Local<v8::Value>();
48 } 48 }
49 49
50 void injectInternalsObject(v8::Local<v8::Context> context) 50 void injectInternalsObject(v8::Local<v8::Context> context)
51 { 51 {
52 ScriptState* scriptState = ScriptState::from(context); 52 ScriptState* scriptState = ScriptState::from(context);
53 ScriptState::Scope scope(scriptState); 53 ScriptState::Scope scope(scriptState);
54 v8::Local<v8::Object> global = scriptState->context()->Global(); 54 v8::Local<v8::Object> global = scriptState->context()->Global();
55 v8::Local<v8::Value> internals = createInternalsObject(context); 55 v8::Local<v8::Value> internals = createInternalsObject(context);
56 if (internals.IsEmpty()) 56 if (internals.IsEmpty())
57 return; 57 return;
58 v8CallOrCrash(global->Set(scriptState->context(), v8AtomicString(scriptState ->isolate(), Internals::internalsId), internals)); 58 v8CallOrCrash(global->Set(scriptState->context(), v8AtomicString(scriptState ->isolate(), Internals::internalsId), internals));
59 } 59 }
60 60
61 void resetInternalsObject(v8::Local<v8::Context> context) 61 void resetInternalsObject(v8::Local<v8::Context> context)
62 { 62 {
63 // This can happen if JavaScript is disabled in the main frame. 63 // This can happen if JavaScript is disabled in the main frame.
64 if (context.IsEmpty()) 64 if (context.IsEmpty())
65 return; 65 return;
66 66
67 ScriptState* scriptState = ScriptState::from(context); 67 ScriptState* scriptState = ScriptState::from(context);
68 ScriptState::Scope scope(scriptState); 68 ScriptState::Scope scope(scriptState);
69 Page* page = toDocument(scriptState->executionContext())->frame()->page(); 69 Page* page = toDocument(scriptState->executionContext())->frame()->page();
70 ASSERT(page); 70 ASSERT(page);
71 Internals::resetToConsistentState(page); 71 Internals::resetToConsistentState(page);
72 InternalSettings::from(*page)->resetToConsistentState(); 72 InternalSettings::from(*page)->resetToConsistentState();
73 } 73 }
74 74
75 } 75 }
OLDNEW
« no previous file with comments | « Source/core/testing/Internals.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698