Changeset 55522 in webkit
- Timestamp:
- Mar 4, 2010 6:00:40 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 27 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55520 r55522 1 2010-03-04 Andrey Kosyakov <caseq@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Added support for worker instrumentation in inspector 6 (display list of active workers, allow debugging of workers 7 by injecting fake JS implementation) 8 9 https://bugs.webkit.org/show_bug.cgi?id=35568 10 11 * English.lproj/localizedStrings.js: 12 * WebCore.gypi: 13 * WebCore.vcproj/WebCore.vcproj: 14 * bindings/js/JSInjectedScriptHostCustom.cpp: 15 (WebCore::InjectedScriptHost::createInjectedScript): 16 (WebCore::InjectedScriptHost::injectedScriptFor): 17 * bindings/v8/custom/V8InjectedScriptHostCustom.cpp: 18 (WebCore::InjectedScriptHost::createInjectedScript): 19 (WebCore::InjectedScriptHost::injectedScriptFor): 20 * dom/Document.cpp: 21 (WebCore::Document::inspectorController): 22 * dom/Document.h: 23 * dom/ScriptExecutionContext.h: 24 (WebCore::ScriptExecutionContext::inspectorController): 25 * inspector/InjectedScriptHost.cpp: 26 (WebCore::InjectedScriptHost::InjectedScriptHost): 27 (WebCore::InjectedScriptHost::injectScript): 28 (WebCore::InjectedScriptHost::nextWorkerId): 29 (WebCore::InjectedScriptHost::didCreateWorker): 30 (WebCore::InjectedScriptHost::willDestroyWorker): 31 * inspector/InjectedScriptHost.h: 32 * inspector/InjectedScriptHost.idl: 33 * inspector/InspectorController.cpp: 34 (WebCore::InspectorController::populateScriptObjects): 35 (WebCore::InspectorController::resetScriptObjects): 36 (WebCore::InspectorController::didCommitLoad): 37 (WebCore::InspectorController::didCreateWorker): 38 (WebCore::InspectorController::willDestroyWorker): 39 * inspector/InspectorController.h: 40 * inspector/InspectorFrontend.cpp: 41 (WebCore::InspectorFrontend::didCreateWorker): 42 (WebCore::InspectorFrontend::willDestroyWorker): 43 * inspector/InspectorFrontend.h: 44 * inspector/InspectorWorkerResource.h: Added. 45 (WebCore::InspectorWorkerResource::create): 46 (WebCore::InspectorWorkerResource::id): 47 (WebCore::InspectorWorkerResource::url): 48 (WebCore::InspectorWorkerResource::isSharedWorker): 49 (WebCore::InspectorWorkerResource::InspectorWorkerResource): 50 * inspector/front-end/Checkbox.js: Added. 51 (WebInspector.Checkbox.callbackWrapper): 52 (WebInspector.Checkbox): 53 (WebInspector.Checkbox.prototype.checked): 54 * inspector/front-end/InjectedFakeWorker.js: 55 (InjectedFakeWorker.FakeWorker): 56 (InjectedFakeWorker.FakeWorker.prototype.terminate): 57 (InjectedFakeWorker.FakeWorker.prototype._handleException): 58 (InjectedFakeWorker.FakeWorker.prototype._importScripts): 59 (InjectedFakeWorker.FakeWorker.prototype._loadScript): 60 (InjectedFakeWorker.FakeWorker.prototype._expandURLAndCheckOrigin): 61 * inspector/front-end/ScriptsPanel.js: 62 (WebInspector.ScriptsPanel): 63 (WebInspector.ScriptsPanel.prototype.debuggerWasEnabled): 64 (WebInspector.ScriptsPanel.prototype.debuggerWasDisabled): 65 (WebInspector.ScriptsPanel.prototype.reset): 66 * inspector/front-end/WebKit.qrc: 67 * inspector/front-end/WorkersSidebarPane.js: Added. 68 (WebInspector.WorkersSidebarPane): 69 (WebInspector.WorkersSidebarPane.prototype.addWorker): 70 (WebInspector.WorkersSidebarPane.prototype.removeWorker): 71 (WebInspector.WorkersSidebarPane.prototype.setInstrumentation): 72 (WebInspector.WorkersSidebarPane.prototype.reset): 73 (WebInspector.WorkersSidebarPane.prototype._onTriggerInstrument): 74 (WebInspector.Worker): 75 (WebInspector.didCreateWorker): 76 (WebInspector.willDestroyWorker): 77 * inspector/front-end/inspector.css: 78 * inspector/front-end/inspector.html: 79 * workers/AbstractWorker.cpp: 80 (WebCore::AbstractWorker::AbstractWorker): 81 (WebCore::AbstractWorker::~AbstractWorker): 82 (WebCore::AbstractWorker::onDestroyWorker): 83 (WebCore::AbstractWorker::contextDestroyed): 84 * workers/AbstractWorker.h: 85 (WebCore::AbstractWorker::id): 86 * workers/SharedWorker.cpp: 87 (WebCore::SharedWorker::SharedWorker): 88 * workers/Worker.cpp: 89 (WebCore::Worker::Worker): 90 1 91 2010-03-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 92 -
trunk/WebCore/WebCore.gypi
r55505 r55522 1615 1615 'inspector/InspectorTimelineAgent.cpp', 1616 1616 'inspector/InspectorTimelineAgent.h', 1617 'inspector/InspectorWorkerResource.h', 1617 1618 'inspector/JavaScriptCallFrame.cpp', 1618 1619 'inspector/JavaScriptCallFrame.h', … … 3732 3733 'inspector/front-end/CallStackSidebarPane.js', 3733 3734 'inspector/front-end/ChangesView.js', 3735 'inspector/front-end/Checkbox.js', 3734 3736 'inspector/front-end/Color.js', 3735 3737 'inspector/front-end/ConsolePanel.js', … … 3808 3810 'inspector/front-end/WatchExpressionsSidebarPane.js', 3809 3811 'inspector/front-end/WelcomeView.js', 3812 'inspector/front-end/WorkersSidebarPane.js', 3810 3813 'inspector/front-end/audits.css', 3811 3814 'inspector/front-end/inspector.css', -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r55505 r55522 42718 42718 </File> 42719 42719 <File 42720 RelativePath="..\inspector\InspectorWorkerResource.h" 42721 > 42722 </File> 42723 <File 42720 42724 RelativePath="..\inspector\JavaScriptCallFrame.cpp" 42721 42725 > … … 42797 42801 </File> 42798 42802 <File 42803 RelativePath="..\inspector\front-end\Checkbox.js" 42804 > 42805 </File> 42806 <File 42799 42807 RelativePath="..\inspector\front-end\Color.js" 42800 42808 > … … 43102 43110 <File 43103 43111 RelativePath="..\inspector\front-end\WelcomeView.js" 43112 > 43113 </File> 43114 <File 43115 RelativePath="..\inspector\front-end\WorkersSidebarPane.js" 43104 43116 > 43105 43117 </File> -
trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
r55071 r55522 2 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 4 * Copyright (C) 20 09Google Inc. All rights reserved.4 * Copyright (C) 2010 Google Inc. All rights reserved. 5 5 * 6 6 * Redistribution and use in source and binary forms, with or without … … 76 76 namespace WebCore { 77 77 78 static ScriptObject createInjectedScript(const String& source, InjectedScriptHost* injectedScriptHost, ScriptState* scriptState, long id)78 ScriptObject InjectedScriptHost::createInjectedScript(const String& source, ScriptState* scriptState, long id) 79 79 { 80 80 SourceCode sourceCode = makeSource(source); … … 92 92 93 93 MarkedArgumentBuffer args; 94 args.append(toJS(scriptState, globalObject, injectedScriptHost));94 args.append(toJS(scriptState, globalObject, this)); 95 95 args.append(globalThisValue); 96 96 args.append(jsNumber(scriptState, id)); … … 222 222 return InjectedScript(ScriptObject(scriptState, injectedScript)); 223 223 224 ASSERT(!m_injectedScriptSource.isEmpty()); 225 ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId); 226 globalObject->setInjectedScript(injectedScriptObject.jsObject()); 227 InjectedScript result(injectedScriptObject); 228 m_idToInjectedScript.set(m_nextInjectedScriptId, result); 229 m_nextInjectedScriptId++; 224 ASSERT(!m_injectedScriptSource.isEmpty()); 225 pair<long, ScriptObject> injectedScriptObject = injectScript(m_injectedScriptSource, scriptState); 226 globalObject->setInjectedScript(injectedScriptObject.second.jsObject()); 227 InjectedScript result(injectedScriptObject.second); 228 m_idToInjectedScript.set(injectedScriptObject.first, result); 230 229 return result; 231 230 } -
trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
r55071 r55522 80 80 } 81 81 82 static ScriptObject createInjectedScript(const String& scriptSource, InjectedScriptHost* injectedScriptHost, ScriptState* inspectedScriptState, long id)82 ScriptObject InjectedScriptHost::createInjectedScript(const String& scriptSource, ScriptState* inspectedScriptState, long id) 83 83 { 84 84 v8::HandleScope scope; … … 91 91 // wrapper in the current context. 92 92 // FIXME: make it possible to use generic bindings factory for InjectedScriptHost. 93 v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper( injectedScriptHost);93 v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(this); 94 94 if (scriptHostWrapper.IsEmpty()) 95 95 return ScriptObject(); … … 241 241 242 242 ASSERT(!m_injectedScriptSource.isEmpty()); 243 ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, inspectedScriptState, m_nextInjectedScriptId); 244 InjectedScript result(injectedScriptObject); 245 m_idToInjectedScript.set(m_nextInjectedScriptId, result); 246 ++m_nextInjectedScriptId; 247 global->SetHiddenValue(key, injectedScriptObject.v8Object()); 243 pair<long, ScriptObject> injectedScript = injectScript(m_injectedScriptSource, inspectedScriptState); 244 InjectedScript result(injectedScript.second); 245 m_idToInjectedScript.set(injectedScript.first, result); 246 global->SetHiddenValue(key, injectedScript.second.v8Object()); 248 247 return result; 249 248 } -
trunk/WebCore/dom/Document.cpp
r55485 r55522 4799 4799 return page() ? page()->inspectorTimelineAgent() : 0; 4800 4800 } 4801 4802 InspectorController* Document::inspectorController() const 4803 { 4804 return page() ? page()->inspectorController() : 0; 4805 } 4801 4806 #endif 4802 4807 -
trunk/WebCore/dom/Document.h
r55461 r55522 451 451 #if ENABLE(INSPECTOR) 452 452 InspectorTimelineAgent* inspectorTimelineAgent() const; // can be NULL 453 virtual InspectorController* inspectorController() const; // can be NULL 453 454 #endif 454 455 -
trunk/WebCore/dom/ScriptExecutionContext.h
r53595 r55522 50 50 class ScriptString; 51 51 class String; 52 #if ENABLE(INSPECTOR) 53 class InspectorController; 54 #endif 52 55 53 56 enum MessageDestination { … … 85 88 86 89 SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); } 90 #if ENABLE(INSPECTOR) 91 virtual InspectorController* inspectorController() const { return 0; } 92 #endif 87 93 88 94 virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0; -
trunk/WebCore/inspector/InjectedScriptHost.cpp
r55071 r55522 2 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 4 * Copyright (C) 20 09Google Inc. All rights reserved.4 * Copyright (C) 2010 Google Inc. All rights reserved. 5 5 * 6 6 * Redistribution and use in source and binary forms, with or without … … 71 71 : m_inspectorController(inspectorController) 72 72 , m_nextInjectedScriptId(1) 73 , m_lastWorkerId(1 << 31) // Distinguish ids of fake workers from real ones, to minimize the chances they overlap. 73 74 { 74 75 } … … 195 196 } 196 197 198 pair<long, ScriptObject> InjectedScriptHost::injectScript(const String& source, ScriptState* scriptState) 199 { 200 long id = m_nextInjectedScriptId++; 201 return std::make_pair(id, createInjectedScript(source, scriptState, id)); 202 } 203 204 #if ENABLE(WORKERS) 205 long InjectedScriptHost::nextWorkerId() 206 { 207 return ++m_lastWorkerId; 208 } 209 210 void InjectedScriptHost::didCreateWorker(long id, const String& url, bool isSharedWorker) 211 { 212 if (m_inspectorController) 213 m_inspectorController->didCreateWorker(id, url, isSharedWorker); 214 } 215 216 void InjectedScriptHost::willDestroyWorker(long id) 217 { 218 if (m_inspectorController) 219 m_inspectorController->willDestroyWorker(id); 220 } 221 #endif // ENABLE(WORKERS) 222 197 223 } // namespace WebCore 198 224 -
trunk/WebCore/inspector/InjectedScriptHost.h
r55071 r55522 81 81 void selectDOMStorage(Storage* storage); 82 82 #endif 83 #if ENABLE(WORKERS) 84 long nextWorkerId(); 85 void didCreateWorker(long id, const String& url, bool isSharedWorker); 86 void willDestroyWorker(long id); 87 #endif 83 88 void reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException); 84 89 90 pair<long, ScriptObject> injectScript(const String& source, ScriptState*); 85 91 InjectedScript injectedScriptFor(ScriptState*); 86 92 InjectedScript injectedScriptForId(long); … … 92 98 InspectorDOMAgent* inspectorDOMAgent(); 93 99 InspectorFrontend* inspectorFrontend(); 100 ScriptObject createInjectedScript(const String& source, ScriptState* scriptState, long id); 94 101 95 102 InspectorController* m_inspectorController; 96 103 String m_injectedScriptSource; 97 104 long m_nextInjectedScriptId; 105 long m_lastWorkerId; 98 106 typedef HashMap<long, InjectedScript> IdToInjectedScriptMap; 99 107 IdToInjectedScriptMap m_idToInjectedScript; -
trunk/WebCore/inspector/InjectedScriptHost.idl
r55071 r55522 2 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 4 * Copyright (C) 20 09Google Inc. All rights reserved.4 * Copyright (C) 2010 Google Inc. All rights reserved. 5 5 * 6 6 * Redistribution and use in source and binary forms, with or without … … 56 56 #endif 57 57 58 #if defined(ENABLE_WORKERS) && ENABLE_WORKERS 59 void didCreateWorker(in long id, in DOMString url, in boolean isFakeWorker); 60 void willDestroyWorker(in long id); 61 long nextWorkerId(); 62 #endif 58 63 [Custom] void reportDidDispatchOnInjectedScript(in long callId, in DOMObject result, in boolean isException); 59 64 }; -
trunk/WebCore/inspector/InspectorController.cpp
r55464 r55522 64 64 #include "InspectorFrontendHost.h" 65 65 #include "InspectorResource.h" 66 #include "InspectorWorkerResource.h" 66 67 #include "InspectorTimelineAgent.h" 67 68 #include "Page.h" … … 690 691 it->second->bind(m_frontend.get()); 691 692 #endif 692 693 #if ENABLE(WORKERS) 694 WorkersMap::iterator workersEnd = m_workers.end(); 695 for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it) 696 m_frontend->didCreateWorker(*it->second); 697 #endif 693 698 if (m_profilerEnabled) 694 699 m_frontend->profilerWasEnabled(); … … 721 726 it->second->unbind(); 722 727 #endif 723 728 #if ENABLE(WORKERS) 729 m_workers.clear(); 730 #endif 724 731 if (m_timelineAgent) 725 732 m_timelineAgent->reset(); … … 808 815 pruneResources(resourceMap, loader); 809 816 817 ScriptState* scriptState = mainWorldScriptState(loader->frame()); 810 818 for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin(); 811 819 it != m_scriptsToEvaluateOnLoad.end(); ++it) { 812 ScriptSourceCode scriptSourceCode(*it); 813 loader->frame()->script()->evaluate(scriptSourceCode); 820 m_injectedScriptHost->injectScript(*it, scriptState); 814 821 } 815 822 } … … 1153 1160 m_frontend->timelineProfilerWasStopped(); 1154 1161 } 1162 1163 #if ENABLE(WORKERS) 1164 void InspectorController::didCreateWorker(long id, const String& url, bool isSharedWorker) 1165 { 1166 if (!enabled()) 1167 return; 1168 1169 RefPtr<InspectorWorkerResource> workerResource(InspectorWorkerResource::create(id, url, isSharedWorker)); 1170 m_workers.set(id, workerResource); 1171 if (m_frontend) 1172 m_frontend->didCreateWorker(*workerResource); 1173 } 1174 1175 void InspectorController::willDestroyWorker(long id) 1176 { 1177 if (!enabled()) 1178 return; 1179 1180 WorkersMap::iterator workerResource = m_workers.find(id); 1181 if (workerResource == m_workers.end()) 1182 return; 1183 if (m_frontend) 1184 m_frontend->willDestroyWorker(*workerResource->second); 1185 m_workers.remove(workerResource); 1186 } 1187 #endif // ENABLE(WORKERS) 1155 1188 1156 1189 #if ENABLE(DATABASE) -
trunk/WebCore/inspector/InspectorController.h
r55227 r55522 86 86 class InspectorDOMStorageResource; 87 87 class InspectorResource; 88 class InspectorWorkerResource; 88 89 89 90 class InspectorController … … 187 188 void mainResourceFiredLoadEvent(DocumentLoader*, const KURL&); 188 189 void mainResourceFiredDOMContentEvent(DocumentLoader*, const KURL&); 189 190 190 191 void didInsertDOMNode(Node*); 191 192 void didRemoveDOMNode(Node*); 192 193 void didModifyDOMAttr(Element*); 193 194 #if ENABLE(WORKERS) 195 void didCreateWorker(long id, const String& url, bool isSharedWorker); 196 void willDestroyWorker(long id); 197 #endif 194 198 void getCookies(long callId); 195 199 … … 366 370 ProfilesMap m_profiles; 367 371 #endif 372 #if ENABLE(WORKERS) 373 typedef HashMap<long, RefPtr<InspectorWorkerResource> > WorkersMap; 374 375 WorkersMap m_workers; 376 #endif 368 377 }; 369 378 -
trunk/WebCore/inspector/InspectorFrontend.cpp
r55071 r55522 38 38 #include "InjectedScriptHost.h" 39 39 #include "InspectorController.h" 40 #include "InspectorWorkerResource.h" 40 41 #include "Node.h" 41 42 #include "ScriptFunctionCall.h" … … 453 454 } 454 455 456 #if ENABLE(WORKERS) 457 void InspectorFrontend::didCreateWorker(const InspectorWorkerResource& worker) 458 { 459 ScriptFunctionCall function(m_webInspector, "dispatch"); 460 function.appendArgument("didCreateWorker"); 461 function.appendArgument(worker.id()); 462 function.appendArgument(worker.url()); 463 function.appendArgument(worker.isSharedWorker()); 464 function.call(); 465 } 466 467 void InspectorFrontend::willDestroyWorker(const InspectorWorkerResource& worker) 468 { 469 ScriptFunctionCall function(m_webInspector, "dispatch"); 470 function.appendArgument("willDestroyWorker"); 471 function.appendArgument(worker.id()); 472 function.call(); 473 } 474 #endif // ENABLE(WORKERS) 475 455 476 void InspectorFrontend::didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString) 456 477 { -
trunk/WebCore/inspector/InspectorFrontend.h
r55071 r55522 46 46 class SerializedScriptValue; 47 47 class Storage; 48 class InspectorWorkerResource; 48 49 49 50 class InspectorFrontend : public Noncopyable { … … 127 128 void addRecordToTimeline(const ScriptObject&); 128 129 130 #if ENABLE(WORKERS) 131 void didCreateWorker(const InspectorWorkerResource&); 132 void willDestroyWorker(const InspectorWorkerResource&); 133 #endif // ENABLE(WORKER) 134 129 135 void didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString); 130 136 void didDispatchOnInjectedScript(int callId, SerializedScriptValue* result, bool isException); -
trunk/WebCore/inspector/InspectorWorkerResource.h
r55521 r55522 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 */ 30 30 31 #include "config.h" 31 #ifndef InspectorWorkerResource_h 32 #define InspectorWorkerResource_h 32 33 33 #if ENABLE( SHARED_WORKERS)34 #if ENABLE(WORKERS) && ENABLE(INSPECTOR) 34 35 35 #include "SharedWorker.h" 36 37 #include "KURL.h" 38 #include "MessageChannel.h" 39 #include "MessagePort.h" 40 #include "SharedWorkerRepository.h" 36 #include "PlatformString.h" 37 #include <wtf/PassRefPtr.h> 38 #include <wtf/RefCounted.h> 39 #include <wtf/RefPtr.h> 41 40 42 41 namespace WebCore { 43 42 44 SharedWorker::SharedWorker(const String& url, const String& name, ScriptExecutionContext* context, ExceptionCode& ec) 45 : AbstractWorker(context) 46 { 47 RefPtr<MessageChannel> channel = MessageChannel::create(scriptExecutionContext()); 48 m_port = channel->port1(); 49 OwnPtr<MessagePortChannel> remotePort = channel->port2()->disentangle(ec); 50 ASSERT(!ec); 43 class InspectorWorkerResource : public RefCounted<InspectorWorkerResource> { 44 public: 45 static PassRefPtr<InspectorWorkerResource> create(long id, const String& url, bool isSharedWorker) 46 { 47 return adoptRef(new InspectorWorkerResource(id, url, isSharedWorker)); 48 } 51 49 52 KURL scriptUrl = resolveURL(url, ec); 53 if (ec) 54 return; 55 SharedWorkerRepository::connect(this, remotePort.release(), scriptUrl, name, ec); 56 } 50 long id() const { return m_id; } 51 const String& url() const { return m_url; } 52 bool isSharedWorker() const { return m_isSharedWorker; } 53 private: 54 InspectorWorkerResource(long id, const String& url, bool isSharedWorker) 55 : m_id(id) 56 , m_url(url) 57 , m_isSharedWorker(isSharedWorker) 58 { 59 } 57 60 58 SharedWorker::~SharedWorker() 59 { 60 } 61 int m_id; 62 String m_url; 63 bool m_isSharedWorker; 64 }; 61 65 62 66 } // namespace WebCore 63 67 64 #endif // ENABLE(SHARED_WORKERS) 68 #endif // ENABLE(WORKERS) && ENABLE(INSPECTOR) 69 70 #endif // InspectorWorkerResource_h -
trunk/WebCore/inspector/front-end/Checkbox.js
r55521 r55522 1 1 /* 2 * Copyright (C) 20 08 Apple Inc. All Rights Reserved.2 * Copyright (C) 2010 Google Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 WebInspector. Script = function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage)26 WebInspector.Checkbox = function(label, callback, checked, className, tooltip) 27 27 { 28 this.sourceID = sourceID; 29 this.sourceURL = sourceURL; 30 this.source = source; 31 this.startingLine = startingLine; 32 this.errorLine = errorLine; 33 this.errorMessage = errorMessage; 28 this.element = document.createElement('label'); 29 this._inputElement = document.createElement('input'); 34 30 35 // if no URL, look for "//@ sourceURL=" decorator 36 // note that this sourceURL comment decorator is behavior that FireBug added 37 // in it's 1.1 release as noted in the release notes: 38 // http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt 39 if (!sourceURL) { 40 // use of [ \t] rather than \s is to prevent \n from matching 41 var pattern = /^\s*\/\/[ \t]*@[ \t]*sourceURL[ \t]*=[ \t]*(\S+).*$/m; 42 var match = pattern.exec(source); 31 function callbackWrapper(event) 32 { 33 if (callback) 34 callback(event); 35 event.stopPropagation(); 36 return true; 37 } 38 this._inputElement.type = "checkbox"; 39 this._inputElement.checked = checked; 40 this._inputElement.addEventListener("click", callbackWrapper, false); 43 41 44 if (match) 45 this.sourceURL = WebInspector.UIString("(program): %s", match[1]); 42 this.element.className = className; 43 this.element.appendChild(this._inputElement); 44 this.element.appendChild(document.createTextNode(label)); 45 this.element.title = tooltip; 46 this.element.addEventListener("click", callbackWrapper, false); 47 } 48 49 WebInspector.Checkbox.prototype = { 50 checked: function() 51 { 52 return this._inputElement.checked; 46 53 } 47 54 } 48 49 WebInspector.Script.prototype = {50 get linesCount()51 {52 if (!this.source)53 return 0;54 this._linesCount = 0;55 var lastIndex = this.source.indexOf("\n");56 while (lastIndex !== -1) {57 lastIndex = this.source.indexOf("\n", lastIndex + 1)58 this._linesCount++;59 }60 }61 } -
trunk/WebCore/inspector/front-end/InjectedFakeWorker.js
r55227 r55522 29 29 */ 30 30 31 var InjectedFakeWorker = function( )31 var InjectedFakeWorker = function(InjectedScriptHost, inspectedWindow, injectedScriptId) 32 32 { 33 33 … … 46 46 function FakeWorker(worker, url) 47 47 { 48 var scriptURL = new URL(document.baseURI).completeWith(url); 49 50 if (!scriptURL.sameOrigin(location.href)) 51 throw new DOMCoreException("SECURITY_ERR",18); 48 var scriptURL = this._expandURLAndCheckOrigin(document.baseURI, location.href, url); 52 49 53 50 this._worker = worker; 54 51 this._buildWorker(scriptURL); 52 this._id = InjectedScriptHost.nextWorkerId(); 53 54 InjectedScriptHost.didCreateWorker(this._id, scriptURL.url, false); 55 55 } 56 56 … … 64 64 terminate: function() 65 65 { 66 InjectedScriptHost.willDestroyWorker(this._id); 67 66 68 if (this._frame != null) { 67 69 this._frame.onmessage = this._worker.onmessage = noop; … … 97 99 { 98 100 // NB: it should be an ErrorEvent, but creating it from script is not 99 // currently supported, to emulate it on top of plain vanilla Event.101 // currently supported, so emulate it on top of plain vanilla Event. 100 102 var errorEvent = this._document.createEvent("Event"); 101 103 errorEvent.initEvent("Event", false, false); … … 148 150 }, 149 151 150 _importScripts: function(evalTarget) 151 { 152 for (var i = 1; i < arguments.length; ++i) 153 evalTarget.eval(this._loadScript(arguments[i])); 152 _importScripts: function(targetFrame) 153 { 154 for (var i = 1; i < arguments.length; ++i) { 155 var workerOrigin = targetFrame.__devtools.location.href; 156 var url = this._expandURLAndCheckOrigin(workerOrigin, workerOrigin, arguments[i]); 157 targetFrame.eval(this._loadScript(url.url) + "\n//@ sourceURL= " + url.url); 158 } 154 159 }, 155 160 … … 166 171 } 167 172 return text; 173 }, 174 175 _expandURLAndCheckOrigin: function(baseURL, origin, url) 176 { 177 var scriptURL = new URL(baseURL).completeWith(url); 178 179 if (!scriptURL.sameOrigin(origin)) 180 throw new DOMCoreException("SECURITY_ERR",18); 181 return scriptURL; 168 182 } 169 183 }; -
trunk/WebCore/inspector/front-end/Script.js
r55241 r55522 43 43 44 44 if (match) 45 this.sourceURL = WebInspector.UIString("(program): %s", match[1]);45 this.sourceURL = match[1]; 46 46 } 47 47 } -
trunk/WebCore/inspector/front-end/ScriptsPanel.js
r55464 r55522 136 136 this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane(); 137 137 this.sidebarPanes.breakpoints = new WebInspector.BreakpointsSidebarPane(); 138 this.sidebarPanes.workers = new WebInspector.WorkersSidebarPane(); 138 139 139 140 for (var pane in this.sidebarPanes) … … 261 262 this._sourceIDMap[sourceID] = script; 262 263 263 var resource = WebInspector.resourceURLMap[s ourceURL];264 var resource = WebInspector.resourceURLMap[script.sourceURL]; 264 265 if (resource) { 265 266 if (resource.finished) { … … 424 425 425 426 this._debuggerEnabled = true; 426 this.reset( );427 this.reset(true); 427 428 }, 428 429 … … 433 434 434 435 this._debuggerEnabled = false; 435 this.reset( );436 }, 437 438 reset: function( )436 this.reset(true); 437 }, 438 439 reset: function(preserveWorkers) 439 440 { 440 441 this.visibleView = null; … … 472 473 this.sidebarPanes.watchExpressions.refreshExpressions(); 473 474 this.sidebarPanes.breakpoints.reset(); 475 if (!preserveWorkers) 476 this.sidebarPanes.workers.reset(); 474 477 }, 475 478 -
trunk/WebCore/inspector/front-end/WebKit.qrc
r55422 r55522 14 14 <file>CallStackSidebarPane.js</file> 15 15 <file>ChangesView.js</file> 16 <file>Checkbox.js</file> 16 17 <file>Color.js</file> 17 18 <file>ConsolePanel.js</file> … … 90 91 <file>WatchExpressionsSidebarPane.js</file> 91 92 <file>WelcomeView.js</file> 93 <file>WorkersSidebarPane.js</file> 92 94 <file>audits.css</file> 93 95 <file>inspector.css</file> -
trunk/WebCore/inspector/front-end/inspector.css
r55466 r55522 1722 1722 } 1723 1723 1724 .sidebar-pane-subtitle { 1725 float: right; 1726 overflow: hidden; 1727 } 1728 1729 .sidebar-pane-subtitle input { 1730 width: 10px; 1731 margin-left: 0; 1732 margin-top: 0; 1733 margin-bottom: 0; 1734 } 1735 1724 1736 .metrics { 1725 1737 padding: 8px; … … 3872 3884 white-space: nowrap; 3873 3885 } 3886 3887 .workers-list { 3888 list-style: none; 3889 margin: 0; 3890 padding: 0; 3891 } 3892 3893 .workers-list > li { 3894 overflow: hidden; 3895 text-overflow: ellipsis; 3896 white-space: nowrap; 3897 margin-left: 1em; 3898 font-size: 12px; 3899 } 3900 3901 a.worker-item { 3902 color: rgb(33%, 33%, 33%); 3903 cursor: pointer; 3904 text-decoration: none; 3905 } 3906 3907 a.worker-item:hover { 3908 color: rgb(15%, 15%, 15%); 3909 } -
trunk/WebCore/inspector/front-end/inspector.html
r55227 r55522 42 42 <script type="text/javascript" src="Object.js"></script> 43 43 <script type="text/javascript" src="Settings.js"></script> 44 <script type="text/javascript" src="Checkbox.js"></script> 44 45 <script type="text/javascript" src="ContextMenu.js"></script> 45 46 <script type="text/javascript" src="KeyboardShortcut.js"></script> … … 75 76 <script type="text/javascript" src="ScopeChainSidebarPane.js"></script> 76 77 <script type="text/javascript" src="WatchExpressionsSidebarPane.js"></script> 78 <script type="text/javascript" src="WorkersSidebarPane.js"></script> 77 79 <script type="text/javascript" src="MetricsSidebarPane.js"></script> 78 80 <script type="text/javascript" src="PropertiesSidebarPane.js"></script> -
trunk/WebCore/workers/AbstractWorker.cpp
r48701 r55522 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 39 39 #include "EventException.h" 40 40 #include "EventNames.h" 41 #include "InspectorController.h" 41 42 #include "ScriptExecutionContext.h" 42 43 #include "SecurityOrigin.h" … … 44 45 namespace WebCore { 45 46 47 long AbstractWorker::s_lastId; 48 46 49 AbstractWorker::AbstractWorker(ScriptExecutionContext* context) 47 50 : ActiveDOMObject(context, this) 51 , m_id(++s_lastId) 48 52 { 49 53 } … … 51 55 AbstractWorker::~AbstractWorker() 52 56 { 57 onDestroyWorker(); 58 } 59 60 void AbstractWorker::onDestroyWorker() 61 { 62 #if ENABLE(INSPECTOR) 63 if (InspectorController* inspector = scriptExecutionContext() ? scriptExecutionContext()->inspectorController() : 0) 64 inspector->willDestroyWorker(id()); 65 #endif 66 } 67 68 void AbstractWorker::contextDestroyed() 69 { 70 onDestroyWorker(); 71 ActiveDOMObject::contextDestroyed(); 53 72 } 54 73 -
trunk/WebCore/workers/AbstractWorker.h
r48701 r55522 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 58 58 using RefCounted<AbstractWorker>::deref; 59 59 60 long id() const { return m_id; } 61 virtual void contextDestroyed(); 60 62 AbstractWorker(ScriptExecutionContext*); 61 63 virtual ~AbstractWorker(); … … 70 72 virtual EventTargetData* eventTargetData(); 71 73 virtual EventTargetData* ensureEventTargetData(); 74 void onDestroyWorker(); 72 75 73 76 EventTargetData m_eventTargetData; 77 long m_id; 78 79 static long s_lastId; 74 80 }; 75 81 -
trunk/WebCore/workers/SharedWorker.cpp
r46925 r55522 35 35 #include "SharedWorker.h" 36 36 37 #include "InspectorController.h" 37 38 #include "KURL.h" 38 39 #include "MessageChannel.h" … … 54 55 return; 55 56 SharedWorkerRepository::connect(this, remotePort.release(), scriptUrl, name, ec); 57 #if ENABLE(INSPECTOR) 58 if (InspectorController* inspector = scriptExecutionContext()->inspectorController()) 59 inspector->didCreateWorker(id(), scriptUrl.string(), true); 60 #endif 56 61 } 57 62 -
trunk/WebCore/workers/Worker.cpp
r49734 r55522 41 41 #include "Frame.h" 42 42 #include "FrameLoader.h" 43 #include "InspectorController.h" 43 44 #include "MessageEvent.h" 44 45 #include "TextEncoding.h" … … 61 62 m_scriptLoader->loadAsynchronously(scriptExecutionContext(), scriptURL, DenyCrossOriginRequests, this); 62 63 setPendingActivity(this); // The worker context does not exist while loading, so we must ensure that the worker object is not collected, as well as its event listeners. 64 #if ENABLE(INSPECTOR) 65 if (InspectorController* inspector = scriptExecutionContext()->inspectorController()) 66 inspector->didCreateWorker(id(), scriptURL.string(), false); 67 #endif 63 68 } 64 69 -
trunk/WebKit/chromium/src/js/InspectorControllerImpl.js
r55347 r55522 39 39 { 40 40 WebInspector.InspectorBackendStub.call(this); 41 this.installInspectorControllerDelegate_("addScriptToEvaluateOnLoad"); 41 42 this.installInspectorControllerDelegate_("clearMessages"); 42 43 this.installInspectorControllerDelegate_("copyNode"); … … 56 57 this.installInspectorControllerDelegate_("hideDOMNodeHighlight"); 57 58 this.installInspectorControllerDelegate_("releaseWrapperObjectGroup"); 59 this.installInspectorControllerDelegate_("removeAllScriptsToEvaluateOnLoad"); 58 60 this.installInspectorControllerDelegate_("reloadPage"); 59 61 this.installInspectorControllerDelegate_("removeAttribute");
Note: See TracChangeset
for help on using the changeset viewer.