[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00

pfeldman at chromium.org pfeldman at chromium.org
Wed Mar 17 18:16:09 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 25f64e872b5d6f107ef2010db6086563b1ae9ca7
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Mar 4 14:00:40 2010 +0000

    2010-03-04  Andrey Kosyakov  <caseq at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Added support for worker instrumentation in inspector
            (display list of active workers, allow debugging of workers
            by injecting fake JS implementation)
    
            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/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):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55522 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 35fc352..80177aa 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,93 @@
+2010-03-04  Andrey Kosyakov  <caseq at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Added support for worker instrumentation in inspector
+        (display list of active workers, allow debugging of workers
+        by injecting fake JS implementation)
+
+        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/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):
+
 2010-03-04  Jocelyn Turcotte  <jocelyn.turcotte at nokia.com>
 
         Reviewed by Tor Arne Vestbø.
diff --git a/WebCore/English.lproj/localizedStrings.js b/WebCore/English.lproj/localizedStrings.js
index 4a37659..50d4560 100644
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 699cce7..da10582 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1614,6 +1614,7 @@
             'inspector/InspectorResource.h',
             'inspector/InspectorTimelineAgent.cpp',
             'inspector/InspectorTimelineAgent.h',
+            'inspector/InspectorWorkerResource.h',
             'inspector/JavaScriptCallFrame.cpp',
             'inspector/JavaScriptCallFrame.h',
             'inspector/ScriptBreakpoint.h',
@@ -3731,6 +3732,7 @@
             'inspector/front-end/Callback.js',
             'inspector/front-end/CallStackSidebarPane.js',
             'inspector/front-end/ChangesView.js',
+            'inspector/front-end/Checkbox.js',
             'inspector/front-end/Color.js',
             'inspector/front-end/ConsolePanel.js',
             'inspector/front-end/ConsoleView.js',
@@ -3807,6 +3809,7 @@
             'inspector/front-end/View.js',
             'inspector/front-end/WatchExpressionsSidebarPane.js',
             'inspector/front-end/WelcomeView.js',
+            'inspector/front-end/WorkersSidebarPane.js',
             'inspector/front-end/audits.css',
             'inspector/front-end/inspector.css',
             'inspector/front-end/inspectorSyntaxHighlight.css',
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 2ad8090..58b94eb 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -42717,6 +42717,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\inspector\InspectorWorkerResource.h"
+				>
+			</File>
+			<File
 				RelativePath="..\inspector\JavaScriptCallFrame.cpp"
 				>
 			</File>
@@ -42796,6 +42800,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\Checkbox.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\Color.js"
 					>
 				</File>
@@ -43103,6 +43111,10 @@
 					RelativePath="..\inspector\front-end\WelcomeView.js"
 					>
 				</File>
+				<File
+					RelativePath="..\inspector\front-end\WorkersSidebarPane.js"
+					>
+				</File>
 			</Filter>
 		</Filter>
 		<Filter
diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
index 947674a..75597fb 100644
--- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Matt Lilek <webkit at mattlilek.com>
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -75,7 +75,7 @@ using namespace JSC;
 
 namespace WebCore {
 
-static ScriptObject createInjectedScript(const String& source, InjectedScriptHost* injectedScriptHost, ScriptState* scriptState, long id)
+ScriptObject InjectedScriptHost::createInjectedScript(const String& source, ScriptState* scriptState, long id)
 {
     SourceCode sourceCode = makeSource(source);
     JSLock lock(SilenceAssertionsOnly);
@@ -91,7 +91,7 @@ static ScriptObject createInjectedScript(const String& source, InjectedScriptHos
         return ScriptObject();
 
     MarkedArgumentBuffer args;
-    args.append(toJS(scriptState, globalObject, injectedScriptHost));
+    args.append(toJS(scriptState, globalObject, this));
     args.append(globalThisValue);
     args.append(jsNumber(scriptState, id));
     JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args);
@@ -221,12 +221,11 @@ InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
     if (injectedScript)
         return InjectedScript(ScriptObject(scriptState, injectedScript));
 
-    ASSERT(!m_injectedScriptSource.isEmpty());
-    ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId);
-    globalObject->setInjectedScript(injectedScriptObject.jsObject());
-    InjectedScript result(injectedScriptObject);
-    m_idToInjectedScript.set(m_nextInjectedScriptId, result);
-    m_nextInjectedScriptId++;
+    ASSERT(!m_injectedScriptSource.isEmpty()); 
+    pair<long, ScriptObject> injectedScriptObject = injectScript(m_injectedScriptSource, scriptState);
+    globalObject->setInjectedScript(injectedScriptObject.second.jsObject());
+    InjectedScript result(injectedScriptObject.second);
+    m_idToInjectedScript.set(injectedScriptObject.first, result);
     return result;
 }
 
diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index f588169..8bf0bfa 100644
--- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -79,7 +79,7 @@ static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHos
     return instance;
 }
 
