[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:30:58 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 2476e859f5f8830204147010bca443ec482c48fc
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Mar 10 09:22:04 2010 +0000
2010-03-10 Andrey Kosyakov <caseq at 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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55771 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0a812be..d56ddf6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,94 @@
+2010-03-10 Andrey Kosyakov <caseq at 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):
+
2010-03-10 Roland Steiner <rolandsteiner at chromium.org>
Unreviewed build fix. Fix variable name change that somehow didn't
diff --git a/WebCore/English.lproj/localizedStrings.js b/WebCore/English.lproj/localizedStrings.js
index 6055896..97c70ce 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 d05f8d9..82f85c2 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1622,6 +1622,7 @@
'inspector/InspectorResource.h',
'inspector/InspectorTimelineAgent.cpp',
'inspector/InspectorTimelineAgent.h',
+ 'inspector/InspectorWorkerResource.h',
'inspector/JavaScriptCallFrame.cpp',
'inspector/JavaScriptCallFrame.h',
'inspector/ScriptBreakpoint.h',
@@ -3743,6 +3744,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',
@@ -3819,6 +3821,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 cff889e..d14a6a2 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -42761,6 +42761,10 @@
>
</File>
<File
+ RelativePath="..\inspector\InspectorWorkerResource.h"
+ >
+ </File>
+ <File
RelativePath="..\inspector\JavaScriptCallFrame.cpp"
>
</File>
@@ -42840,6 +42844,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\Checkbox.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\Color.js"
>
</File>
@@ -43147,6 +43155,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 79bfa97..f827483 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 b3ca3ae..e369ab5 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"
@@ -730,6 +731,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
m_frontend->populateInterface();
@@ -758,7 +764,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();
@@ -845,10 +853,12 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
if (ResourcesMap* resourceMap = m_frameResources.get(frame))
pruneResources(resourceMap, loader);
- for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin();
- it != m_scriptsToEvaluateOnLoad.end(); ++it) {
- ScriptSourceCode scriptSourceCode(*it);
- loader->frame()->script()->evaluate(scriptSourceCode);
+ if (m_scriptsToEvaluateOnLoad.size()) {
+ ScriptState* scriptState = mainWorldScriptState(loader->frame());
+ for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin();
+ it != m_scriptsToEvaluateOnLoad.end(); ++it) {
+ m_injectedScriptHost->injectScript(*it, scriptState);
+ }
}
}
@@ -1191,6 +1201,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 3cdc807..a6a2ada 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)
@@ -185,11 +186,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)
@@ -371,6 +375,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 f3b485f..781a095 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"
@@ -471,6 +472,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 121cd90..861a6f7 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:
@@ -131,6 +132,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..b30da70
--- /dev/null
+++ b/WebCore/inspector/front-end/Checkbox.js
@@ -0,0 +1,56 @@
+/*
+ * 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));
+ if (tooltip)
+ 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/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js
index e7f0e35..316f32e 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);
@@ -424,7 +425,7 @@ WebInspector.ScriptsPanel.prototype = {
return;
this._debuggerEnabled = true;
- this.reset();
+ this.reset(true);
},
debuggerWasDisabled: function()
@@ -433,10 +434,10 @@ WebInspector.ScriptsPanel.prototype = {
return;
this._debuggerEnabled = false;
- this.reset();
+ this.reset(true);
},
- reset: function()
+ reset: function(preserveWorkers)
{
this.visibleView = null;
@@ -472,6 +473,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/StylesSidebarPane.js b/WebCore/inspector/front-end/StylesSidebarPane.js
index 67c5a77..cabaa8e 100644
--- a/WebCore/inspector/front-end/StylesSidebarPane.js
+++ b/WebCore/inspector/front-end/StylesSidebarPane.js
@@ -404,26 +404,20 @@ WebInspector.StylePropertiesSection = function(styleRule, subtitle, computedStyl
if (WebInspector.settings.showInheritedComputedStyleProperties)
this.element.addStyleClass("show-inherited");
- var showInheritedLabel = document.createElement("label");
- var showInheritedInput = document.createElement("input");
- showInheritedInput.type = "checkbox";
- showInheritedInput.checked = WebInspector.settings.showInheritedComputedStyleProperties;
-
var computedStyleSection = this;
var showInheritedToggleFunction = function(event) {
- WebInspector.settings.showInheritedComputedStyleProperties = showInheritedInput.checked;
+ WebInspector.settings.showInheritedComputedStyleProperties = computedStyleSection._showInheritedCheckbox.checked();
if (WebInspector.settings.showInheritedComputedStyleProperties)
computedStyleSection.element.addStyleClass("show-inherited");
else
computedStyleSection.element.removeStyleClass("show-inherited");
- event.stopPropagation();
};
- showInheritedLabel.addEventListener("click", showInheritedToggleFunction, false);
+ this._showInheritedCheckbox = new WebInspector.Checkbox(WebInspector.UIString("Show inherited"),
+ showInheritedToggleFunction,
+ WebInspector.settings.showInheritedComputedStyleProperties);
- showInheritedLabel.appendChild(showInheritedInput);
- showInheritedLabel.appendChild(document.createTextNode(WebInspector.UIString("Show inherited")));
- this.subtitleElement.appendChild(showInheritedLabel);
+ this.subtitleElement.appendChild(this._showInheritedCheckbox.element);
} else {
if (!subtitle) {
if (this.styleRule.parentStyleSheet && this.styleRule.parentStyleSheet.href) {
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 9beb10a..7b023a4 100644
--- a/WebCore/inspector/front-end/inspector.css
+++ b/WebCore/inspector/front-end/inspector.css
@@ -1329,15 +1329,6 @@ body.inactive .placard.selected {
display: inline;
}
-.section .header input[type=checkbox] {
- height: 10px;
- width: 10px;
- margin-left: 0;
- margin-top: 0;
- margin-bottom: 0;
- vertical-align: 2px;
-}
-
.section .header .subtitle, .event-bar .header .subtitle {
float: right;
font-size: 10px;
@@ -1722,6 +1713,21 @@ 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, .section .header input[type=checkbox] {
+ font-size: inherit;
+ hight: 1em;
+ width: 1em;
+ margin-left: 0;
+ margin-top: 0;
+ margin-bottom: 0.25em;
+ vertical-align: bottom;
+}
+
.metrics {
padding: 8px;
font-size: 10px;
@@ -3882,3 +3888,27 @@ ol.breakpoint-list {
white-space: nowrap;
}
+.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/ChangeLog b/WebKit/chromium/ChangeLog
index e672c6f..c5acd9a 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,14 @@
+2010-03-10 Andrey Kosyakov <caseq at 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
+
+ * src/js/InspectorControllerImpl.js:
+ (devtools.InspectorBackendImpl):
+
2010-03-10 Tony Chang <tony at chromium.org>
Reviewed by Darin Fisher.
diff --git a/WebKit/chromium/src/js/InspectorControllerImpl.js b/WebKit/chromium/src/js/InspectorControllerImpl.js
index d8de556..38325b6 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");
@@ -57,6 +58,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