Changeset 55771 in webkit


Ignore:
Timestamp:
Mar 10, 2010 1:22:04 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-03-10 Andrey Kosyakov <caseq@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: display list of active workers & support debugging
with fake workers.
https://bugs.webkit.org/show_bug.cgi?id=35568

  • English.lproj/localizedStrings.js:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • bindings/js/JSInjectedScriptHostCustom.cpp: (WebCore::InjectedScriptHost::createInjectedScript): (WebCore::InjectedScriptHost::injectedScriptFor):
  • bindings/v8/custom/V8InjectedScriptHostCustom.cpp: (WebCore::InjectedScriptHost::createInjectedScript): (WebCore::InjectedScriptHost::injectedScriptFor):
  • dom/Document.cpp: (WebCore::Document::inspectorController):
  • dom/Document.h:
  • dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::inspectorController):
  • inspector/InjectedScriptHost.cpp: (WebCore::InjectedScriptHost::InjectedScriptHost): (WebCore::InjectedScriptHost::injectScript): (WebCore::InjectedScriptHost::nextWorkerId): (WebCore::InjectedScriptHost::didCreateWorker): (WebCore::InjectedScriptHost::willDestroyWorker):
  • inspector/InjectedScriptHost.h:
  • inspector/InjectedScriptHost.idl:
  • inspector/InspectorController.cpp: (WebCore::InspectorController::populateScriptObjects): (WebCore::InspectorController::resetScriptObjects): (WebCore::InspectorController::didCommitLoad): (WebCore::InspectorController::didCreateWorker): (WebCore::InspectorController::willDestroyWorker):
  • inspector/InspectorController.h:
  • inspector/InspectorFrontend.cpp: (WebCore::InspectorFrontend::didCreateWorker): (WebCore::InspectorFrontend::willDestroyWorker):
  • inspector/InspectorFrontend.h:
  • inspector/InspectorWorkerResource.h: Added. (WebCore::InspectorWorkerResource::create): (WebCore::InspectorWorkerResource::id): (WebCore::InspectorWorkerResource::url): (WebCore::InspectorWorkerResource::isSharedWorker): (WebCore::InspectorWorkerResource::InspectorWorkerResource):
  • inspector/front-end/Checkbox.js: Added. (WebInspector.Checkbox.callbackWrapper): (WebInspector.Checkbox): (WebInspector.Checkbox.prototype.checked):
  • inspector/front-end/InjectedFakeWorker.js: (InjectedFakeWorker.FakeWorker): (InjectedFakeWorker.FakeWorker.prototype.terminate): (InjectedFakeWorker.FakeWorker.prototype._handleException): (InjectedFakeWorker.FakeWorker.prototype._importScripts): (InjectedFakeWorker.FakeWorker.prototype._loadScript): (InjectedFakeWorker.FakeWorker.prototype._expandURLAndCheckOrigin):
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel): (WebInspector.ScriptsPanel.prototype.debuggerWasEnabled): (WebInspector.ScriptsPanel.prototype.debuggerWasDisabled): (WebInspector.ScriptsPanel.prototype.reset):
  • inspector/front-end/StylesSidebarPane.js: (WebInspector.StylePropertiesSection.showInheritedToggleFunction): (WebInspector.StylePropertiesSection):
  • inspector/front-end/WebKit.qrc:
  • inspector/front-end/WorkersSidebarPane.js: Added. (WebInspector.WorkersSidebarPane): (WebInspector.WorkersSidebarPane.prototype.addWorker): (WebInspector.WorkersSidebarPane.prototype.removeWorker): (WebInspector.WorkersSidebarPane.prototype.setInstrumentation): (WebInspector.WorkersSidebarPane.prototype.reset): (WebInspector.WorkersSidebarPane.prototype._onTriggerInstrument): (WebInspector.Worker): (WebInspector.didCreateWorker): (WebInspector.willDestroyWorker):
  • inspector/front-end/inspector.css:
  • inspector/front-end/inspector.html:
  • workers/AbstractWorker.cpp: (WebCore::AbstractWorker::AbstractWorker): (WebCore::AbstractWorker::~AbstractWorker): (WebCore::AbstractWorker::onDestroyWorker): (WebCore::AbstractWorker::contextDestroyed):
  • workers/AbstractWorker.h: (WebCore::AbstractWorker::id):
  • workers/SharedWorker.cpp: (WebCore::SharedWorker::SharedWorker):
  • workers/Worker.cpp: (WebCore::Worker::Worker):

WebKit/chromium:

  • src/js/InspectorControllerImpl.js: (devtools.InspectorBackendImpl):