-static ScriptObject createInjectedScript(const String& scriptSource, InjectedScriptHost* injectedScriptHost, ScriptState* inspectedScriptState, long id)
+ScriptObject InjectedScriptHost::createInjectedScript(const String& scriptSource, ScriptState* inspectedScriptState, long id)
 {
     v8::HandleScope scope;
 
@@ -90,7 +90,7 @@ static ScriptObject createInjectedScript(const String& scriptSource, InjectedScr
     // instead of calling toV8() that would create the
     // wrapper in the current context.
     // FIXME: make it possible to use generic bindings factory for InjectedScriptHost.
-    v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(injectedScriptHost);
+    v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(this);
     if (scriptHostWrapper.IsEmpty())
         return ScriptObject();
 
@@ -240,11 +240,10 @@ InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScrip
         return InjectedScript(ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val)));
 
     ASSERT(!m_injectedScriptSource.isEmpty());
-    ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, inspectedScriptState, m_nextInjectedScriptId);
-    InjectedScript result(injectedScriptObject);
-    m_idToInjectedScript.set(m_nextInjectedScriptId, result);
-    ++m_nextInjectedScriptId;
-    global->SetHiddenValue(key, injectedScriptObject.v8Object());
+    pair<long, ScriptObject> injectedScript = injectScript(m_injectedScriptSource, inspectedScriptState);
+    InjectedScript result(injectedScript.second);
+    m_idToInjectedScript.set(injectedScript.first, result);
+    global->SetHiddenValue(key, injectedScript.second.v8Object());
     return result;
 }
 
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index d0fe75f..4263157 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -4798,6 +4798,11 @@ InspectorTimelineAgent* Document::inspectorTimelineAgent() const
 {
     return page() ? page()->inspectorTimelineAgent() : 0;
 }
+
+InspectorController* Document::inspectorController() const 
+{
+    return page() ? page()->inspectorController() : 0;
+}
 #endif
 
 } // namespace WebCore
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 20df138..df87ebd 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -450,6 +450,7 @@ public:
     Settings* settings() const; // can be NULL
 #if ENABLE(INSPECTOR)
     InspectorTimelineAgent* inspectorTimelineAgent() const; // can be NULL
+    virtual InspectorController* inspectorController() const; // can be NULL
 #endif
 
     PassRefPtr<Range> createRange();
diff --git a/WebCore/dom/ScriptExecutionContext.h b/WebCore/dom/ScriptExecutionContext.h
index 709bc69..f1c79cf 100644
--- a/WebCore/dom/ScriptExecutionContext.h
+++ b/WebCore/dom/ScriptExecutionContext.h
@@ -49,6 +49,9 @@ namespace WebCore {
     class SecurityOrigin;
     class ScriptString;
     class String;
+#if ENABLE(INSPECTOR)
+    class InspectorController;
+#endif
 
     enum MessageDestination {
 #if ENABLE(INSPECTOR)
@@ -84,6 +87,9 @@ namespace WebCore {
         virtual String userAgent(const KURL&) const = 0;
 
         SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
+#if ENABLE(INSPECTOR)
+        virtual InspectorController* inspectorController() const { return 0; }
+#endif
 
         virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
         virtual void addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL) = 0;
diff --git a/WebCore/inspector/InjectedScriptHost.cpp b/WebCore/inspector/InjectedScriptHost.cpp
index 6dbbdfd..5ba7085 100644
--- a/WebCore/inspector/InjectedScriptHost.cpp
+++ b/WebCore/inspector/InjectedScriptHost.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Matt Lilek <webkit at mattlilek.com>
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -70,6 +70,7 @@ namespace WebCore {
 InjectedScriptHost::InjectedScriptHost(InspectorController* inspectorController)
     : m_inspectorController(inspectorController)
     , m_nextInjectedScriptId(1)
+    , m_lastWorkerId(1 << 31) // Distinguish ids of fake workers from real ones, to minimize the chances they overlap.
 {
 }
 
@@ -194,6 +195,31 @@ InspectorFrontend* InjectedScriptHost::inspectorFrontend()
     return m_inspectorController->m_frontend.get();
 }
 
+pair<long, ScriptObject> InjectedScriptHost::injectScript(const String& source, ScriptState* scriptState)
+{
+    long id = m_nextInjectedScriptId++;
+    return std::make_pair(id, createInjectedScript(source, scriptState, id));
+}
+
+#if ENABLE(WORKERS)
+long InjectedScriptHost::nextWorkerId()
+{
+    return ++m_lastWorkerId;
+}
+
+void InjectedScriptHost::didCreateWorker(long id, const String& url, bool isSharedWorker)
+{
+    if (m_inspectorController)
+        m_inspectorController->didCreateWorker(id, url, isSharedWorker);
+}
+
+void InjectedScriptHost::willDestroyWorker(long id)
+{
+    if (m_inspectorController)
+        m_inspectorController->willDestroyWorker(id);
+}
+#endif // ENABLE(WORKERS)
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InjectedScriptHost.h b/WebCore/inspector/InjectedScriptHost.h
index 112d556..40e1af2 100644
--- a/WebCore/inspector/InjectedScriptHost.h
+++ b/WebCore/inspector/InjectedScriptHost.h
@@ -80,8 +80,14 @@ public:
 #if ENABLE(DOM_STORAGE)
     void selectDOMStorage(Storage* storage);
 #endif
+#if ENABLE(WORKERS)
+    long nextWorkerId();
+    void didCreateWorker(long id, const String& url, bool isSharedWorker);
+    void willDestroyWorker(long id);
+#endif
     void reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException);
 
+    pair<long, ScriptObject> injectScript(const String& source, ScriptState*);
     InjectedScript injectedScriptFor(ScriptState*);
     InjectedScript injectedScriptForId(long);
     void discardInjectedScripts();
@@ -91,10 +97,12 @@ private:
     InjectedScriptHost(InspectorController* inspectorController);
     InspectorDOMAgent* inspectorDOMAgent();
     InspectorFrontend* inspectorFrontend();
+    ScriptObject createInjectedScript(const String& source, ScriptState* scriptState, long id);
 
     InspectorController* m_inspectorController;
     String m_injectedScriptSource;
     long m_nextInjectedScriptId;
+    long m_lastWorkerId;
     typedef HashMap<long, InjectedScript> IdToInjectedScriptMap;
     IdToInjectedScriptMap m_idToInjectedScript;
 };
