Changeset 116744 in webkit


Ignore:
Timestamp:
May 11, 2012 2:55:19 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: console should allow JS execution in the context of an isolated world
https://bugs.webkit.org/show_bug.cgi?id=85612

Reviewed by Pavel Feldman.

Added an option to select not only a frame but also isolated world in which
to perform evaluation of the code typed into the console.

Each execution context can be identified using it injected script id. We call it
execution context id in the protocol. Runtime agent is extended with an event that
is sent when new ExecutionContext is created. The event tracking can be enabled/disabled
using setReportExecutionContextCreation command.

  • bindings/js/ScriptController.cpp:

(WebCore):
(WebCore::isolatedWorldToSecurityOriginMap):

  • bindings/js/ScriptController.h:

(ScriptController):

  • bindings/js/ScriptState.cpp:

(WebCore::isolatedWorldScriptState):
(WebCore):

  • bindings/js/ScriptState.h:

(WebCore):

  • bindings/v8/ScriptController.cpp:

(WebCore):
(WebCore::ScriptController::isolatedWorldToSecurityOriginMap):

  • bindings/v8/ScriptController.h:

(ScriptController):

  • bindings/v8/ScriptState.cpp:

(WebCore::isolatedWorldScriptState):
(WebCore):

  • bindings/v8/ScriptState.h:

(WebCore):

  • bindings/v8/V8IsolatedContext.cpp:

(WebCore::V8IsolatedContext::setSecurityOrigin):

  • bindings/v8/V8Proxy.cpp:

(WebCore::V8Proxy::setIsolatedWorldSecurityOrigin):
(WebCore::V8Proxy::isolatedWorldContext):
(WebCore):
(WebCore::V8Proxy::isolatedWorldToSecurityOriginMap):

  • bindings/v8/V8Proxy.h:

(V8Proxy):

  • inspector/CodeGeneratorInspector.py:

(DomainNameFixes):

  • inspector/Inspector.json:
  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::didCreateIsolatedContextImpl):
(WebCore):

  • inspector/InspectorInstrumentation.h:

(WebCore):
(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::didCreateIsolatedContext):

  • inspector/InspectorRuntimeAgent.cpp:

(WebCore::InspectorRuntimeAgent::evaluate):

  • inspector/InspectorRuntimeAgent.h:

(InspectorRuntimeAgent):

  • inspector/InstrumentingAgents.h:

(WebCore):
(WebCore::InstrumentingAgents::InstrumentingAgents):
(WebCore::InstrumentingAgents::pageRuntimeAgent):
(WebCore::InstrumentingAgents::setPageRuntimeAgent):
(InstrumentingAgents):

  • inspector/PageRuntimeAgent.cpp:

(PageRuntimeAgentState):
(WebCore):
(WebCore::PageRuntimeAgent::PageRuntimeAgent):
(WebCore::PageRuntimeAgent::setFrontend):
(WebCore::PageRuntimeAgent::clearFrontend):
(WebCore::PageRuntimeAgent::restore):
(WebCore::PageRuntimeAgent::setReportExecutionContextCreation):
(WebCore::PageRuntimeAgent::didCreateExecutionContext):
(WebCore::PageRuntimeAgent::getScriptStateForEval):

  • inspector/PageRuntimeAgent.h:

(WebCore):
(PageRuntimeAgent):

  • inspector/WorkerRuntimeAgent.cpp:

(WebCore::WorkerRuntimeAgent::setReportExecutionContextCreation):
(WebCore::WorkerRuntimeAgent::getScriptStateForEval):

  • inspector/WorkerRuntimeAgent.h:

(WorkerRuntimeAgent):

  • inspector/front-end/ConsoleView.js:

(WebInspector.ConsoleView.prototype.get statusBarItems):
(WebInspector.ConsoleView.prototype.addContext):
(WebInspector.ConsoleView.prototype.removeContext):
(WebInspector.ConsoleView.prototype._updateIsolatedWorldSelector):
(WebInspector.ConsoleView.prototype._contextUpdated):
(WebInspector.ConsoleView.prototype._addedExecutionContext):
(WebInspector.ConsoleView.prototype._currentEvaluationContextId):
(WebInspector.ConsoleView.prototype._currentEvaluationContext):
(WebInspector.ConsoleView.prototype._currentIsolatedWorldId):
(WebInspector.ConsoleView.prototype.evalInInspectedWindow):

  • inspector/front-end/ExtensionPanel.js:

(WebInspector.ExtensionSidebarPane.prototype.setExpression):

  • inspector/front-end/ExtensionServer.js:

(WebInspector.ExtensionServer.prototype._onEvaluateOnInspectedPage):

  • inspector/front-end/JavaScriptContextManager.js:

(WebInspector.JavaScriptContextManager):
(WebInspector.JavaScriptContextManager.prototype._didLoadCachedResources):
(WebInspector.JavaScriptContextManager.prototype.isolatedContextCreated):
(WebInspector.RuntimeDispatcher):
(WebInspector.RuntimeDispatcher.prototype.isolatedContextCreated):
(WebInspector.ExecutionContext):
(WebInspector.ExecutionContext.comparator):
(WebInspector.FrameEvaluationContext):
(WebInspector.FrameEvaluationContext.prototype._frameNavigated):
(WebInspector.FrameEvaluationContext.prototype._addExecutionContext):
(WebInspector.FrameEvaluationContext.prototype._ensureMainWorldContextAdded):
(WebInspector.FrameEvaluationContext.prototype.isolatedContexts):