Location:
trunk
Files:
2 added
28 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r55767 r55771  
     12010-03-10  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: display list of active workers & support debugging
     6        with fake workers.
     7        https://bugs.webkit.org/show_bug.cgi?id=35568
     8
     9        * English.lproj/localizedStrings.js:
     10        * WebCore.gypi:
     11        * WebCore.vcproj/WebCore.vcproj:
     12        * bindings/js/JSInjectedScriptHostCustom.cpp:
     13        (WebCore::InjectedScriptHost::createInjectedScript):
     14        (WebCore::InjectedScriptHost::injectedScriptFor):
     15        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
     16        (WebCore::InjectedScriptHost::createInjectedScript):
     17        (WebCore::InjectedScriptHost::injectedScriptFor):
     18        * dom/Document.cpp:
     19        (WebCore::Document::inspectorController):
     20        * dom/Document.h:
     21        * dom/ScriptExecutionContext.h:
     22        (WebCore::ScriptExecutionContext::inspectorController):
     23        * inspector/InjectedScriptHost.cpp:
     24        (WebCore::InjectedScriptHost::InjectedScriptHost):
     25        (WebCore::InjectedScriptHost::injectScript):
     26        (WebCore::InjectedScriptHost::nextWorkerId):
     27        (WebCore::InjectedScriptHost::didCreateWorker):
     28        (WebCore::InjectedScriptHost::willDestroyWorker):
     29        * inspector/InjectedScriptHost.h:
     30        * inspector/InjectedScriptHost.idl:
     31        * inspector/InspectorController.cpp:
     32        (WebCore::InspectorController::populateScriptObjects):
     33        (WebCore::InspectorController::resetScriptObjects):
     34        (WebCore::InspectorController::didCommitLoad):
     35        (WebCore::InspectorController::didCreateWorker):
     36        (WebCore::InspectorController::willDestroyWorker):
     37        * inspector/InspectorController.h:
     38        * inspector/InspectorFrontend.cpp:
     39        (WebCore::InspectorFrontend::didCreateWorker):
     40        (WebCore::InspectorFrontend::willDestroyWorker):
     41        * inspector/InspectorFrontend.h:
     42        * inspector/InspectorWorkerResource.h: Added.
     43        (WebCore::InspectorWorkerResource::create):
     44        (WebCore::InspectorWorkerResource::id):
     45        (WebCore::InspectorWorkerResource::url):
     46        (WebCore::InspectorWorkerResource::isSharedWorker):
     47        (WebCore::InspectorWorkerResource::InspectorWorkerResource):
     48        * inspector/front-end/Checkbox.js: Added.
     49        (WebInspector.Checkbox.callbackWrapper):
     50        (WebInspector.Checkbox):
     51        (WebInspector.Checkbox.prototype.checked):
     52        * inspector/front-end/InjectedFakeWorker.js:
     53        (InjectedFakeWorker.FakeWorker):
     54        (InjectedFakeWorker.FakeWorker.prototype.terminate):
     55        (InjectedFakeWorker.FakeWorker.prototype._handleException):
     56        (InjectedFakeWorker.FakeWorker.prototype._importScripts):
     57        (InjectedFakeWorker.FakeWorker.prototype._loadScript):
     58        (InjectedFakeWorker.FakeWorker.prototype._expandURLAndCheckOrigin):
     59        * inspector/front-end/ScriptsPanel.js:
     60        (WebInspector.ScriptsPanel):
     61        (WebInspector.ScriptsPanel.prototype.debuggerWasEnabled):
     62        (WebInspector.ScriptsPanel.prototype.debuggerWasDisabled):
     63        (WebInspector.ScriptsPanel.prototype.reset):
     64        * inspector/front-end/StylesSidebarPane.js:
     65        (WebInspector.StylePropertiesSection.showInheritedToggleFunction):
     66        (WebInspector.StylePropertiesSection):
     67        * inspector/front-end/WebKit.qrc:
     68        * inspector/front-end/WorkersSidebarPane.js: Added.
     69        (WebInspector.WorkersSidebarPane):
     70        (WebInspector.WorkersSidebarPane.prototype.addWorker):
     71        (WebInspector.WorkersSidebarPane.prototype.removeWorker):
     72        (WebInspector.WorkersSidebarPane.prototype.setInstrumentation):
     73        (WebInspector.WorkersSidebarPane.prototype.reset):
     74        (WebInspector.WorkersSidebarPane.prototype._onTriggerInstrument):
     75        (WebInspector.Worker):
     76        (WebInspector.didCreateWorker):
     77        (WebInspector.willDestroyWorker):
     78        * inspector/front-end/inspector.css:
     79        * inspector/front-end/inspector.html:
     80        * workers/AbstractWorker.cpp:
     81        (WebCore::AbstractWorker::AbstractWorker):
     82        (WebCore::AbstractWorker::~AbstractWorker):
     83        (WebCore::AbstractWorker::onDestroyWorker):
     84        (WebCore::AbstractWorker::contextDestroyed):
     85        * workers/AbstractWorker.h:
     86        (WebCore::AbstractWorker::id):
     87        * workers/SharedWorker.cpp:
     88        (WebCore::SharedWorker::SharedWorker):
     89        * workers/Worker.cpp:
     90        (WebCore::Worker::Worker):
     91
    1922010-03-10  Roland Steiner  <rolandsteiner@chromium.org>
    293
  • trunk/WebCore/WebCore.gypi

    r55673 r55771  
    16231623            'inspector/InspectorTimelineAgent.cpp',
    16241624            'inspector/InspectorTimelineAgent.h',
     1625            'inspector/InspectorWorkerResource.h',
    16251626            'inspector/JavaScriptCallFrame.cpp',
    16261627            'inspector/JavaScriptCallFrame.h',
     
    37443745            'inspector/front-end/CallStackSidebarPane.js',
    37453746            'inspector/front-end/ChangesView.js',
     3747            'inspector/front-end/Checkbox.js',
    37463748            'inspector/front-end/Color.js',
    37473749            'inspector/front-end/ConsolePanel.js',
     
    38203822            'inspector/front-end/WatchExpressionsSidebarPane.js',
    38213823            'inspector/front-end/WelcomeView.js',
     3824            'inspector/front-end/WorkersSidebarPane.js',
    38223825            'inspector/front-end/audits.css',
    38233826            'inspector/front-end/inspector.css',
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r55635 r55771  
    4276242762                        </File>
    4276342763                        <File
     42764                                RelativePath="..\inspector\InspectorWorkerResource.h"
     42765                                >
     42766                        </File>
     42767                        <File
    4276442768                                RelativePath="..\inspector\JavaScriptCallFrame.cpp"
    4276542769                                >
     
    4284142845                                </File>
    4284242846                                <File
     42847                                        RelativePath="..\inspector\front-end\Checkbox.js"
     42848                                        >
     42849                                </File>
     42850                                <File
    4284342851                                        RelativePath="..\inspector\front-end\Color.js"
    4284442852                                        >
     
    4314643154                                <File
    4314743155                                        RelativePath="..\inspector\front-end\WelcomeView.js"
     43156                                        >
     43157                                </File>
     43158                                <File
     43159                                        RelativePath="..\inspector\front-end\WorkersSidebarPane.js"
    4314843160                                        >
    4314943161                                </File>
  • trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp

    r55584 r55771  
    22 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
    4  * Copyright (C) 2009 Google Inc. All rights reserved.
     4 * Copyright (C) 2010 Google Inc. All rights reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    7676namespace WebCore {
    7777
    78 static ScriptObject createInjectedScript(const String& source, InjectedScriptHost* injectedScriptHost, ScriptState* scriptState, long id)
     78ScriptObject InjectedScriptHost::createInjectedScript(const String& source, ScriptState* scriptState, long id)
    7979{
    8080    SourceCode sourceCode = makeSource(source);
     
    9292
    9393    MarkedArgumentBuffer args;
    94     args.append(toJS(scriptState, globalObject, injectedScriptHost));
     94    args.append(toJS(scriptState, globalObject, this));
    9595    args.append(globalThisValue);
    9696    args.append(jsNumber(scriptState, id));
     
    222222        return InjectedScript(ScriptObject(scriptState, injectedScript));
    223223
    224     ASSERT(!m_injectedScriptSource.isEmpty());
    225     ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId);
    226     globalObject->setInjectedScript(injectedScriptObject.jsObject());
    227     InjectedScript result(injectedScriptObject);
    228     m_idToInjectedScript.set(m_nextInjectedScriptId, result);
    229     m_nextInjectedScriptId++;
     224    ASSERT(!m_injectedScriptSource.isEmpty());
     225    pair<long, ScriptObject> injectedScriptObject = injectScript(m_injectedScriptSource, scriptState);
     226    globalObject->setInjectedScript(injectedScriptObject.second.jsObject());
     227    InjectedScript result(injectedScriptObject.second);
     228    m_idToInjectedScript.set(injectedScriptObject.first, result);
    230229    return result;
    231230}
  • trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp

    r55584 r55771  
    8080}
    8181
    82 static ScriptObject createInjectedScript(const String& scriptSource, InjectedScriptHost* injectedScriptHost, ScriptState* inspectedScriptState, long id)
     82ScriptObject InjectedScriptHost::createInjectedScript(const String& scriptSource, ScriptState* inspectedScriptState, long id)
    8383{
    8484    v8::HandleScope scope;
     
    9191    // wrapper in the current context.
    9292    // FIXME: make it possible to use generic bindings factory for InjectedScriptHost.
    93     v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(injectedScriptHost);
     93    v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(this);
    9494    if (scriptHostWrapper.IsEmpty())
    9595        return ScriptObject();
     
    241241
    242242    ASSERT(!m_injectedScriptSource.isEmpty());
    243     ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, inspectedScriptState, m_nextInjectedScriptId);
    244     InjectedScript result(injectedScriptObject);
    245     m_idToInjectedScript.set(m_nextInjectedScriptId, result);
    246     ++m_nextInjectedScriptId;
    247     global->SetHiddenValue(key, injectedScriptObject.v8Object());
     243    pair<long, ScriptObject> injectedScript = injectScript(m_injectedScriptSource, inspectedScriptState);
     244    InjectedScript result(injectedScript.second);
     245    m_idToInjectedScript.set(injectedScript.first, result);
     246    global->SetHiddenValue(key, injectedScript.second.v8Object());
    248247    return result;
    249248}
  • trunk/WebCore/dom/Document.cpp

    r55673 r55771  
    47994799    return page() ? page()->inspectorTimelineAgent() : 0;
    48004800}
     4801
     4802InspectorController* Document::inspectorController() const
     4803{
     4804    return page() ? page()->inspectorController() : 0;
     4805}
    48014806#endif
    48024807
  • trunk/WebCore/dom/Document.h

    r55584 r55771  
    451451#if ENABLE(INSPECTOR)
    452452    InspectorTimelineAgent* inspectorTimelineAgent() const; // can be NULL
     453    virtual InspectorController* inspectorController() const; // can be NULL
    453454#endif
    454455
  • trunk/WebCore/dom/ScriptExecutionContext.h

    r55584 r55771  
    5050    class ScriptString;
    5151    class String;
     52#if ENABLE(INSPECTOR)
     53    class InspectorController;
     54#endif
    5255
    5356    enum MessageDestination {
     
    8588
    8689        SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
     90#if ENABLE(INSPECTOR)
     91        virtual InspectorController* inspectorController() const { return 0; }
     92#endif
    8793
    8894        virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
  • trunk/WebCore/inspector/InjectedScriptHost.cpp

    r55584 r55771  
    22 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
    4  * Copyright (C) 2009 Google Inc. All rights reserved.
     4 * Copyright (C) 2010 Google Inc. All rights reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    7171    : m_inspectorController(inspectorController)
    7272    , m_nextInjectedScriptId(1)
     73    , m_lastWorkerId(1 << 31) // Distinguish ids of fake workers from real ones, to minimize the chances they overlap.
    7374{
    7475}
     
    195196}
    196197
     198pair<long, ScriptObject> InjectedScriptHost::injectScript(const String& source, ScriptState* scriptState)
     199{
     200    long id = m_nextInjectedScriptId++;
     201    return std::make_pair(id, createInjectedScript(source, scriptState, id));
     202}
     203
     204#if ENABLE(WORKERS)
     205long InjectedScriptHost::nextWorkerId()
     206{
     207    return ++m_lastWorkerId;
     208}
     209
     210void InjectedScriptHost::didCreateWorker(long id, const String& url, bool isSharedWorker)
     211{
     212    if (m_inspectorController)
     213        m_inspectorController->didCreateWorker(id, url, isSharedWorker);
     214}
     215
     216void InjectedScriptHost::willDestroyWorker(long id)
     217{
     218    if (m_inspectorController)
     219        m_inspectorController->willDestroyWorker(id);
     220}
     221#endif // ENABLE(WORKERS)
     222
    197223} // namespace WebCore
    198224
  • trunk/WebCore/inspector/InjectedScriptHost.h

    r55584 r55771  
    8181    void selectDOMStorage(Storage* storage);
    8282#endif
     83#if ENABLE(WORKERS)
     84    long nextWorkerId();
     85    void didCreateWorker(long id, const String& url, bool isSharedWorker);
     86    void willDestroyWorker(long id);
     87#endif
    8388    void reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException);
    8489
     90    pair<long, ScriptObject> injectScript(const String& source, ScriptState*);
    8591    InjectedScript injectedScriptFor(ScriptState*);
    8692    InjectedScript injectedScriptForId(long);
     
    9298    InspectorDOMAgent* inspectorDOMAgent();
    9399    InspectorFrontend* inspectorFrontend();
     100    ScriptObject createInjectedScript(const String& source, ScriptState* scriptState, long id);
    94101
    95102    InspectorController* m_inspectorController;
    96103    String m_injectedScriptSource;
    97104    long m_nextInjectedScriptId;
     105    long m_lastWorkerId;
    98106    typedef HashMap<long, InjectedScript> IdToInjectedScriptMap;
    99107    IdToInjectedScriptMap m_idToInjectedScript;
  • trunk/WebCore/inspector/InjectedScriptHost.idl

    r55584 r55771  
    22 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
    4  * Copyright (C) 2009 Google Inc. All rights reserved.
     4 * Copyright (C) 2010 Google Inc. All rights reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    5656#endif
    5757
     58#if defined(ENABLE_WORKERS) && ENABLE_WORKERS
     59        void didCreateWorker(in long id, in DOMString url, in boolean isFakeWorker);
     60        void willDestroyWorker(in long id);
     61        long nextWorkerId();
     62#endif
    5863        [Custom] void reportDidDispatchOnInjectedScript(in long callId, in DOMObject result, in boolean isException);
    5964    };
  • trunk/WebCore/inspector/InspectorController.cpp

    r55761 r55771  
    6464#include "InspectorFrontendHost.h"
    6565#include "InspectorResource.h"
     66#include "InspectorWorkerResource.h"
    6667#include "InspectorTimelineAgent.h"
    6768#include "Page.h"
     
    731732        it->second->bind(m_frontend.get());
    732733#endif
     734#if ENABLE(WORKERS)
     735    WorkersMap::iterator workersEnd = m_workers.end();
     736    for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it)
     737        m_frontend->didCreateWorker(*it->second);
     738#endif
    733739
    734740    m_frontend->populateInterface();
     
    759765        it->second->unbind();
    760766#endif
    761 
     767#if ENABLE(WORKERS)
     768    m_workers.clear();
     769#endif
    762770    if (m_timelineAgent)
    763771        m_timelineAgent->reset();
     
    846854            pruneResources(resourceMap, loader);
    847855
    848     for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin();
    849          it != m_scriptsToEvaluateOnLoad.end(); ++it) {
    850         ScriptSourceCode scriptSourceCode(*it);
    851         loader->frame()->script()->evaluate(scriptSourceCode);
     856    if (m_scriptsToEvaluateOnLoad.size()) {
     857        ScriptState* scriptState = mainWorldScriptState(loader->frame());
     858        for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin();
     859             it != m_scriptsToEvaluateOnLoad.end(); ++it) {
     860            m_injectedScriptHost->injectScript(*it, scriptState);
     861        }
    852862    }
    853863}
     
    11911201        m_frontend->timelineProfilerWasStopped();
    11921202}
     1203
     1204#if ENABLE(WORKERS)
     1205void InspectorController::didCreateWorker(long id, const String& url, bool isSharedWorker)
     1206{
     1207    if (!enabled())
     1208        return;
     1209
     1210    RefPtr<InspectorWorkerResource> workerResource(InspectorWorkerResource::create(id, url, isSharedWorker));
     1211    m_workers.set(id, workerResource);
     1212    if (m_frontend)
     1213        m_frontend->didCreateWorker(*workerResource);
     1214}
     1215
     1216void InspectorController::willDestroyWorker(long id)
     1217{
     1218    if (!enabled())
     1219        return;
     1220
     1221    WorkersMap::iterator workerResource = m_workers.find(id);
     1222    if (workerResource == m_workers.end())
     1223        return;
     1224    if (m_frontend)
     1225        m_frontend->willDestroyWorker(*workerResource->second);
     1226    m_workers.remove(workerResource);
     1227}
     1228#endif // ENABLE(WORKERS)
    11931229
    11941230#if ENABLE(DATABASE)
  • trunk/WebCore/inspector/InspectorController.h

    r55761 r55771  
    8686class InspectorDOMStorageResource;
    8787class InspectorResource;
     88class InspectorWorkerResource;
    8889
    8990class InspectorController
     
    186187    void mainResourceFiredLoadEvent(DocumentLoader*, const KURL&);
    187188    void mainResourceFiredDOMContentEvent(DocumentLoader*, const KURL&);
    188    
     189
    189190    void didInsertDOMNode(Node*);
    190191    void didRemoveDOMNode(Node*);
    191192    void didModifyDOMAttr(Element*);
    192                                                        
     193#if ENABLE(WORKERS)
     194    void didCreateWorker(long id, const String& url, bool isSharedWorker);
     195    void willDestroyWorker(long id);
     196#endif
    193197    void getCookies(long callId);
    194198
     
    372376    ProfilesMap m_profiles;
    373377#endif
     378#if ENABLE(WORKERS)
     379    typedef HashMap<long, RefPtr<InspectorWorkerResource> > WorkersMap;
     380
     381    WorkersMap m_workers;
     382#endif
    374383};
    375384
  • trunk/WebCore/inspector/InspectorFrontend.cpp

    r55584 r55771  
    3838#include "InjectedScriptHost.h"
    3939#include "InspectorController.h"
     40#include "InspectorWorkerResource.h"
    4041#include "Node.h"
    4142#include "ScriptFunctionCall.h"
     
    472473}
    473474
     475#if ENABLE(WORKERS)
     476void InspectorFrontend::didCreateWorker(const InspectorWorkerResource& worker)
     477{
     478    ScriptFunctionCall function(m_webInspector, "dispatch");
     479    function.appendArgument("didCreateWorker");
     480    function.appendArgument(worker.id());
     481    function.appendArgument(worker.url());
     482    function.appendArgument(worker.isSharedWorker());
     483    function.call();
     484}
     485
     486void InspectorFrontend::willDestroyWorker(const InspectorWorkerResource& worker)
     487{
     488    ScriptFunctionCall function(m_webInspector, "dispatch");
     489    function.appendArgument("willDestroyWorker");
     490    function.appendArgument(worker.id());
     491    function.call();
     492}
     493#endif // ENABLE(WORKERS)
     494
    474495void InspectorFrontend::didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString)
    475496{
  • trunk/WebCore/inspector/InspectorFrontend.h

    r55584 r55771  
    4646    class SerializedScriptValue;
    4747    class Storage;
     48    class InspectorWorkerResource;
    4849
    4950    class InspectorFrontend : public Noncopyable {
     
    132133        void addRecordToTimeline(const ScriptObject&);
    133134
     135#if ENABLE(WORKERS)
     136        void didCreateWorker(const InspectorWorkerResource&);
     137        void willDestroyWorker(const InspectorWorkerResource&);
     138#endif // ENABLE(WORKER)
     139
    134140        void didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString);
    135141        void didDispatchOnInjectedScript(int callId, SerializedScriptValue* result, bool isException);
  • trunk/WebCore/inspector/InspectorWorkerResource.h

    r55770 r55771  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929 */
    3030
    31 #include "config.h"
     31#ifndef InspectorWorkerResource_h
     32#define InspectorWorkerResource_h
    3233
    33 #if ENABLE(SHARED_WORKERS)
     34#if ENABLE(WORKERS) && ENABLE(INSPECTOR)
    3435
    35 #include "SharedWorker.h"
    36 
    37 #include "KURL.h"
    38 #include "MessageChannel.h"
    39 #include "MessagePort.h"
    40 #include "SharedWorkerRepository.h"
     36#include "PlatformString.h"
     37#include <wtf/PassRefPtr.h>
     38#include <wtf/RefCounted.h>
     39#include <wtf/RefPtr.h>
    4140
    4241namespace WebCore {
    4342
    44 SharedWorker::SharedWorker(const String& url, const String& name, ScriptExecutionContext* context, ExceptionCode& ec)
    45     : AbstractWorker(context)
    46 {
    47     RefPtr<MessageChannel> channel = MessageChannel::create(scriptExecutionContext());
    48     m_port = channel->port1();
    49     OwnPtr<MessagePortChannel> remotePort = channel->port2()->disentangle(ec);
    50     ASSERT(!ec);
     43class InspectorWorkerResource : public RefCounted<InspectorWorkerResource> {
     44public:
     45    static PassRefPtr<InspectorWorkerResource> create(long id, const String& url, bool isSharedWorker)
     46    {
     47        return adoptRef(new InspectorWorkerResource(id, url, isSharedWorker));
     48    }
    5149
    52     KURL scriptUrl = resolveURL(url, ec);
    53     if (ec)
    54         return;
    55     SharedWorkerRepository::connect(this, remotePort.release(), scriptUrl, name, ec);
    56 }
     50    long id() const { return m_id; }
     51    const String& url() const { return m_url; }
     52    bool isSharedWorker() const { return m_isSharedWorker; }
     53private:
     54    InspectorWorkerResource(long id, const String& url, bool isSharedWorker)
     55        : m_id(id)
     56        , m_url(url)
     57        , m_isSharedWorker(isSharedWorker)
     58    {
     59    }
    5760
    58 SharedWorker::~SharedWorker()
    59 {
    60 }
     61    int m_id;
     62    String m_url;
     63    bool m_isSharedWorker;
     64};
    6165
    6266} // namespace WebCore
    6367
    64 #endif  // ENABLE(SHARED_WORKERS)
     68#endif // ENABLE(WORKERS) && ENABLE(INSPECTOR)
     69
     70#endif // InspectorWorkerResource_h
  • trunk/WebCore/inspector/front-end/InjectedFakeWorker.js

    r55584 r55771  
    2929 */
    3030
    31 var InjectedFakeWorker = function()
     31var InjectedFakeWorker = function(InjectedScriptHost, inspectedWindow, injectedScriptId)
    3232{
    3333
     
    4646function FakeWorker(worker, url)
    4747{
    48     var scriptURL = new URL(document.baseURI).completeWith(url);
    49 
    50     if (!scriptURL.sameOrigin(location.href))
    51         throw new DOMCoreException("SECURITY_ERR",18);
     48    var scriptURL = this._expandURLAndCheckOrigin(document.baseURI, location.href, url);
    5249
    5350    this._worker = worker;
    5451    this._buildWorker(scriptURL);
     52    this._id = InjectedScriptHost.nextWorkerId();
     53
     54    InjectedScriptHost.didCreateWorker(this._id, scriptURL.url, false);
    5555}
    5656
     
    6464    terminate: function()
    6565    {
     66        InjectedScriptHost.willDestroyWorker(this._id);
     67
    6668        if (this._frame != null) {
    6769            this._frame.onmessage = this._worker.onmessage = noop;
     
    9799    {
    98100        // NB: it should be an ErrorEvent, but creating it from script is not
    99         // currently supported, to emulate it on top of plain vanilla Event.
     101        // currently supported, so emulate it on top of plain vanilla Event.
    100102        var errorEvent = this._document.createEvent("Event");
    101103        errorEvent.initEvent("Event", false, false);
     
    148150    },
    149151
    150     _importScripts: function(evalTarget)
    151     {
    152         for (var i = 1; i < arguments.length; ++i)
    153             evalTarget.eval(this._loadScript(arguments[i]));
     152    _importScripts: function(targetFrame)
     153    {
     154        for (var i = 1; i < arguments.length; ++i) {
     155            var workerOrigin = targetFrame.__devtools.location.href;
     156            var url = this._expandURLAndCheckOrigin(workerOrigin, workerOrigin, arguments[i]);
     157            targetFrame.eval(this._loadScript(url.url) + "\n//@ sourceURL= " + url.url);
     158        }
    154159    },
    155160
     
    166171        }
    167172        return text;
     173    },
     174
     175    _expandURLAndCheckOrigin: function(baseURL, origin, url)
     176    {
     177        var scriptURL = new URL(baseURL).completeWith(url);
     178
     179        if (!scriptURL.sameOrigin(origin))
     180            throw new DOMCoreException("SECURITY_ERR",18);
     181        return scriptURL;
    168182    }
    169183};
  • trunk/WebCore/inspector/front-end/ScriptsPanel.js

    r55584 r55771  
    136136    this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane();
    137137    this.sidebarPanes.breakpoints = new WebInspector.BreakpointsSidebarPane();
     138    this.sidebarPanes.workers = new WebInspector.WorkersSidebarPane();
    138139
    139140    for (var pane in this.sidebarPanes)
     
    425426
    426427        this._debuggerEnabled = true;
    427         this.reset();
     428        this.reset(true);
    428429    },
    429430
     
    434435
    435436        this._debuggerEnabled = false;
    436         this.reset();
    437     },
    438 
    439     reset: function()
     437        this.reset(true);
     438    },
     439
     440    reset: function(preserveWorkers)
    440441    {
    441442        this.visibleView = null;
     
    473474        this.sidebarPanes.watchExpressions.refreshExpressions();
    474475        this.sidebarPanes.breakpoints.reset();
     476        if (!preserveWorkers)
     477            this.sidebarPanes.workers.reset();
    475478    },
    476479
  • trunk/WebCore/inspector/front-end/StylesSidebarPane.js

    r55764 r55771  
    405405            this.element.addStyleClass("show-inherited");
    406406
    407         var showInheritedLabel = document.createElement("label");
    408         var showInheritedInput = document.createElement("input");
    409         showInheritedInput.type = "checkbox";
    410         showInheritedInput.checked = WebInspector.settings.showInheritedComputedStyleProperties;
    411 
    412407        var computedStyleSection = this;
    413408        var showInheritedToggleFunction = function(event) {
    414             WebInspector.settings.showInheritedComputedStyleProperties = showInheritedInput.checked;
     409            WebInspector.settings.showInheritedComputedStyleProperties = computedStyleSection._showInheritedCheckbox.checked();
    415410            if (WebInspector.settings.showInheritedComputedStyleProperties)
    416411                computedStyleSection.element.addStyleClass("show-inherited");
    417412            else
    418413                computedStyleSection.element.removeStyleClass("show-inherited");
    419             event.stopPropagation();
    420414        };
    421415
    422         showInheritedLabel.addEventListener("click", showInheritedToggleFunction, false);
    423 
    424         showInheritedLabel.appendChild(showInheritedInput);
    425         showInheritedLabel.appendChild(document.createTextNode(WebInspector.UIString("Show inherited")));
    426         this.subtitleElement.appendChild(showInheritedLabel);
     416        this._showInheritedCheckbox = new WebInspector.Checkbox(WebInspector.UIString("Show inherited"),
     417                                                                showInheritedToggleFunction,
     418                                                                WebInspector.settings.showInheritedComputedStyleProperties);
     419
     420        this.subtitleElement.appendChild(this._showInheritedCheckbox.element);
    427421    } else {
    428422        if (!subtitle) {
  • trunk/WebCore/inspector/front-end/WebKit.qrc

    r55584 r55771  
    1414    <file>CallStackSidebarPane.js</file>
    1515    <file>ChangesView.js</file>
     16    <file>Checkbox.js</file>
    1617    <file>Color.js</file>
    1718    <file>ConsolePanel.js</file>
     
    9091    <file>WatchExpressionsSidebarPane.js</file>
    9192    <file>WelcomeView.js</file>
     93    <file>WorkersSidebarPane.js</file>
    9294    <file>audits.css</file>
    9395    <file>inspector.css</file>
  • trunk/WebCore/inspector/front-end/inspector.css

    r55765 r55771  
    13301330}
    13311331
    1332 .section .header input[type=checkbox] {
    1333     height: 10px;
    1334     width: 10px;
    1335     margin-left: 0;
    1336     margin-top: 0;
    1337     margin-bottom: 0;
    1338     vertical-align: 2px;
    1339 }
    1340 
    13411332.section .header .subtitle, .event-bar .header .subtitle {
    13421333    float: right;
     
    17211712    background-position: center center, bottom;
    17221713    height: 5px;
     1714}
     1715
     1716.sidebar-pane-subtitle {
     1717    float: right;
     1718    overflow: hidden;
     1719}
     1720
     1721.sidebar-pane-subtitle input, .section .header input[type=checkbox] {
     1722    font-size: inherit;
     1723    hight: 1em;
     1724    width: 1em;
     1725    margin-left: 0;
     1726    margin-top: 0;
     1727    margin-bottom: 0.25em;
     1728    vertical-align: bottom;
    17231729}
    17241730
     
    38833889}
    38843890
     3891.workers-list {
     3892    list-style: none;
     3893    margin: 0;
     3894    padding: 0;
     3895}
     3896 
     3897.workers-list > li {
     3898    overflow: hidden;
     3899    text-overflow: ellipsis;
     3900    white-space: nowrap;
     3901    margin-left: 1em;
     3902    font-size: 12px;
     3903}
     3904
     3905a.worker-item {
     3906    color: rgb(33%, 33%, 33%);
     3907    cursor: pointer;
     3908    text-decoration: none;
     3909}
     3910
     3911a.worker-item:hover {
     3912    color: rgb(15%, 15%, 15%);
     3913}
     3914
  • trunk/WebCore/inspector/front-end/inspector.html

    r55584 r55771  
    4242    <script type="text/javascript" src="Object.js"></script>
    4343    <script type="text/javascript" src="Settings.js"></script>
     44    <script type="text/javascript" src="Checkbox.js"></script>
    4445    <script type="text/javascript" src="ContextMenu.js"></script>
    4546    <script type="text/javascript" src="KeyboardShortcut.js"></script>
     
    7576    <script type="text/javascript" src="ScopeChainSidebarPane.js"></script>
    7677    <script type="text/javascript" src="WatchExpressionsSidebarPane.js"></script>
     78    <script type="text/javascript" src="WorkersSidebarPane.js"></script>
    7779    <script type="text/javascript" src="MetricsSidebarPane.js"></script>
    7880    <script type="text/javascript" src="PropertiesSidebarPane.js"></script>
  • trunk/WebCore/workers/AbstractWorker.cpp

    r55584 r55771  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3939#include "EventException.h"
    4040#include "EventNames.h"
     41#include "InspectorController.h"
    4142#include "ScriptExecutionContext.h"
    4243#include "SecurityOrigin.h"
     
    4445namespace WebCore {
    4546
     47long AbstractWorker::s_lastId;
     48
    4649AbstractWorker::AbstractWorker(ScriptExecutionContext* context)
    4750    : ActiveDOMObject(context, this)
     51    , m_id(++s_lastId)
    4852{
    4953}
     
    5155AbstractWorker::~AbstractWorker()
    5256{
     57    onDestroyWorker();
     58}
     59
     60void AbstractWorker::onDestroyWorker()
     61{
     62#if ENABLE(INSPECTOR)
     63    if (InspectorController* inspector = scriptExecutionContext() ? scriptExecutionContext()->inspectorController() : 0)
     64        inspector->willDestroyWorker(id());
     65#endif
     66}
     67
     68void AbstractWorker::contextDestroyed()
     69{
     70    onDestroyWorker();
     71    ActiveDOMObject::contextDestroyed();
    5372}
    5473
  • trunk/WebCore/workers/AbstractWorker.h

    r55584 r55771  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5858        using RefCounted<AbstractWorker>::deref;
    5959
     60        long id() const { return m_id; }
     61        virtual void contextDestroyed();
    6062        AbstractWorker(ScriptExecutionContext*);
    6163        virtual ~AbstractWorker();
     
    7072        virtual EventTargetData* eventTargetData();
    7173        virtual EventTargetData* ensureEventTargetData();
     74        void onDestroyWorker();
    7275       
    7376        EventTargetData m_eventTargetData;
     77        long m_id;
     78
     79        static long s_lastId;
    7480    };
    7581
  • trunk/WebCore/workers/SharedWorker.cpp

    r55584 r55771  
    3535#include "SharedWorker.h"
    3636
     37#include "InspectorController.h"
    3738#include "KURL.h"
    3839#include "MessageChannel.h"
     
    5455        return;
    5556    SharedWorkerRepository::connect(this, remotePort.release(), scriptUrl, name, ec);
     57#if ENABLE(INSPECTOR)
     58    if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
     59        inspector->didCreateWorker(id(), scriptUrl.string(), true);
     60#endif
    5661}
    5762
  • trunk/WebCore/workers/Worker.cpp

    r55584 r55771  
    4141#include "Frame.h"
    4242#include "FrameLoader.h"
     43#include "InspectorController.h"
    4344#include "MessageEvent.h"
    4445#include "TextEncoding.h"
     
    6162    m_scriptLoader->loadAsynchronously(scriptExecutionContext(), scriptURL, DenyCrossOriginRequests, this);
    6263    setPendingActivity(this);  // The worker context does not exist while loading, so we must ensure that the worker object is not collected, as well as its event listeners.
     64#if ENABLE(INSPECTOR)
     65    if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
     66        inspector->didCreateWorker(id(), scriptURL.string(), false);
     67#endif
    6368}
    6469
  • trunk/WebKit/chromium/ChangeLog

    r55769 r55771  
     12010-03-10  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: display list of active workers & support debugging
     6        with fake workers
     7        https://bugs.webkit.org/show_bug.cgi?id=35568
     8
     9        * src/js/InspectorControllerImpl.js:
     10        (devtools.InspectorBackendImpl):
     11
    1122010-03-10  Tony Chang  <tony@chromium.org>
    213
  • trunk/WebKit/chromium/src/js/InspectorControllerImpl.js

    r55584 r55771  
    3939{
    4040    WebInspector.InspectorBackendStub.call(this);
     41    this.installInspectorControllerDelegate_("addScriptToEvaluateOnLoad");
    4142    this.installInspectorControllerDelegate_("clearMessages");
    4243    this.installInspectorControllerDelegate_("copyNode");
     
    5859    this.installInspectorControllerDelegate_("hideDOMNodeHighlight");
    5960    this.installInspectorControllerDelegate_("releaseWrapperObjectGroup");
     61    this.installInspectorControllerDelegate_("removeAllScriptsToEvaluateOnLoad");
    6062    this.installInspectorControllerDelegate_("reloadPage");
    6163    this.installInspectorControllerDelegate_("removeAttribute");
Note: See TracChangeset for help on using the changeset viewer.