diff --git a/WebCore/inspector/InjectedScriptHost.idl b/WebCore/inspector/InjectedScriptHost.idl
index 73a36fd..2a1c129 100644
--- a/WebCore/inspector/InjectedScriptHost.idl
+++ b/WebCore/inspector/InjectedScriptHost.idl
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Matt Lilek <webkit at mattlilek.com>
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -55,6 +55,11 @@ module core {
         [Custom] void selectDOMStorage(in DOMObject storage);
 #endif
 
+#if defined(ENABLE_WORKERS) && ENABLE_WORKERS
+        void didCreateWorker(in long id, in DOMString url, in boolean isFakeWorker);
+        void willDestroyWorker(in long id);
+        long nextWorkerId();
+#endif
         [Custom] void reportDidDispatchOnInjectedScript(in long callId, in DOMObject result, in boolean isException);
     };
 }
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index 0f03610..38a39b1 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -63,6 +63,7 @@
 #include "InspectorFrontend.h"
 #include "InspectorFrontendHost.h"
 #include "InspectorResource.h"
+#include "InspectorWorkerResource.h"
 #include "InspectorTimelineAgent.h"
 #include "Page.h"
 #include "ProgressTracker.h"
@@ -689,7 +690,11 @@ void InspectorController::populateScriptObjects()
     for (DOMStorageResourcesMap::iterator it = m_domStorageResources.begin(); it != domStorageEnd; ++it)
         it->second->bind(m_frontend.get());
 #endif
-
+#if ENABLE(WORKERS)
+    WorkersMap::iterator workersEnd = m_workers.end();
+    for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it)
+        m_frontend->didCreateWorker(*it->second);
+#endif
     if (m_profilerEnabled)
         m_frontend->profilerWasEnabled();
 
@@ -720,7 +725,9 @@ void InspectorController::resetScriptObjects()
     for (DOMStorageResourcesMap::iterator it = m_domStorageResources.begin(); it != domStorageEnd; ++it)
         it->second->unbind();
 #endif
-
+#if ENABLE(WORKERS)
+    m_workers.clear();
+#endif
     if (m_timelineAgent)
         m_timelineAgent->reset();
 
@@ -807,10 +814,10 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
         if (ResourcesMap* resourceMap = m_frameResources.get(frame))
             pruneResources(resourceMap, loader);
 
+    ScriptState* scriptState = mainWorldScriptState(loader->frame());
     for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin();
          it != m_scriptsToEvaluateOnLoad.end(); ++it) {
-        ScriptSourceCode scriptSourceCode(*it);
-        loader->frame()->script()->evaluate(scriptSourceCode);
+        m_injectedScriptHost->injectScript(*it, scriptState);
     }
 }
 
@@ -1153,6 +1160,32 @@ void InspectorController::stopTimelineProfiler()
         m_frontend->timelineProfilerWasStopped();
 }
 
