Changeset 60771 in webkit


Ignore:
Timestamp:
Jun 7, 2010 2:57:55 AM (14 years ago)
Author:
yurys@chromium.org
Message:

2010-06-07 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: should be possible to distinguish extension scripts from main world scripts
https://bugs.webkit.org/show_bug.cgi?id=40220

  • bindings/js/ScriptDebugServer.cpp: remove global listeners set which is not used anymore. (WebCore::ScriptDebugServer::dispatchDidParseSource): pass script wrold type to the listeners. (WebCore::currentWorldType): (WebCore::ScriptDebugServer::sourceParsed):
  • bindings/js/ScriptDebugServer.h:
  • bindings/v8/ScriptDebugServer.cpp: (WebCore::ScriptDebugServer::dispatchDidParseSource):
  • inspector/InspectorController.cpp: (WebCore::InspectorController::didParseSource):
  • inspector/InspectorController.h:
  • inspector/InspectorFrontend.cpp: (WebCore::InspectorFrontend::parsedScriptSource):
  • inspector/InspectorFrontend.h:
  • inspector/ScriptDebugListener.h: pass type of the isolated world where the script was compiled to didParseSource. (WebCore::):
  • inspector/front-end/InjectedScript.js: (injectedScriptConstructor):
  • inspector/front-end/Script.js: (WebInspector.Script):
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel.prototype.addScript): (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu): use different style to highlight content scripts.
  • inspector/front-end/inspector.css: (#scripts-files option.extension-script):
  • inspector/front-end/inspector.js: (WebInspector.parsedScriptSource):

2010-06-07 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: should be possible to distinguish extension scripts from main world scripts
https://bugs.webkit.org/show_bug.cgi?id=40220

  • src/js/DebuggerAgent.js: (devtools.DebuggerAgent.prototype.initUI): (devtools.DebuggerAgent.prototype.addScriptInfo_): (devtools.DebuggerAgent.prototype.formatCallFrame_): (devtools.ScriptInfo.prototype.worldType):
  • src/js/DebuggerScript.js: (debuggerScriptConstructor.DebuggerScript.getScripts): use only context id without context type when filtering scripts so that extension scripts are also included. (debuggerScriptConstructor.DebuggerScript._formatScript):
  • src/js/devTools.css:
Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r60768 r60771  
     12010-06-07  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: should be possible to distinguish extension scripts from main world scripts
     6        https://bugs.webkit.org/show_bug.cgi?id=40220
     7
     8        * bindings/js/ScriptDebugServer.cpp: remove global listeners set which is not used anymore.
     9        (WebCore::ScriptDebugServer::dispatchDidParseSource): pass script wrold type to the listeners.
     10        (WebCore::currentWorldType):
     11        (WebCore::ScriptDebugServer::sourceParsed):
     12        * bindings/js/ScriptDebugServer.h:
     13        * bindings/v8/ScriptDebugServer.cpp:
     14        (WebCore::ScriptDebugServer::dispatchDidParseSource):
     15        * inspector/InspectorController.cpp:
     16        (WebCore::InspectorController::didParseSource):
     17        * inspector/InspectorController.h:
     18        * inspector/InspectorFrontend.cpp:
     19        (WebCore::InspectorFrontend::parsedScriptSource):
     20        * inspector/InspectorFrontend.h:
     21        * inspector/ScriptDebugListener.h: pass type of the isolated world where the script was compiled to didParseSource.
     22        (WebCore::):
     23        * inspector/front-end/InjectedScript.js:
     24        (injectedScriptConstructor):
     25        * inspector/front-end/Script.js:
     26        (WebInspector.Script):
     27        * inspector/front-end/ScriptsPanel.js:
     28        (WebInspector.ScriptsPanel.prototype.addScript):
     29        (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu): use different style to highlight content scripts.
     30        * inspector/front-end/inspector.css:
     31        (#scripts-files option.extension-script):
     32        * inspector/front-end/inspector.js:
     33        (WebInspector.parsedScriptSource):
     34
    1352010-06-06  MORITA Hajime  <morrita@google.com>
    236
  • trunk/WebCore/bindings/js/ScriptDebugServer.cpp

    r60154 r60771  
    131131    ASSERT_ARG(page, page);
    132132
    133     if (hasGlobalListeners())
    134         return true;
    135 
    136133    return m_pageListenersMap.contains(page);
    137134}
     
    258255}
    259256
    260 void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source)
     257void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, ScriptWorldType worldType)
    261258{
    262259    String sourceID = ustringToString(JSC::UString::from(source.provider()->asID()));
     
    268265    copyToVector(listeners, copy);
    269266    for (size_t i = 0; i < copy.size(); ++i)
    270         copy[i]->didParseSource(sourceID, url, data, firstLine);
     267        copy[i]->didParseSource(sourceID, url, data, firstLine, worldType);
    271268}
    272269
     
    290287    Frame* frame = window->impl()->frame();
    291288    return frame ? frame->page() : 0;
     289}
     290
     291static ScriptWorldType currentWorldType(ExecState* exec)
     292{
     293    if (currentWorld(exec) == mainThreadNormalWorld())
     294        return MAIN_WORLD;
     295    return EXTENSIONS_WORLD;
    292296}
    293297
     
    314318        return;
    315319
     320    ScriptWorldType worldType = currentWorldType(exec);
     321
    316322    m_callingListeners = true;
    317323
    318324    bool isError = errorLine != -1;
    319 
    320     if (hasGlobalListeners()) {
    321         if (isError)
    322             dispatchFailedToParseSource(m_listeners, source, errorLine, ustringToString(errorMessage));
    323         else
    324             dispatchDidParseSource(m_listeners, source);
    325     }
    326325
    327326    if (ListenerSet* pageListeners = m_pageListenersMap.get(page)) {
     
    330329            dispatchFailedToParseSource(*pageListeners, source, errorLine, ustringToString(errorMessage));
    331330        else
    332             dispatchDidParseSource(*pageListeners, source);
     331            dispatchDidParseSource(*pageListeners, source, worldType);
    333332    }
    334333
     
    352351
    353352    ASSERT(hasListeners());
    354 
    355     dispatchFunctionToListeners(m_listeners, callback);
    356353
    357354    if (ListenerSet* pageListeners = m_pageListenersMap.get(page)) {
     
    575572void ScriptDebugServer::didRemoveListener(Page* page)
    576573{
    577     if (hasGlobalListeners() || (page && hasListenersInterestedInPage(page)))
     574    if (page && hasListenersInterestedInPage(page))
    578575        return;
    579576
  • trunk/WebCore/bindings/js/ScriptDebugServer.h

    r60154 r60771  
    3333#if ENABLE(JAVASCRIPT_DEBUGGER)
    3434
     35#include "ScriptDebugListener.h"
    3536#include "PlatformString.h"
    3637#include "ScriptBreakpoint.h"
     
    9798
    9899    bool hasBreakpoint(intptr_t sourceID, unsigned lineNumber) const;
    99     bool hasListeners() const { return !m_listeners.isEmpty() || !m_pageListenersMap.isEmpty(); }
    100     bool hasGlobalListeners() const { return !m_listeners.isEmpty(); }
     100    bool hasListeners() const { return !m_pageListenersMap.isEmpty(); }
    101101    bool hasListenersInterestedInPage(Page*);
    102102
     
    110110    void dispatchDidPause(ScriptDebugListener*);
    111111    void dispatchDidContinue(ScriptDebugListener*);
    112     void dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source);
     112    void dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, enum ScriptWorldType);
    113113    void dispatchFailedToParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, int errorLine, const String& errorMessage);
    114114
     
    134134
    135135    PageListenersMap m_pageListenersMap;
    136     ListenerSet m_listeners;
    137136    bool m_callingListeners;
    138137    PauseOnExceptionsState m_pauseOnExceptionsState;
  • trunk/WebCore/bindings/v8/ScriptDebugServer.cpp

    r60309 r60771  
    321321        toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("name"))),
    322322        toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("source"))),
    323         object->Get(v8::String::New("lineOffset"))->ToInteger()->Value());
     323        object->Get(v8::String::New("lineOffset"))->ToInteger()->Value(),
     324        static_cast<ScriptWorldType>(object->Get(v8::String::New("scriptWorldType"))->Int32Value()));
    324325}
    325326
  • trunk/WebCore/inspector/InspectorController.cpp

    r60618 r60771  
    16541654// JavaScriptDebugListener functions
    16551655
    1656 void InspectorController::didParseSource(const String& sourceID, const String& url, const String& data, int firstLine)
    1657 {
    1658     m_frontend->parsedScriptSource(sourceID, url, data, firstLine);
     1656void InspectorController::didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType worldType)
     1657{
     1658    m_frontend->parsedScriptSource(sourceID, url, data, firstLine, worldType);
    16591659
    16601660    if (url.isEmpty())
  • trunk/WebCore/inspector/InspectorController.h

    r60414 r60771  
    244244    void resumeDebugger();
    245245
    246     virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine);
     246    virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType);
    247247    virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
    248248    virtual void didPause(ScriptState*);
  • trunk/WebCore/inspector/InspectorFrontend.cpp

    r60443 r60771  
    306306}
    307307
    308 void InspectorFrontend::parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine)
     308void InspectorFrontend::parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine, int scriptWorldType)
    309309{
    310310    ScriptFunctionCall function(m_webInspector, "dispatch");
     
    314314    function.appendArgument(data);
    315315    function.appendArgument(firstLine);
     316    function.appendArgument(scriptWorldType);
    316317    function.call();
    317318}
  • trunk/WebCore/inspector/InspectorFrontend.h

    r60443 r60771  
    9393        void debuggerWasDisabled();
    9494
    95         void parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine);
     95        void parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine, int scriptWorldType);
    9696        void restoredBreakpoint(const String& sourceID, const String& url, int line, bool enabled, const String& condition);
    9797        void failedToParseScriptSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
  • trunk/WebCore/inspector/ScriptDebugListener.h

    r60154 r60771  
    3939class String;
    4040
     41enum ScriptWorldType {
     42MAIN_WORLD = 0,
     43EXTENSIONS_WORLD
     44};
     45
    4146class ScriptDebugListener {
    4247public:
    4348    virtual ~ScriptDebugListener() { }
    4449
    45     virtual void didParseSource(const String&  sourceID, const String& url, const String& data, int firstLine) = 0;
     50    virtual void didParseSource(const String&  sourceID, const String& url, const String& data, int firstLine, ScriptWorldType) = 0;
    4651    virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) = 0;
    4752    virtual void didPause(ScriptState*) = 0;
  • trunk/WebCore/inspector/front-end/InjectedScript.js

    r60623 r60771  
    10181018    // I gave up and am using a check below to distinguish between the egine bingings.
    10191019
    1020     if (typeof Document === "object") {
    1021         // JSC
     1020    if (jsEngine == "JSC") {
    10221021        var str = inspectedWindow.Object ? inspectedWindow.Object.prototype.toString.call(obj) : InjectedScript._toString(obj);
    10231022        return str.replace(/^\[object (.*)\]$/i, "$1");
    1024     }
    1025     // V8
    1026     if (typeof obj !== "object")
    1027         return "null";
    1028     return obj.constructor.name || "Object";
     1023    } else {
     1024        // V8
     1025        if (typeof obj !== "object")
     1026            return "null";
     1027        return obj.constructor.name || "Object";
     1028    }
    10291029}
    10301030
  • trunk/WebCore/inspector/front-end/Script.js

    r55522 r60771  
    2424 */
    2525
    26 WebInspector.Script = function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage)
     26WebInspector.Script = function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, worldType)
    2727{
    2828    this.sourceID = sourceID;
     
    3232    this.errorLine = errorLine;
    3333    this.errorMessage = errorMessage;
     34    this.worldType = worldType;
    3435
    3536    // if no URL, look for "//@ sourceURL=" decorator
     
    4748}
    4849
     50WebInspector.Script.WorldType = {
     51    MAIN_WORLD: 0,
     52    EXTENSIONS_WORLD: 1
     53}
     54
    4955WebInspector.Script.prototype = {
    5056    get linesCount()
  • trunk/WebCore/inspector/front-end/ScriptsPanel.js

    r60567 r60771  
    242242    },
    243243
    244     addScript: function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage)
    245     {
    246         var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, errorLine, errorMessage);
     244    addScript: function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, scriptWorldType)
     245    {
     246        var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, scriptWorldType);
    247247        this._sourceIDMap[sourceID] = script;
    248248
     
    738738                this._showScriptOrResource(option.representedObject, {initialLoad: true});
    739739        }
     740
     741        if (script.worldType === WebInspector.Script.WorldType.EXTENSIONS_WORLD)
     742            script.filesSelectOption.addStyleClass("extension-script");
    740743    },
    741744
  • trunk/WebCore/inspector/front-end/inspector.css

    r60414 r60771  
    23522352}
    23532353
     2354#scripts-files option.extension-script {
     2355    color: rgb(70, 134, 240);
     2356}
     2357
    23542358#scripts-functions {
    23552359    max-width: 150px;
  • trunk/WebCore/inspector/front-end/inspector.js

    r60680 r60771  
    13201320}
    13211321
    1322 WebInspector.parsedScriptSource = function(sourceID, sourceURL, source, startingLine)
    1323 {
    1324     this.panels.scripts.addScript(sourceID, sourceURL, source, startingLine);
     1322WebInspector.parsedScriptSource = function(sourceID, sourceURL, source, startingLine, scriptWorldType)
     1323{
     1324    this.panels.scripts.addScript(sourceID, sourceURL, source, startingLine, undefined, undefined, scriptWorldType);
    13251325}
    13261326
  • trunk/WebKit/chromium/ChangeLog

    r60695 r60771  
     12010-06-07  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: should be possible to distinguish extension scripts from main world scripts
     6        https://bugs.webkit.org/show_bug.cgi?id=40220
     7
     8        * src/js/DebuggerAgent.js:
     9        (devtools.DebuggerAgent.prototype.initUI):
     10        (devtools.DebuggerAgent.prototype.addScriptInfo_):
     11        (devtools.DebuggerAgent.prototype.formatCallFrame_):
     12        (devtools.ScriptInfo.prototype.worldType):
     13        * src/js/DebuggerScript.js:
     14        (debuggerScriptConstructor.DebuggerScript.getScripts): use only context id without context type
     15        when filtering scripts so that extension scripts are also included.
     16        (debuggerScriptConstructor.DebuggerScript._formatScript):
     17        * src/js/devTools.css:
     18
    1192010-06-04  Jay Civelli  <jcivelli@chromium.org>
    220
  • trunk/WebKit/chromium/src/js/DebuggerAgent.js

    r58477 r60771  
    182182        for (var scriptId in this.parsedScripts_) {
    183183          var script = this.parsedScripts_[scriptId];
    184           WebInspector.parsedScriptSource(scriptId, script.getUrl(), undefined /* script source */, script.getLineOffset() + 1);
     184          WebInspector.parsedScriptSource(scriptId, script.getUrl(), undefined /* script source */, script.getLineOffset() + 1, script.worldType());
    185185          this.restoreBreakpoints_(scriptId, script.getUrl());
    186186        }
     
    949949{
    950950    var context = msg.lookup(script.context.ref);
    951     var contextType;
    952951    // Find the type from context data. The context data has the format
    953952    // "type,id".
    954953    var comma = context.data.indexOf(",");
    955954    if (comma < 0)
    956         return
    957     contextType = context.data.substring(0, comma);
    958     this.parsedScripts_[script.id] = new devtools.ScriptInfo(script.id, script.name, script.lineOffset, contextType);
     955        return;
     956    var contextType = context.data.substring(0, comma);
     957    var info = new devtools.ScriptInfo(script.id, script.name, script.lineOffset, contextType);
     958    this.parsedScripts_[script.id] = info;
    959959    if (this.scriptsPanelInitialized_) {
    960960        // Only report script as parsed after scripts panel has been shown.
    961         WebInspector.parsedScriptSource(script.id, script.name, script.source, script.lineOffset + 1);
     961        WebInspector.parsedScriptSource(script.id, script.name, script.source, script.lineOffset + 1, info.worldType());
    962962        this.restoreBreakpoints_(script.id, script.name);
    963963    }
     
    10451045    if (!existingScript) {
    10461046        this.parsedScripts_[sourceId] = new devtools.ScriptInfo(sourceId, null /* name */, 0 /* line */, "unknown" /* type */, true /* unresolved */);
    1047         WebInspector.parsedScriptSource(sourceId, null, null, 0);
     1047        WebInspector.parsedScriptSource(sourceId, null, null, 0, WebInspector.Script.WorldType.MAIN_WORLD);
    10481048    }
    10491049
     
    12581258
    12591259
     1260devtools.ScriptInfo.prototype.worldType = function()
     1261{
     1262    if (this.contextType_ === "injected")
     1263        return WebInspector.Script.WorldType.EXTENSIONS_WORLD;
     1264    return WebInspector.Script.WorldType.MAIN_WORLD;
     1265};
     1266
     1267
    12601268/**
    12611269 * @param {number} line 0-based line number in the script.
  • trunk/WebKit/chromium/src/js/DebuggerScript.js

    r60154 r60771  
    4040};
    4141
     42DebuggerScript.ScriptWorldType = {
     43    MainWorld : 0,
     44    ExtensionsWorld : 1
     45};
     46
    4247DebuggerScript._pauseOnExceptionsState = DebuggerScript.PauseOnExceptionsState.DontPauseOnExceptions;
    4348Debug.clearBreakOnException();
     
    5156DebuggerScript.getScripts = function(contextData)
    5257{
     58    var result = [];
     59
     60    if (!contextData)
     61        return result;
     62    var comma = contextData.indexOf(",");
     63    if (comma === -1)
     64        return result;
     65    // Context data is a string in the following format:
     66    // ("page"|"injected")","<page id>
     67    var idSuffix = contextData.substring(comma); // including the comma
     68
    5369    var scripts = Debug.scripts();
    54     var result = [];
    5570    for (var i = 0; i < scripts.length; ++i) {
    5671        var script = scripts[i];
    57         if (contextData === script.context_data)
     72        if (script.context_data && script.context_data.lastIndexOf(idSuffix) != -1)
    5873            result.push(DebuggerScript._formatScript(script));
    5974    }
     
    6378DebuggerScript._formatScript = function(script)
    6479{
     80    var scriptWorldType = DebuggerScript.ScriptWorldType.MainWorld;
     81    if (script.context_data && script.context_data.indexOf("injected") == 0)
     82        scriptWorldType = DebuggerScript.ScriptWorldType.ExtensionsWorld;
    6583    return {
    6684        id: script.id,
     
    6987        lineOffset: script.line_offset,
    7088        lineCount: script.lineCount(),
    71         contextData: script.context_data
     89        scriptWorldType: scriptWorldType
    7290    };
    7391}
  • trunk/WebKit/chromium/src/js/devTools.css

    r60141 r60771  
    1 #scripts-files option.injected {
    2     color: rgb(70, 134, 240);
    3 }
    4 
    51.data-grid table {
    62    line-height: 120%;
Note: See TracChangeset for help on using the changeset viewer.