Location:
trunk/Source/WebCore
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r116743 r116744  
     12012-05-04  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: console should allow JS execution in the context of an isolated world
     4        https://bugs.webkit.org/show_bug.cgi?id=85612
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Added an option to select not only a frame but also isolated world in which
     9        to perform evaluation of the code typed into the console.
     10
     11        Each execution context can be identified using it injected script id. We call it
     12        execution context id in the protocol. Runtime agent is extended with an event that
     13        is sent when new ExecutionContext is created. The event tracking can be enabled/disabled
     14        using setReportExecutionContextCreation command.
     15
     16        * bindings/js/ScriptController.cpp:
     17        (WebCore):
     18        (WebCore::isolatedWorldToSecurityOriginMap):
     19        * bindings/js/ScriptController.h:
     20        (ScriptController):
     21        * bindings/js/ScriptState.cpp:
     22        (WebCore::isolatedWorldScriptState):
     23        (WebCore):
     24        * bindings/js/ScriptState.h:
     25        (WebCore):
     26        * bindings/v8/ScriptController.cpp:
     27        (WebCore):
     28        (WebCore::ScriptController::isolatedWorldToSecurityOriginMap):
     29        * bindings/v8/ScriptController.h:
     30        (ScriptController):
     31        * bindings/v8/ScriptState.cpp:
     32        (WebCore::isolatedWorldScriptState):
     33        (WebCore):
     34        * bindings/v8/ScriptState.h:
     35        (WebCore):
     36        * bindings/v8/V8IsolatedContext.cpp:
     37        (WebCore::V8IsolatedContext::setSecurityOrigin):
     38        * bindings/v8/V8Proxy.cpp:
     39        (WebCore::V8Proxy::setIsolatedWorldSecurityOrigin):
     40        (WebCore::V8Proxy::isolatedWorldContext):
     41        (WebCore):
     42        (WebCore::V8Proxy::isolatedWorldToSecurityOriginMap):
     43        * bindings/v8/V8Proxy.h:
     44        (V8Proxy):
     45        * inspector/CodeGeneratorInspector.py:
     46        (DomainNameFixes):
     47        * inspector/Inspector.json:
     48        * inspector/InspectorInstrumentation.cpp:
     49        (WebCore::InspectorInstrumentation::didCreateIsolatedContextImpl):
     50        (WebCore):
     51        * inspector/InspectorInstrumentation.h:
     52        (WebCore):
     53        (InspectorInstrumentation):
     54        (WebCore::InspectorInstrumentation::didCreateIsolatedContext):
     55        * inspector/InspectorRuntimeAgent.cpp:
     56        (WebCore::InspectorRuntimeAgent::evaluate):
     57        * inspector/InspectorRuntimeAgent.h:
     58        (InspectorRuntimeAgent):
     59        * inspector/InstrumentingAgents.h:
     60        (WebCore):
     61        (WebCore::InstrumentingAgents::InstrumentingAgents):
     62        (WebCore::InstrumentingAgents::pageRuntimeAgent):
     63        (WebCore::InstrumentingAgents::setPageRuntimeAgent):
     64        (InstrumentingAgents):
     65        * inspector/PageRuntimeAgent.cpp:
     66        (PageRuntimeAgentState):
     67        (WebCore):
     68        (WebCore::PageRuntimeAgent::PageRuntimeAgent):
     69        (WebCore::PageRuntimeAgent::setFrontend):
     70        (WebCore::PageRuntimeAgent::clearFrontend):
     71        (WebCore::PageRuntimeAgent::restore):
     72        (WebCore::PageRuntimeAgent::setReportExecutionContextCreation):
     73        (WebCore::PageRuntimeAgent::didCreateExecutionContext):
     74        (WebCore::PageRuntimeAgent::getScriptStateForEval):
     75        * inspector/PageRuntimeAgent.h:
     76        (WebCore):
     77        (PageRuntimeAgent):
     78        * inspector/WorkerRuntimeAgent.cpp:
     79        (WebCore::WorkerRuntimeAgent::setReportExecutionContextCreation):
     80        (WebCore::WorkerRuntimeAgent::getScriptStateForEval):
     81        * inspector/WorkerRuntimeAgent.h:
     82        (WorkerRuntimeAgent):
     83        * inspector/front-end/ConsoleView.js:
     84        (WebInspector.ConsoleView.prototype.get statusBarItems):
     85        (WebInspector.ConsoleView.prototype.addContext):
     86        (WebInspector.ConsoleView.prototype.removeContext):
     87        (WebInspector.ConsoleView.prototype._updateIsolatedWorldSelector):
     88        (WebInspector.ConsoleView.prototype._contextUpdated):
     89        (WebInspector.ConsoleView.prototype._addedExecutionContext):
     90        (WebInspector.ConsoleView.prototype._currentEvaluationContextId):
     91        (WebInspector.ConsoleView.prototype._currentEvaluationContext):
     92        (WebInspector.ConsoleView.prototype._currentIsolatedWorldId):
     93        (WebInspector.ConsoleView.prototype.evalInInspectedWindow):
     94        * inspector/front-end/ExtensionPanel.js:
     95        (WebInspector.ExtensionSidebarPane.prototype.setExpression):
     96        * inspector/front-end/ExtensionServer.js:
     97        (WebInspector.ExtensionServer.prototype._onEvaluateOnInspectedPage):
     98        * inspector/front-end/JavaScriptContextManager.js:
     99        (WebInspector.JavaScriptContextManager):
     100        (WebInspector.JavaScriptContextManager.prototype._didLoadCachedResources):
     101        (WebInspector.JavaScriptContextManager.prototype.isolatedContextCreated):
     102        (WebInspector.RuntimeDispatcher):
     103        (WebInspector.RuntimeDispatcher.prototype.isolatedContextCreated):
     104        (WebInspector.ExecutionContext):
     105        (WebInspector.ExecutionContext.comparator):
     106        (WebInspector.FrameEvaluationContext):
     107        (WebInspector.FrameEvaluationContext.prototype._frameNavigated):
     108        (WebInspector.FrameEvaluationContext.prototype._addExecutionContext):
     109        (WebInspector.FrameEvaluationContext.prototype._ensureMainWorldContextAdded):
     110        (WebInspector.FrameEvaluationContext.prototype.isolatedContexts):
     111
    11122012-05-11  Andrey Kosyakov  <caseq@chromium.org>
    2113
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

    r115498 r116744  
    327327{
    328328}
     329
     330void ScriptController::collectIsolatedContexts(Vector<std::pair<JSC::ExecState*, SecurityOrigin*> >&)
     331{
     332    // FIXME(85709): support isolated contexts inspection for JSC.
     333}
    329334#endif
    330335
  • trunk/Source/WebCore/bindings/js/ScriptController.h

    r115498 r116744  
    4141namespace JSC {
    4242    class JSGlobalObject;
     43    class ExecState;
    4344
    4445    namespace Bindings {
     
    5354class ScriptSourceCode;
    5455class ScriptValue;
     56class SecurityOrigin;
    5557class Widget;
    5658
     
    144146#if ENABLE(INSPECTOR)
    145147    static void setCaptureCallStackForUncaughtExceptions(bool);
     148    void collectIsolatedContexts(Vector<std::pair<JSC::ExecState*, SecurityOrigin*> >&);
    146149#endif
    147150
  • trunk/Source/WebCore/bindings/v8/ScriptController.cpp

    r115670 r116744  
    468468    v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, stackTraceOptions);
    469469}
     470
     471void ScriptController::collectIsolatedContexts(Vector<std::pair<ScriptState*, SecurityOrigin*> >& result)
     472{
     473    m_proxy->collectIsolatedContexts(result);
     474}
    470475#endif
    471476
  • trunk/Source/WebCore/bindings/v8/ScriptController.h

    r115498 r116744  
    6262class PagePopupClient;
    6363class ScriptSourceCode;
     64class ScriptState;
    6465class Widget;
    6566
     
    135136#if ENABLE(INSPECTOR)
    136137    static void setCaptureCallStackForUncaughtExceptions(bool);
     138    void collectIsolatedContexts(Vector<std::pair<ScriptState*, SecurityOrigin*> >&);
    137139#endif
    138140
  • trunk/Source/WebCore/bindings/v8/V8IsolatedContext.cpp

    r116580 r116744  
    3535#include "Frame.h"
    3636#include "FrameLoaderClient.h"
     37#include "InspectorInstrumentation.h"
    3738#include "SecurityOrigin.h"
    3839#include "V8BindingPerContextData.h"
     
    119120void V8IsolatedContext::setSecurityOrigin(PassRefPtr<SecurityOrigin> securityOrigin)
    120121{
     122    if (!m_securityOrigin && InspectorInstrumentation::hasFrontends() && !context().IsEmpty()) {
     123        v8::HandleScope handleScope;
     124        ScriptState* scriptState = ScriptState::forContext(v8::Local<v8::Context>::New(context()));
     125        InspectorInstrumentation::didCreateIsolatedContext(m_frame, scriptState, securityOrigin.get());
     126    }
    121127    m_securityOrigin = securityOrigin;
    122128}
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r116171 r116744  
    632632}
    633633
     634v8::Local<v8::Context> V8Proxy::isolatedWorldContext(int worldId)
     635{
     636    IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldId);
     637    if (iter == m_isolatedWorlds.end())
     638        return v8::Local<v8::Context>();
     639    return v8::Local<v8::Context>::New(iter->second->context());
     640}
     641
    634642bool V8Proxy::matchesCurrentContext()
    635643{
     
    728736}
    729737
     738void V8Proxy::collectIsolatedContexts(Vector<std::pair<ScriptState*, SecurityOrigin*> >& result)
     739{
     740    v8::HandleScope handleScope;
     741    for (IsolatedWorldMap::iterator it = m_isolatedWorlds.begin(); it != m_isolatedWorlds.end(); ++it) {
     742        V8IsolatedContext* isolatedContext = it->second;
     743        if (!isolatedContext->securityOrigin())
     744            continue;
     745        v8::Handle<v8::Context> v8Context = isolatedContext->context();
     746        if (v8Context.IsEmpty())
     747            continue;
     748        ScriptState* scriptState = ScriptState::forContext(v8::Local<v8::Context>::New(v8Context));
     749        result.append(std::pair<ScriptState*, SecurityOrigin*>(scriptState, isolatedContext->securityOrigin()));
     750    }
     751}
     752
    730753v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, const WorldContextHandle& worldContext)
    731754{
  • trunk/Source/WebCore/bindings/v8/V8Proxy.h

    r115522 r116744  
    245245        v8::Local<v8::Context> context();
    246246        v8::Local<v8::Context> mainWorldContext();
     247        v8::Local<v8::Context> isolatedWorldContext(int worldId);
    247248        bool matchesCurrentContext();
    248249
     
    252253        bool setContextDebugId(int id);
    253254        static int contextDebugId(v8::Handle<v8::Context>);
     255        void collectIsolatedContexts(Vector<std::pair<ScriptState*, SecurityOrigin*> >&);
    254256
    255257        // Registers a v8 extension to be available on webpages. Will only
  • trunk/Source/WebCore/inspector/CodeGeneratorInspector.py

    r116641 r116744  
    186186        return Res
    187187
    188     skip_js_bind_domains = set(["Runtime", "DOMDebugger"])
     188    skip_js_bind_domains = set(["DOMDebugger"])
    189189
    190190
  • trunk/Source/WebCore/inspector/InjectedScriptManager.cpp

    r110854 r116744  
    8080InjectedScript InjectedScriptManager::injectedScriptForId(long id)
    8181{
    82     return m_idToInjectedScript.get(id);
     82    IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(id);
     83    if (it != m_idToInjectedScript.end())
     84        return it->second;
     85    for (ScriptStateToId::iterator it = m_scriptStateToId.begin(); it != m_scriptStateToId.end(); ++it) {
     86        if (it->second == id)
     87            return injectedScriptFor(it->first);
     88    }
     89    return InjectedScript();
     90}
     91
     92long InjectedScriptManager::injectedScriptIdFor(ScriptState* scriptState)
     93{
     94    ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState);
     95    if (it != m_scriptStateToId.end())
     96        return it->second;
     97    long id = m_nextInjectedScriptId++;
     98    m_scriptStateToId.set(scriptState, id);
     99    return id;
    83100}
    84101
     
    90107        bool success = parsedObjectId->asObject()->getNumber("injectedScriptId", &injectedScriptId);
    91108        if (success)
    92             return injectedScriptForId(injectedScriptId);
     109            return m_idToInjectedScript.get(injectedScriptId);
    93110    }
    94111    return InjectedScript();
     
    101118        discardInjectedScript(it->second.scriptState());
    102119    m_idToInjectedScript.clear();
     120    m_scriptStateToId.clear();
    103121}
    104122
    105123void InjectedScriptManager::discardInjectedScriptsFor(DOMWindow* window)
    106124{
     125    if (m_scriptStateToId.isEmpty())
     126        return;
     127
    107128    Vector<long> idsToRemove;
    108129    IdToInjectedScriptMap::iterator end = m_idToInjectedScript.end();
     
    112133            continue;
    113134        discardInjectedScript(scriptState);
     135        m_scriptStateToId.remove(scriptState);
    114136        idsToRemove.append(it->first);
    115137    }
     
    117139    for (size_t i = 0; i < idsToRemove.size(); i++)
    118140        m_idToInjectedScript.remove(idsToRemove[i]);
     141
     142    // Now remove script states that have id but no injected script.
     143    Vector<ScriptState*> scriptStatesToRemove;
     144    for (ScriptStateToId::iterator it = m_scriptStateToId.begin(); it != m_scriptStateToId.end(); ++it) {
     145        ScriptState* scriptState = it->first;
     146        if (window == domWindowFromScriptState(scriptState))
     147            scriptStatesToRemove.append(scriptState);
     148    }
     149    for (size_t i = 0; i < scriptStatesToRemove.size(); i++)
     150        m_scriptStateToId.remove(scriptStatesToRemove[i]);
    119151}
    120152
     
    137169pair<long, ScriptObject> InjectedScriptManager::injectScript(const String& source, ScriptState* scriptState)
    138170{
    139     long id = m_nextInjectedScriptId++;
     171    long id = injectedScriptIdFor(scriptState);
    140172    return std::make_pair(id, createInjectedScript(source, scriptState, id));
    141173}
  • trunk/Source/WebCore/inspector/InjectedScriptManager.h

    r95901 r116744  
    5959    InjectedScript injectedScriptFor(ScriptState*);
    6060    InjectedScript injectedScriptForId(long);
     61    long injectedScriptIdFor(ScriptState*);
    6162    InjectedScript injectedScriptForObjectId(const String& objectId);
    6263    void discardInjectedScripts();
     
    8182    RefPtr<InjectedScriptHost> m_injectedScriptHost;
    8283    InspectedStateAccessCheck m_inspectedStateAccessCheck;
     84    typedef HashMap<ScriptState*, long> ScriptStateToId;
     85    ScriptStateToId m_scriptStateToId;
    8386};
    8487
  • trunk/Source/WebCore/inspector/Inspector.json

    r116237 r116744  
    428428                    { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Remote object handle." }
    429429                ]
    430             }
     430            },
     431            {
     432                "id": "ExecutionContextId",
     433                "type": "integer",
     434                "description": "Id of an execution context.",
     435                "hidden": true
     436            },
     437            {
     438                "id": "ExecutionContextDescription",
     439                "type": "object",
     440                "description": "Description of an isolated world.",
     441                "properties": [
     442                    { "name": "id", "$ref": "ExecutionContextId", "description": "Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed." },
     443                    { "name": "isPageContext", "type": "boolean", "description": "True if this is a context where inpspected web page scripts run. False if it is a content script isolated context." },
     444                    { "name": "name", "type": "string", "description": "Human readable name describing given context." },
     445                    { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the owning frame." }
     446                ],
     447                "hidden": true
     448            }
     449
    431450        ],
    432451        "commands": [
     
    438457                    { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation.", "hidden": true },
    439458                    { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true },
    440                     { "name": "frameId", "$ref": "Network.FrameId", "optional": true, "description": "Specifies in which frame to perform evaluation.", "hidden": true },
     459                    { "name": "contextId", "type": "integer", "optional": true, "description": "Specifies in which isolated context to perform evaluation. Each content script lives in an isolated context and this parameter may be used to specify on of those contexts. If the parameter is omitted or 0 the evaluation will be performed in the context of the inspected page.", "hidden": true },
    441460                    { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }
    442461                ],
     
    491510                "hidden": true,
    492511                "description": "Tells inspected instance(worker or page) that it can run in case it was started paused."
     512            },
     513            {
     514                "name": "setReportExecutionContextCreation",
     515                "parameters": [
     516                    { "name": "enabled", "type": "boolean", "description": "Reporting enabled state." }
     517                ],
     518                "hidden": true,
     519                "description": "Enables reporting about creation of isolated contexts by means of <code>isolatedContextCreated</code> event. When the reporting gets enabled the event will be sent immediately for each existing isolated context."
     520            }
     521
     522        ],
     523        "events": [
     524            {
     525                "name": "isolatedContextCreated",
     526                "parameters": [
     527                    { "name": "context", "$ref": "ExecutionContextDescription", "description": "A newly created isolated contex." }
     528                ],
     529                "description": "Issued when new isolated context is created."
    493530            }
    494531        ]
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r115427 r116744  
    6262#include "InspectorWorkerAgent.h"
    6363#include "InstrumentingAgents.h"
     64#include "PageRuntimeAgent.h"
    6465#include "ScriptArguments.h"
    6566#include "ScriptCallStack.h"
     
    113114    }
    114115#endif
     116    if (PageRuntimeAgent* pageRuntimeAgent = instrumentingAgents->pageRuntimeAgent()) {
     117        if (world == mainThreadNormalWorld())
     118            pageRuntimeAgent->didClearWindowObject(frame);
     119    }
    115120}
    116121
     
    362367    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
    363368        timelineAgent->didEvaluateScript();
     369}
     370
     371void InspectorInstrumentation::didCreateIsolatedContextImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, ScriptState* scriptState, SecurityOrigin* origin)
     372{
     373    if (PageRuntimeAgent* runtimeAgent = instrumentingAgents->pageRuntimeAgent())
     374        runtimeAgent->didCreateIsolatedContext(frame, scriptState, origin);
    364375}
    365376
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r115427 r116744  
    4040#include "ScriptExecutionContext.h"
    4141
     42#if USE(JSC)
     43namespace JSC {
     44class ExecState;
     45}
     46#endif
     47
    4248namespace WebCore {
    4349
     
    6470class ScriptExecutionContext;
    6571class ScriptProfile;
     72class SecurityOrigin;
    6673class ShadowRoot;
    6774class StorageArea;
     
    7077class WorkerContextProxy;
    7178class XMLHttpRequest;
     79
     80#if USE(JSC)
     81typedef JSC::ExecState ScriptState;
     82#else
     83class ScriptState;
     84#endif
    7285
    7386#if ENABLE(WEB_SOCKETS)
     
    120133    static InspectorInstrumentationCookie willEvaluateScript(Frame*, const String& url, int lineNumber);
    121134    static void didEvaluateScript(const InspectorInstrumentationCookie&);
     135    static void didCreateIsolatedContext(Frame*, ScriptState*, SecurityOrigin*);
    122136    static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext*, int timerId);
    123137    static void didFireTimer(const InspectorInstrumentationCookie&);
     
    279293    static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents*, const String& url, int lineNumber);
    280294    static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&);
     295    static void didCreateIsolatedContextImpl(InstrumentingAgents*, Frame*, ScriptState*, SecurityOrigin*);
    281296    static InspectorInstrumentationCookie willFireTimerImpl(InstrumentingAgents*, int timerId);
    282297    static void didFireTimerImpl(const InspectorInstrumentationCookie&);
     
    707722}
    708723
     724inline void InspectorInstrumentation::didCreateIsolatedContext(Frame* frame, ScriptState* scriptState, SecurityOrigin* origin)
     725{
     726#if ENABLE(INSPECTOR)
     727    FAST_RETURN_IF_NO_FRONTENDS(void());
     728    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
     729        return didCreateIsolatedContextImpl(instrumentingAgents, frame, scriptState, origin);
     730#endif
     731}
     732
    709733inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext* context, int timerId)
    710734{
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp

    r116099 r116744  
    8484#endif
    8585
    86 void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const String* const frameId, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
     86void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
    8787{
    88     ScriptState* scriptState = scriptStateForEval(errorString, frameId);
    89     if (!scriptState)
     88    InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId);
     89    if (injectedScript.hasNoValue())
    9090        return;
    91     InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
    92     if (injectedScript.hasNoValue()) {
    93         *errorString = "Inspected frame has gone";
    94         return;
    95     }
    9691#if ENABLE(JAVASCRIPT_DEBUGGER)
    9792    ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = ScriptDebugServer::DontPauseOnExceptions;
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h

    r116099 r116744  
    4141namespace WebCore {
    4242
     43class InjectedScript;
    4344class InjectedScriptManager;
    4445class InspectorArray;
     
    6364                  const bool* includeCommandLineAPI,
    6465                  const bool* doNotPauseOnExceptionsAndMuteConsole,
    65                   const String* frameId,
     66                  const int* executionContextId,
    6667                  const bool* returnByValue,
    6768                  RefPtr<TypeBuilder::Runtime::RemoteObject>& result,
     
    8990protected:
    9091    InspectorRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
    91     virtual ScriptState* scriptStateForEval(ErrorString*, const String* frameId) = 0;
     92    virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) = 0;
    9293
    9394    virtual void muteConsole() = 0;
    9495    virtual void unmuteConsole() = 0;
     96
     97    InjectedScriptManager* injectedScriptManager() { return m_injectedScriptManager; }
    9598
    9699private:
  • trunk/Source/WebCore/inspector/InstrumentingAgents.h

    r101236 r116744  
    5454class InspectorWorkerAgent;
    5555class Page;
     56class PageRuntimeAgent;
    5657class WorkerContext;
    5758
     
    6869        , m_inspectorResourceAgent(0)
    6970        , m_inspectorRuntimeAgent(0)
     71        , m_pageRuntimeAgent(0)
    7072        , m_inspectorTimelineAgent(0)
    7173        , m_inspectorDOMStorageAgent(0)
     
    108110    InspectorRuntimeAgent* inspectorRuntimeAgent() const { return m_inspectorRuntimeAgent; }
    109111    void setInspectorRuntimeAgent(InspectorRuntimeAgent* agent) { m_inspectorRuntimeAgent = agent; }
     112
     113    PageRuntimeAgent* pageRuntimeAgent() const { return m_pageRuntimeAgent; }
     114    void setPageRuntimeAgent(PageRuntimeAgent* agent) { m_pageRuntimeAgent = agent; }
    110115
    111116    InspectorTimelineAgent* inspectorTimelineAgent() const { return m_inspectorTimelineAgent; }
     
    151156    InspectorResourceAgent* m_inspectorResourceAgent;
    152157    InspectorRuntimeAgent* m_inspectorRuntimeAgent;
     158    PageRuntimeAgent* m_pageRuntimeAgent;
    153159    InspectorTimelineAgent* m_inspectorTimelineAgent;
    154160    InspectorDOMStorageAgent* m_inspectorDOMStorageAgent;
  • trunk/Source/WebCore/inspector/PageRuntimeAgent.cpp

    r116099 r116744  
    3636
    3737#include "Console.h"
     38#include "Document.h"
     39#include "InjectedScript.h"
     40#include "InjectedScriptManager.h"
    3841#include "InspectorPageAgent.h"
     42#include "InspectorState.h"
     43#include "InstrumentingAgents.h"
    3944#include "Page.h"
    40 #include "ScriptState.h"
     45#include "SecurityOrigin.h"
     46
     47using WebCore::TypeBuilder::Runtime::ExecutionContextDescription;
    4148
    4249namespace WebCore {
     50
     51namespace PageRuntimeAgentState {
     52static const char reportExecutionContextCreation[] = "reportExecutionContextCreation";
     53};
    4354
    4455PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, InspectorPageAgent* pageAgent)
     
    4657    , m_inspectedPage(page)
    4758    , m_pageAgent(pageAgent)
     59    , m_frontend(0)
    4860{
    4961}
     
    5365}
    5466
    55 ScriptState* PageRuntimeAgent::scriptStateForEval(ErrorString* errorString, const String* frameId)
     67void PageRuntimeAgent::setFrontend(InspectorFrontend* frontend)
    5668{
    57     if (!frameId)
    58         return mainWorldScriptState(m_inspectedPage->mainFrame());
     69    m_frontend = frontend->runtime();
     70    m_instrumentingAgents->setPageRuntimeAgent(this);
     71}
    5972
    60     Frame* frame = m_pageAgent->frameForId(*frameId);
    61     if (!frame) {
    62         *errorString = "Frame with given id not found.";
    63         return 0;
     73void PageRuntimeAgent::clearFrontend()
     74{
     75    m_instrumentingAgents->setPageRuntimeAgent(0);
     76    m_frontend = 0;
     77    m_state->setBoolean(PageRuntimeAgentState::reportExecutionContextCreation, false);
     78}
     79
     80void PageRuntimeAgent::restore()
     81{
     82    if (!m_state->getBoolean(PageRuntimeAgentState::reportExecutionContextCreation))
     83        return;
     84    String error;
     85    setReportExecutionContextCreation(&error, true);
     86}
     87
     88void PageRuntimeAgent::setReportExecutionContextCreation(ErrorString*, bool enable)
     89{
     90    m_state->setBoolean(PageRuntimeAgentState::reportExecutionContextCreation, enable);
     91    if (!enable)
     92        return;
     93    Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts;
     94    for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
     95        if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
     96            continue;
     97        String frameId = m_pageAgent->frameId(frame);
     98
     99        ScriptState* scriptState = mainWorldScriptState(frame);
     100        notifyContextCreated(frameId, scriptState, 0, true);
     101        frame->script()->collectIsolatedContexts(isolatedContexts);
     102        if (isolatedContexts.isEmpty())
     103            continue;
     104        for (size_t i = 0; i< isolatedContexts.size(); i++)
     105            notifyContextCreated(frameId, isolatedContexts[i].first, isolatedContexts[i].second, false);
     106        isolatedContexts.clear();
    64107    }
    65     return mainWorldScriptState(frame);
     108}
     109
     110void PageRuntimeAgent::didClearWindowObject(Frame* frame)
     111{
     112    if (!m_state->getBoolean(PageRuntimeAgentState::reportExecutionContextCreation))
     113        return;
     114    ASSERT(m_frontend);
     115    String frameId = m_pageAgent->frameId(frame);
     116    ScriptState* scriptState = mainWorldScriptState(frame);
     117    notifyContextCreated(frameId, scriptState, 0, true);
     118}
     119
     120void PageRuntimeAgent::didCreateIsolatedContext(Frame* frame, ScriptState* scriptState, SecurityOrigin* origin)
     121{
     122    if (!m_state->getBoolean(PageRuntimeAgentState::reportExecutionContextCreation))
     123        return;
     124    ASSERT(m_frontend);
     125    String frameId = m_pageAgent->frameId(frame);
     126    notifyContextCreated(frameId, scriptState, origin, false);
     127}
     128
     129InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId)
     130{
     131    if (!executionContextId) {
     132        ScriptState* scriptState = mainWorldScriptState(m_inspectedPage->mainFrame());
     133        return injectedScriptManager()->injectedScriptFor(scriptState);
     134    }
     135    InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId(*executionContextId);
     136    if (injectedScript.hasNoValue())
     137        *errorString = "Execution context with given id not found.";
     138    return injectedScript;
    66139}
    67140
     
    76149}
    77150
     151void PageRuntimeAgent::notifyContextCreated(const String& frameId, ScriptState* scriptState, SecurityOrigin* securityOrigin, bool isPageContext)
     152{
     153    ASSERT(securityOrigin || isPageContext);
     154    long executionContextId = injectedScriptManager()->injectedScriptIdFor(scriptState);
     155    String name = securityOrigin ? securityOrigin->toString() : "";
     156    m_frontend->isolatedContextCreated(ExecutionContextDescription::create()
     157        .setId(executionContextId)
     158        .setIsPageContext(isPageContext)
     159        .setName(name)
     160        .setFrameId(frameId)
     161        .release());
     162}
     163
    78164} // namespace WebCore
    79165
  • trunk/Source/WebCore/inspector/PageRuntimeAgent.h

    r116099 r116744  
    3434#if ENABLE(INSPECTOR)
    3535
     36#include "InspectorFrontend.h"
    3637#include "InspectorRuntimeAgent.h"
     38#include "ScriptState.h"
    3739#include <wtf/PassOwnPtr.h>
    3840
     
    4143class InspectorPageAgent;
    4244class Page;
     45class SecurityOrigin;
    4346
    4447class PageRuntimeAgent : public InspectorRuntimeAgent {
     
    4952    }
    5053    virtual ~PageRuntimeAgent();
     54    virtual void setFrontend(InspectorFrontend*);
     55    virtual void clearFrontend();
     56    virtual void restore();
     57    virtual void setReportExecutionContextCreation(ErrorString*, bool);
     58
     59    void didClearWindowObject(Frame*);
     60    void didCreateIsolatedContext(Frame*, ScriptState*, SecurityOrigin*);
    5161
    5262private:
    5363    PageRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, Page*, InspectorPageAgent*);
    5464
    55     virtual ScriptState* scriptStateForEval(ErrorString*, const String* frameId);
     65    virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId);
    5666    virtual void muteConsole();
    5767    virtual void unmuteConsole();
     68    void notifyContextCreated(const String& frameId, ScriptState*, SecurityOrigin*, bool isPageContext);
     69
    5870    Page* m_inspectedPage;
    5971    InspectorPageAgent* m_pageAgent;
     72    InspectorFrontend::Runtime* m_frontend;
    6073};
    6174
  • trunk/Source/WebCore/inspector/WorkerRuntimeAgent.cpp

    r116099 r116744  
    3535#include "WorkerRuntimeAgent.h"
    3636
     37#include "InjectedScript.h"
    3738#include "ScriptState.h"
    3839
     
    4950}
    5051
    51 ScriptState* WorkerRuntimeAgent::scriptStateForEval(ErrorString* error, const String* frameId)
     52void WorkerRuntimeAgent::setReportExecutionContextCreation(ErrorString* error, bool)
    5253{
    53     if (frameId) {
    54         *error = "Frame id is not supported for workers.";
    55         return 0;
     54    *error = "Isolated contexts are not supported for workers.";
     55}
     56
     57InjectedScript WorkerRuntimeAgent::injectedScriptForEval(ErrorString* error, const int* executionContextId)
     58{
     59    if (executionContextId) {
     60        *error = "Execution context id is not supported for workers as there is only one execution context.";
     61        return InjectedScript();
    5662    }
    57     return scriptStateFromWorkerContext(m_workerContext);
     63    ScriptState* scriptState = scriptStateFromWorkerContext(m_workerContext);
     64    return injectedScriptManager()->injectedScriptFor(scriptState);
    5865}
    5966
  • trunk/Source/WebCore/inspector/WorkerRuntimeAgent.h

    r116099 r116744  
    4848    }
    4949    virtual ~WorkerRuntimeAgent();
     50    virtual void setReportExecutionContextCreation(ErrorString*, bool);
    5051
    5152private:
    5253    WorkerRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, WorkerContext*);
    53     virtual ScriptState* scriptStateForEval(ErrorString*, const String* frameId);
     54    virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId);
    5455    virtual void muteConsole();
    5556    virtual void unmuteConsole();
  • trunk/Source/WebCore/inspector/front-end/ConsoleView.js

    r115194 r116744  
    4848    this._contextSelectElement.id = "console-context";
    4949    this._contextSelectElement.className = "status-bar-item";
    50 
    51     if (hideContextSelector)
     50    this._contextSelectElement.addEventListener("change", this._updateIsolatedWorldSelector.bind(this), false);
     51
     52    this._isolatedWorldSelectElement = document.createElement("select");
     53    this._isolatedWorldSelectElement.id = "console-context";
     54    this._isolatedWorldSelectElement.className = "status-bar-item";
     55
     56    if (hideContextSelector) {
    5257        this._contextSelectElement.addStyleClass("hidden");
     58        this._isolatedWorldSelectElement.addStyleClass("hidden");
     59    }
    5360
    5461    this.messagesElement = document.createElement("div");
     
    128135    get statusBarItems()
    129136    {
    130         return [this._clearConsoleButton.element, this._contextSelectElement, this._filterBarElement];
     137        return [this._clearConsoleButton.element, this._contextSelectElement, this._isolatedWorldSelectElement, this._filterBarElement];
    131138    },
    132139
     
    140147        this._contextSelectElement.appendChild(option);
    141148        context.addEventListener(WebInspector.FrameEvaluationContext.EventTypes.Updated, this._contextUpdated, this);
     149        context.addEventListener(WebInspector.FrameEvaluationContext.EventTypes.AddedExecutionContext, this._addedExecutionContext, this);
     150        this._updateIsolatedWorldSelector();
    142151    },
    143152
     
    145154    {
    146155        this._contextSelectElement.removeChild(context._consoleOption);
     156        this._updateIsolatedWorldSelector();
     157    },
     158
     159    _updateIsolatedWorldSelector: function()
     160    {
     161        var context = this._currentEvaluationContext();
     162        if (!context) {
     163            this._isolatedWorldSelectElement.addStyleClass("hidden");
     164            return;
     165        }
     166
     167        var isolatedContexts = context.isolatedContexts();
     168        if (!isolatedContexts.length) {
     169            this._isolatedWorldSelectElement.addStyleClass("hidden");
     170            return;
     171        }
     172        this._isolatedWorldSelectElement.removeStyleClass("hidden");
     173        this._isolatedWorldSelectElement.removeChildren();
     174        this._appendIsolatedContextOption(context.mainWorldContext());
     175        for (var i = 0; i < isolatedContexts.length; i++)
     176            this._appendIsolatedContextOption(isolatedContexts[i]);
     177    },
     178
     179    _appendIsolatedContextOption: function(isolatedContext)
     180    {
     181        if (!isolatedContext)
     182            return;
     183        var option = document.createElement("option");
     184        option.text = isolatedContext.name;
     185        option.title = isolatedContext.id;
     186        option._executionContextId = isolatedContext.id;
     187        this._isolatedWorldSelectElement.appendChild(option);
    147188    },
    148189
     
    150191    {
    151192        var context = event.data;
    152         var option= context._consoleOption;
     193        var option = context._consoleOption;
    153194        option.text = context.displayName;
    154195        option.title = context.url;
    155196    },
    156197
     198    _addedExecutionContext: function(event)
     199    {
     200        var context = event.data;
     201        if (context === this._currentEvaluationContext())
     202            this._updateIsolatedWorldSelector();
     203    },
     204
    157205    _currentEvaluationContextId: function()
     206    {
     207        var result = this._currentIsolatedContextId();
     208        if (result !== undefined)
     209            return result;
     210        var context = this._currentEvaluationContext();
     211        if (context && context.mainWorldContext())
     212            return context.mainWorldContext().id;
     213        return undefined;
     214    },
     215
     216    _currentEvaluationContext: function()
    158217    {
    159218        if (this._contextSelectElement.selectedIndex === -1)
    160219            return undefined;
    161         return this._contextSelectElement[this._contextSelectElement.selectedIndex]._context.frameId;
     220        return this._contextSelectElement[this._contextSelectElement.selectedIndex]._context;
     221    },
     222
     223    _currentIsolatedContextId: function()
     224    {
     225        if (this._isolatedWorldSelectElement.hasStyleClass("hidden"))
     226            return undefined;
     227        if (this._isolatedWorldSelectElement.selectedIndex === -1)
     228            return undefined;
     229        return this._isolatedWorldSelectElement[this._isolatedWorldSelectElement.selectedIndex]._executionContextId;
    162230    },
    163231
     
    621689                callback(WebInspector.RemoteObject.fromPayload(result), !!wasThrown);
    622690        }
    623         RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, this._currentEvaluationContextId(), returnByValue, evalCallback);
     691        var contextId = this._currentEvaluationContextId();
     692        RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, contextId, returnByValue, evalCallback);
    624693    },
    625694
  • trunk/Source/WebCore/inspector/front-end/JavaScriptContextManager.js

    r114117 r116744  
    3838    resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated, this);
    3939    resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, this);
     40    resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._didLoadCachedResources, this);
    4041    this._consoleView = consoleView;
    4142    this._frameIdToContext = {};
     
    6869        delete this._frameIdToContext[frame.id];
    6970    },
     71
     72    _didLoadCachedResources: function()
     73    {
     74        InspectorBackend.registerRuntimeDispatcher(new WebInspector.RuntimeDispatcher(this));
     75        RuntimeAgent.setReportExecutionContextCreation(true);
     76    },
     77
     78    isolatedContextCreated: function(context)
     79    {
     80        var frameEvaluationContext = this._frameIdToContext[context.frameId];
     81        // FIXME(85708): this should never happen
     82        if (!frameEvaluationContext)
     83            return;
     84        frameEvaluationContext._addExecutionContext(new WebInspector.ExecutionContext(context.id, context.name, context.isPageContext));
     85    }
    7086}
    7187
    7288WebInspector.JavaScriptContextManager.prototype.__proto__ = WebInspector.Object.prototype;
    7389
     90
     91/**
     92 * @constructor
     93 * @implements {RuntimeAgent.Dispatcher}
     94 * @param {WebInspector.JavaScriptContextManager} contextManager
     95 */
     96WebInspector.RuntimeDispatcher = function(contextManager)
     97{
     98    this._contextManager = contextManager;
     99}
     100
     101WebInspector.RuntimeDispatcher.prototype = {
     102    isolatedContextCreated: function(context)
     103    {
     104        this._contextManager.isolatedContextCreated(context);
     105    }
     106}
     107
    74108/**
    75109 * @constructor
    76110 * @extends {WebInspector.Object}
    77111 */
     112WebInspector.ExecutionContext = function(id, name, isPageContext)
     113{
     114    this.id = id;
     115    this.name = (isPageContext && !name) ? "<page context>" : name;
     116    this.isMainWorldContext = isPageContext;
     117}
     118
     119/**
     120 * @param {WebInspector.ExecutionContext} a
     121 * @param {WebInspector.ExecutionContext} b
     122 */
     123WebInspector.ExecutionContext.comparator = function(a, b)
     124{
     125    // Main world context should always go first.
     126    if (a.isMainWorldContext)
     127        return -1;
     128    if (b.isMainWorldContext)
     129        return +1;
     130    return a.name.localeCompare(b.name);
     131}
     132
     133/**
     134 * @constructor
     135 * @extends {WebInspector.Object}
     136 */
    78137WebInspector.FrameEvaluationContext = function(frame)
    79138{
    80139    this._frame = frame;
     140    this._mainWorldContext = null;
     141    this._isolatedContexts = [];
    81142}
    82143
    83144WebInspector.FrameEvaluationContext.EventTypes = {
    84     Updated: "updated"
     145    Updated: "Updated",
     146    AddedExecutionContext: "AddedExecutionContext"
    85147}
    86148
     
    90152    {
    91153        this._frame = frame;
     154        this._mainWorldContext = null;
     155        this._isolatedContexts = [];
    92156        this.dispatchEventToListeners(WebInspector.FrameEvaluationContext.EventTypes.Updated, this);
     157    },
     158
     159    /**
     160     * @param {WebInspector.ExecutionContext} context
     161     */
     162    _addExecutionContext: function(context)
     163    {
     164        if (context.isMainWorldContext)
     165            this._mainWorldContext = context;
     166        else
     167            this._isolatedContexts.push(context);
     168        this.dispatchEventToListeners(WebInspector.FrameEvaluationContext.EventTypes.AddedExecutionContext, this);
     169    },
     170
     171    mainWorldContext: function()
     172    {
     173        return this._mainWorldContext;
     174    },
     175
     176    isolatedContexts: function()
     177    {
     178        if (this._isolatedContexts.length)
     179            this._isolatedContexts.sort(WebInspector.ExecutionContext.comparator);
     180        return this._isolatedContexts;
    93181    },
    94182
Note: See TracChangeset for help on using the changeset viewer.