+#if ENABLE(WORKERS)
+void InspectorController::didCreateWorker(long id, const String& url, bool isSharedWorker)
+{
+    if (!enabled())
+        return;
+
+    RefPtr<InspectorWorkerResource> workerResource(InspectorWorkerResource::create(id, url, isSharedWorker));
+    m_workers.set(id, workerResource);
+    if (m_frontend)
+        m_frontend->didCreateWorker(*workerResource);
+}
+
+void InspectorController::willDestroyWorker(long id)
+{
+    if (!enabled())
+        return;
+
+    WorkersMap::iterator workerResource = m_workers.find(id);
+    if (workerResource == m_workers.end())
+        return;
+    if (m_frontend)
+        m_frontend->willDestroyWorker(*workerResource->second);
+    m_workers.remove(workerResource);
+}
+#endif // ENABLE(WORKERS)
+
 #if ENABLE(DATABASE)
 void InspectorController::selectDatabase(Database* database)
 {
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index 500b0df..9830f46 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -85,6 +85,7 @@ class ConsoleMessage;
 class InspectorDatabaseResource;
 class InspectorDOMStorageResource;
 class InspectorResource;
+class InspectorWorkerResource;
 
 class InspectorController
 #if ENABLE(JAVASCRIPT_DEBUGGER)
@@ -186,11 +187,14 @@ public:
 
     void mainResourceFiredLoadEvent(DocumentLoader*, const KURL&);
     void mainResourceFiredDOMContentEvent(DocumentLoader*, const KURL&);
-    
+
     void didInsertDOMNode(Node*);
     void didRemoveDOMNode(Node*);
     void didModifyDOMAttr(Element*);
-                                                        
+#if ENABLE(WORKERS)
+    void didCreateWorker(long id, const String& url, bool isSharedWorker);
+    void willDestroyWorker(long id);
+#endif
     void getCookies(long callId);
 
 #if ENABLE(DATABASE)
@@ -365,6 +369,11 @@ private:
     Timer<InspectorController> m_startProfiling;
     ProfilesMap m_profiles;
 #endif
+#if ENABLE(WORKERS)
+    typedef HashMap<long, RefPtr<InspectorWorkerResource> > WorkersMap;
+
+    WorkersMap m_workers;
+#endif
 };
 
 inline void InspectorController::didInsertDOMNode(Node* node)
diff --git a/WebCore/inspector/InspectorFrontend.cpp b/WebCore/inspector/InspectorFrontend.cpp
index b33ea6a..9a5560f 100755
--- a/WebCore/inspector/InspectorFrontend.cpp
+++ b/WebCore/inspector/InspectorFrontend.cpp
@@ -37,6 +37,7 @@
 #include "InjectedScript.h"
 #include "InjectedScriptHost.h"
 #include "InspectorController.h"
+#include "InspectorWorkerResource.h"
 #include "Node.h"
 #include "ScriptFunctionCall.h"
 #include "ScriptObject.h"
@@ -452,6 +453,26 @@ void InspectorFrontend::didGetEventListenersForNode(int callId, int nodeId, Scri
     function.call();
 }
 
+#if ENABLE(WORKERS)
+void InspectorFrontend::didCreateWorker(const InspectorWorkerResource& worker)
+{
+    ScriptFunctionCall function(m_webInspector, "dispatch");
+    function.appendArgument("didCreateWorker");
+    function.appendArgument(worker.id());
+    function.appendArgument(worker.url());
+    function.appendArgument(worker.isSharedWorker());
+    function.call();
+}
+
+void InspectorFrontend::willDestroyWorker(const InspectorWorkerResource& worker)
+{
+    ScriptFunctionCall function(m_webInspector, "dispatch"); 
+    function.appendArgument("willDestroyWorker");
+    function.appendArgument(worker.id());
+    function.call();
+}
+#endif // ENABLE(WORKERS)
+
 void InspectorFrontend::didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString)
 {
     ScriptFunctionCall function(m_webInspector, "dispatch"); 
diff --git a/WebCore/inspector/InspectorFrontend.h b/WebCore/inspector/InspectorFrontend.h
index fa09eba..9a993be 100644
--- a/WebCore/inspector/InspectorFrontend.h
+++ b/WebCore/inspector/InspectorFrontend.h
@@ -45,6 +45,7 @@ namespace WebCore {
     class ScriptString;
     class SerializedScriptValue;
     class Storage;
+    class InspectorWorkerResource;
 
     class InspectorFrontend : public Noncopyable {
     public:
@@ -126,6 +127,11 @@ namespace WebCore {
         void timelineProfilerWasStopped();
         void addRecordToTimeline(const ScriptObject&);
 
+#if ENABLE(WORKERS)
+        void didCreateWorker(const InspectorWorkerResource&);
+        void willDestroyWorker(const InspectorWorkerResource&);
+#endif // ENABLE(WORKER)
+
         void didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString);
         void didDispatchOnInjectedScript(int callId, SerializedScriptValue* result, bool isException);
 
diff --git a/WebCore/inspector/InspectorWorkerResource.h b/WebCore/inspector/InspectorWorkerResource.h
new file mode 100644
index 0000000..11d787e
--- /dev/null
+++ b/WebCore/inspector/InspectorWorkerResource.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorWorkerResource_h
+#define InspectorWorkerResource_h
+
+#if ENABLE(WORKERS) && ENABLE(INSPECTOR)
+
+#include "PlatformString.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class InspectorWorkerResource : public RefCounted<InspectorWorkerResource> {
+public:
+    static PassRefPtr<InspectorWorkerResource> create(long id, const String& url, bool isSharedWorker)
+    {
+        return adoptRef(new InspectorWorkerResource(id, url, isSharedWorker));
+    }
+
+    long id() const { return m_id; }
+    const String& url() const { return m_url; }
+    bool isSharedWorker() const { return m_isSharedWorker; }
+private:
+    InspectorWorkerResource(long id, const String& url, bool isSharedWorker)
+        : m_id(id)
+        , m_url(url)
+        , m_isSharedWorker(isSharedWorker)
+    {
+    }
+
+    int m_id;
+    String m_url;
+    bool m_isSharedWorker;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WORKERS) && ENABLE(INSPECTOR)
+
+#endif // InspectorWorkerResource_h
diff --git a/WebCore/inspector/front-end/Checkbox.js b/WebCore/inspector/front-end/Checkbox.js
new file mode 100644
index 0000000..3f86824
--- /dev/null
+++ b/WebCore/inspector/front-end/Checkbox.js
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 Google Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.Checkbox = function(label, callback, checked, className, tooltip)
+{
+    this.element = document.createElement('label');
+    this._inputElement = document.createElement('input');
+
+    function callbackWrapper(event)
+    {
+        if (callback)
+            callback(event);
+        event.stopPropagation();
+        return true;
+    }
+    this._inputElement.type = "checkbox";
+    this._inputElement.checked = checked;
+    this._inputElement.addEventListener("click", callbackWrapper, false);
+
+    this.element.className = className;
+    this.element.appendChild(this._inputElement);
+    this.element.appendChild(document.createTextNode(label));
+    this.element.title = tooltip;
+    this.element.addEventListener("click", callbackWrapper, false);
+}
+
+WebInspector.Checkbox.prototype = {
+    checked: function()
+    {
+        return this._inputElement.checked;
+    }
+}
diff --git a/WebCore/inspector/front-end/InjectedFakeWorker.js b/WebCore/inspector/front-end/InjectedFakeWorker.js
index ecaa64a..658fd77 100644
--- a/WebCore/inspector/front-end/InjectedFakeWorker.js
+++ b/WebCore/inspector/front-end/InjectedFakeWorker.js
@@ -28,7 +28,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-var InjectedFakeWorker = function()
+var InjectedFakeWorker = function(InjectedScriptHost, inspectedWindow, injectedScriptId)
 {
 
 Worker = function(url)
@@ -45,13 +45,13 @@ Worker = function(url)
 
 function FakeWorker(worker, url)
 {
-    var scriptURL = new URL(document.baseURI).completeWith(url);
-
-    if (!scriptURL.sameOrigin(location.href))
-        throw new DOMCoreException("SECURITY_ERR",18);
+    var scriptURL = this._expandURLAndCheckOrigin(document.baseURI, location.href, url);
 
     this._worker = worker;
     this._buildWorker(scriptURL);
+    this._id = InjectedScriptHost.nextWorkerId();
+
+    InjectedScriptHost.didCreateWorker(this._id, scriptURL.url, false);
 }
 
 FakeWorker.prototype = {
@@ -63,6 +63,8 @@ FakeWorker.prototype = {
 
     terminate: function()
     {
+        InjectedScriptHost.willDestroyWorker(this._id);
+
         if (this._frame != null) {
             this._frame.onmessage = this._worker.onmessage = noop;
             this._frame.frameElement.parentNode.removeChild(this._frame.frameElement);
@@ -96,7 +98,7 @@ FakeWorker.prototype = {
     _handleException: function(e)
     {
         // NB: it should be an ErrorEvent, but creating it from script is not
-        // currently supported, to emulate it on top of plain vanilla Event.
+        // currently supported, so emulate it on top of plain vanilla Event.
         var errorEvent = this._document.createEvent("Event");
         errorEvent.initEvent("Event", false, false);
         errorEvent.message = "Uncaught exception";
@@ -147,10 +149,13 @@ FakeWorker.prototype = {
         workerFrame.close = bind(this.terminate, this);
     },
 
-    _importScripts: function(evalTarget)
+    _importScripts: function(targetFrame)
     {
-        for (var i = 1; i < arguments.length; ++i)
-            evalTarget.eval(this._loadScript(arguments[i]));
+        for (var i = 1; i < arguments.length; ++i) {
+            var workerOrigin = targetFrame.__devtools.location.href;
+            var url = this._expandURLAndCheckOrigin(workerOrigin, workerOrigin, arguments[i]);
+            targetFrame.eval(this._loadScript(url.url) + "\n//@ sourceURL= " + url.url);
+        }
     },
 
     _loadScript: function(url)
@@ -165,6 +170,15 @@ FakeWorker.prototype = {
             text = ""; // We've got error message, not worker code.
         }
         return text;
+    },
+
+    _expandURLAndCheckOrigin: function(baseURL, origin, url)
+    {
+        var scriptURL = new URL(baseURL).completeWith(url);
+
+        if (!scriptURL.sameOrigin(origin))
+            throw new DOMCoreException("SECURITY_ERR",18);
+        return scriptURL;
     }
 };
 
diff --git a/WebCore/inspector/front-end/Script.js b/WebCore/inspector/front-end/Script.js
index 9be624a..79004f3 100644
--- a/WebCore/inspector/front-end/Script.js
+++ b/WebCore/inspector/front-end/Script.js
@@ -42,7 +42,7 @@ WebInspector.Script = function(sourceID, sourceURL, source, startingLine, errorL
         var match = pattern.exec(source);
 
         if (match)
-            this.sourceURL = WebInspector.UIString("(program): %s", match[1]);
+            this.sourceURL = match[1];
     }
 }
 
diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js
index c5e5276..f84d4cb 100644
--- a/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/WebCore/inspector/front-end/ScriptsPanel.js
@@ -135,6 +135,7 @@ WebInspector.ScriptsPanel = function()
     this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane();
     this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane();
     this.sidebarPanes.breakpoints = new WebInspector.BreakpointsSidebarPane();
+    this.sidebarPanes.workers = new WebInspector.WorkersSidebarPane();
 
     for (var pane in this.sidebarPanes)
         this.sidebarElement.appendChild(this.sidebarPanes[pane].element);
@@ -260,7 +261,7 @@ WebInspector.ScriptsPanel.prototype = {
         var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, errorLine, errorMessage);
         this._sourceIDMap[sourceID] = script;
 
-        var resource = WebInspector.resourceURLMap[sourceURL];
+        var resource = WebInspector.resourceURLMap[script.sourceURL];
         if (resource) {
             if (resource.finished) {
                 // Resource is finished, bind the script right away.
@@ -423,7 +424,7 @@ WebInspector.ScriptsPanel.prototype = {
             return;
 
         this._debuggerEnabled = true;
-        this.reset();
+        this.reset(true);
     },
 
     debuggerWasDisabled: function()
@@ -432,10 +433,10 @@ WebInspector.ScriptsPanel.prototype = {
             return;
 
         this._debuggerEnabled = false;
-        this.reset();
+        this.reset(true);
     },
 
-    reset: function()
+    reset: function(preserveWorkers)
     {
         this.visibleView = null;
 
@@ -471,6 +472,8 @@ WebInspector.ScriptsPanel.prototype = {
         
         this.sidebarPanes.watchExpressions.refreshExpressions();
         this.sidebarPanes.breakpoints.reset();
+        if (!preserveWorkers)
+            this.sidebarPanes.workers.reset();
     },
 
     get visibleView()
diff --git a/WebCore/inspector/front-end/WebKit.qrc b/WebCore/inspector/front-end/WebKit.qrc
index ff21c15..ac4c306 100644
--- a/WebCore/inspector/front-end/WebKit.qrc
+++ b/WebCore/inspector/front-end/WebKit.qrc
@@ -13,6 +13,7 @@
     <file>Callback.js</file>
     <file>CallStackSidebarPane.js</file>
     <file>ChangesView.js</file>
+    <file>Checkbox.js</file>
     <file>Color.js</file>
     <file>ConsolePanel.js</file>
     <file>ConsoleView.js</file>
@@ -89,6 +90,7 @@
     <file>View.js</file>
     <file>WatchExpressionsSidebarPane.js</file>
     <file>WelcomeView.js</file>
+    <file>WorkersSidebarPane.js</file>
     <file>audits.css</file>
     <file>inspector.css</file>
     <file>inspectorSyntaxHighlight.css</file>
diff --git a/WebCore/inspector/front-end/WorkersSidebarPane.js b/WebCore/inspector/front-end/WorkersSidebarPane.js
new file mode 100644
index 0000000..cfb70b7
--- /dev/null
+++ b/WebCore/inspector/front-end/WorkersSidebarPane.js
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.WorkersSidebarPane = function()
+{
+    WebInspector.SidebarPane.call(this, WebInspector.UIString("Workers"));
+    
+    this._workers = {};
+
+    this._enableWorkersCheckbox = new WebInspector.Checkbox(
+        WebInspector.UIString("Debug"),
+        this._onTriggerInstrument.bind(this),
+        false,
+        "sidebar-pane-subtitle",
+        WebInspector.UIString("Allow debugging workers. Enabling this option will replace native workers with the iframe-based JavaScript implementation"));
+
+    this.titleElement.insertBefore(this._enableWorkersCheckbox.element, this.titleElement.firstChild);
+
+    this._listElement = document.createElement("ol");
+    this._listElement.className = "workers-list";
+
+    this.bodyElement.appendChild(this._listElement);
+    this._treeOutline = new TreeOutline(this._listElement);
+}
+
+WebInspector.WorkersSidebarPane.prototype = {
+    addWorker: function(id, url, isShared)
+    {
+        if (id in this._workers) 
+            return;
+        var worker = new WebInspector.Worker(id, url, isShared);
+        this._workers[id] = worker;
+
+        var title = WebInspector.linkifyURL(url, WebInspector.displayNameForURL(url), "worker-item", true, url);
+        var treeElement = new TreeElement(title, worker, false);
+        this._treeOutline.appendChild(treeElement);
+    },
+
+    removeWorker: function(id)
+    {
+        if (id in this._workers) {
+            this._treeOutline.removeChild(this._treeOutline.findTreeElement(this._workers[id]));
+            delete this._workers[id];
+        }
+    },
+
+    setInstrumentation: function(enabled)
+    {
+        InspectorBackend.removeAllScriptsToEvaluateOnLoad();
+        if (enabled)
+            InspectorBackend.addScriptToEvaluateOnLoad("(" + InjectedFakeWorker + ")");
+    },
+
+    reset: function()
+    {
+        InspectorBackend.removeAllScriptsToEvaluateOnLoad();
+        this.setInstrumentation(this._enableWorkersCheckbox.checked());
+        this._treeOutline.removeChildren();
+        this._workers = {};
+    },
+
+    _onTriggerInstrument: function(event)
+    {
+        this.setInstrumentation(this._enableWorkersCheckbox.checked());
+    }
+};
+
+WebInspector.WorkersSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
+
+WebInspector.Worker = function(id, url, shared)
+{
+    this.id = id;
+    this.url = url;
+    this.shared = shared;
+}
+
+WebInspector.didCreateWorker = function()
+{
+    var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
+    workersPane.addWorker.apply(workersPane, arguments);
+}
+
+WebInspector.willDestroyWorker = function()
+{
+    var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
+    workersPane.removeWorker.apply(workersPane, arguments);
+}
diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css
index 4630898..d169279 100644
--- a/WebCore/inspector/front-end/inspector.css
+++ b/WebCore/inspector/front-end/inspector.css
@@ -1721,6 +1721,18 @@ li.editing .swatch, li.editing .enabled-button,  li.editing-sub-part .delete-but
     height: 5px;
 }
 
+.sidebar-pane-subtitle {
+    float: right;
+    overflow: hidden;
+}
+
+.sidebar-pane-subtitle input {
+    width: 10px;
+    margin-left: 0;
+    margin-top: 0;
+    margin-bottom: 0;
+}
+
 .metrics {
     padding: 8px;
     font-size: 10px;
@@ -3870,4 +3882,28 @@ ol.breakpoint-list {
 .timeline-details-title {
     font-weight: bold;
     white-space: nowrap;
-}
\ No newline at end of file
+}
+
+.workers-list {
+    list-style: none;
+    margin: 0;
+    padding: 0;
+}
+
+.workers-list > li {
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    margin-left: 1em;
+    font-size: 12px;
+}
+
+a.worker-item {
+    color: rgb(33%, 33%, 33%);
+    cursor: pointer;
+    text-decoration: none;
+}
+
+a.worker-item:hover {
+    color: rgb(15%, 15%, 15%);
+}
diff --git a/WebCore/inspector/front-end/inspector.html b/WebCore/inspector/front-end/inspector.html
index e5295f2..4fa8ddc 100644
--- a/WebCore/inspector/front-end/inspector.html
+++ b/WebCore/inspector/front-end/inspector.html
@@ -41,6 +41,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="InspectorFrontendHostStub.js"></script>
     <script type="text/javascript" src="Object.js"></script>
     <script type="text/javascript" src="Settings.js"></script>
+    <script type="text/javascript" src="Checkbox.js"></script>
     <script type="text/javascript" src="ContextMenu.js"></script>
     <script type="text/javascript" src="KeyboardShortcut.js"></script>
     <script type="text/javascript" src="TextPrompt.js"></script>
@@ -74,6 +75,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="CallStackSidebarPane.js"></script>
     <script type="text/javascript" src="ScopeChainSidebarPane.js"></script>
     <script type="text/javascript" src="WatchExpressionsSidebarPane.js"></script>
+    <script type="text/javascript" src="WorkersSidebarPane.js"></script>
     <script type="text/javascript" src="MetricsSidebarPane.js"></script>
     <script type="text/javascript" src="PropertiesSidebarPane.js"></script>
     <script type="text/javascript" src="EventListenersSidebarPane.js"></script>
diff --git a/WebCore/workers/AbstractWorker.cpp b/WebCore/workers/AbstractWorker.cpp
index 6ba8922..b9d1b78 100644
--- a/WebCore/workers/AbstractWorker.cpp
+++ b/WebCore/workers/AbstractWorker.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -38,18 +38,37 @@
 #include "Event.h"
 #include "EventException.h"
 #include "EventNames.h"
+#include "InspectorController.h"
 #include "ScriptExecutionContext.h"
 #include "SecurityOrigin.h"
 
 namespace WebCore {
 
+long AbstractWorker::s_lastId;
+
 AbstractWorker::AbstractWorker(ScriptExecutionContext* context)
     : ActiveDOMObject(context, this)
+    , m_id(++s_lastId)
 {
 }
 
 AbstractWorker::~AbstractWorker()
 {
+    onDestroyWorker();
+}
+
+void AbstractWorker::onDestroyWorker()
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspector = scriptExecutionContext() ? scriptExecutionContext()->inspectorController() : 0)
+        inspector->willDestroyWorker(id());
+#endif
+}
+
+void AbstractWorker::contextDestroyed()
+{
+    onDestroyWorker();
+    ActiveDOMObject::contextDestroyed(); 
 }
 
 KURL AbstractWorker::resolveURL(const String& url, ExceptionCode& ec)
diff --git a/WebCore/workers/AbstractWorker.h b/WebCore/workers/AbstractWorker.h
index 2209856..66b9c15 100644
--- a/WebCore/workers/AbstractWorker.h
+++ b/WebCore/workers/AbstractWorker.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -57,6 +57,8 @@ namespace WebCore {
         using RefCounted<AbstractWorker>::ref;
         using RefCounted<AbstractWorker>::deref;
 
+        long id() const { return m_id; }
+        virtual void contextDestroyed();
         AbstractWorker(ScriptExecutionContext*);
         virtual ~AbstractWorker();
 
@@ -69,8 +71,12 @@ namespace WebCore {
         virtual void derefEventTarget() { deref(); }
         virtual EventTargetData* eventTargetData();
         virtual EventTargetData* ensureEventTargetData();
+        void onDestroyWorker();
         
         EventTargetData m_eventTargetData;
+        long m_id;
+
+        static long s_lastId;
     };
 
 } // namespace WebCore
diff --git a/WebCore/workers/SharedWorker.cpp b/WebCore/workers/SharedWorker.cpp
index 71fcc68..d9b7d11 100644
--- a/WebCore/workers/SharedWorker.cpp
+++ b/WebCore/workers/SharedWorker.cpp
@@ -34,6 +34,7 @@
 
 #include "SharedWorker.h"
 
+#include "InspectorController.h"
 #include "KURL.h"
 #include "MessageChannel.h"
 #include "MessagePort.h"
@@ -53,6 +54,10 @@ SharedWorker::SharedWorker(const String& url, const String& name, ScriptExecutio
     if (ec)
         return;
     SharedWorkerRepository::connect(this, remotePort.release(), scriptUrl, name, ec);
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
+        inspector->didCreateWorker(id(), scriptUrl.string(), true);
+#endif
 }
 
 SharedWorker::~SharedWorker()
diff --git a/WebCore/workers/Worker.cpp b/WebCore/workers/Worker.cpp
index 864b7c6..4ef94ba 100644
--- a/WebCore/workers/Worker.cpp
+++ b/WebCore/workers/Worker.cpp
@@ -40,6 +40,7 @@
 #include "ExceptionCode.h"
 #include "Frame.h"
 #include "FrameLoader.h"
+#include "InspectorController.h"
 #include "MessageEvent.h"
 #include "TextEncoding.h"
 #include "WorkerContextProxy.h"
@@ -60,6 +61,10 @@ Worker::Worker(const String& url, ScriptExecutionContext* context, ExceptionCode
     m_scriptLoader = new WorkerScriptLoader();
     m_scriptLoader->loadAsynchronously(scriptExecutionContext(), scriptURL, DenyCrossOriginRequests, this);
     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.
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
+        inspector->didCreateWorker(id(), scriptURL.string(), false);
+#endif
 }
 
 Worker::~Worker()
diff --git a/WebKit/chromium/src/js/InspectorControllerImpl.js b/WebKit/chromium/src/js/InspectorControllerImpl.js
index 7fbfb64..03259b4 100644
--- a/WebKit/chromium/src/js/InspectorControllerImpl.js
+++ b/WebKit/chromium/src/js/InspectorControllerImpl.js
@@ -38,6 +38,7 @@ if (!this.devtools)
 devtools.InspectorBackendImpl = function()
 {
     WebInspector.InspectorBackendStub.call(this);
+    this.installInspectorControllerDelegate_("addScriptToEvaluateOnLoad");
     this.installInspectorControllerDelegate_("clearMessages");
     this.installInspectorControllerDelegate_("copyNode");
     this.installInspectorControllerDelegate_("deleteCookie");
@@ -55,6 +56,7 @@ devtools.InspectorBackendImpl = function()
     this.installInspectorControllerDelegate_("highlightDOMNode");
     this.installInspectorControllerDelegate_("hideDOMNodeHighlight");
     this.installInspectorControllerDelegate_("releaseWrapperObjectGroup");
+    this.installInspectorControllerDelegate_("removeAllScriptsToEvaluateOnLoad");
     this.installInspectorControllerDelegate_("reloadPage");
     this.installInspectorControllerDelegate_("removeAttribute");
     this.installInspectorControllerDelegate_("removeDOMStorageItem");

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list