Bug 89530 - Web Inspector: Allow module injections into the InjectedScript
Summary: Web Inspector: Allow module injections into the InjectedScript
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Andrey Adaikin
URL:
Keywords:
Depends on: 89107
Blocks: 88973 89592
  Show dependency treegraph
 
Reported: 2012-06-19 16:46 PDT by Andrey Adaikin
Modified: 2012-06-20 12:12 PDT (History)
16 users (show)

See Also:


Attachments
Patch (23.86 KB, patch)
2012-06-19 16:56 PDT, Andrey Adaikin
no flags Details | Formatted Diff | Diff
Patch (24.59 KB, patch)
2012-06-19 20:12 PDT, Andrey Adaikin
no flags Details | Formatted Diff | Diff
Patch (26.28 KB, patch)
2012-06-20 10:04 PDT, Andrey Adaikin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Adaikin 2012-06-19 16:46:55 PDT
Add a new InjectedModule abstract class that inherits InjectedScriptBase to reuse implementation, and which javascript code is injected via InjectedScript's addModule.
Comment 1 Andrey Adaikin 2012-06-19 16:56:35 PDT
Created attachment 148460 [details]
Patch
Comment 2 Pavel Feldman 2012-06-19 17:38:25 PDT
Comment on attachment 148460 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=148460&action=review

> Source/WebCore/inspector/InjectedModule.h:42
> +class InjectedModule : public InjectedScriptBase {

InjectedScriptModule

> Source/WebCore/inspector/InjectedModule.h:49
> +    friend void InjectedScript::injectModule(InjectedModule&, bool&);

friend class InjectedScript

> Source/WebCore/inspector/InjectedScript.cpp:242
> +    ASSERT(!hasNoValue());

I would try to hold all the module-related logic in a single location. (InjectedScriptModule). Eventually, we might want to make generic injected script a module itself.
Comment 3 Andrey Adaikin 2012-06-19 20:12:16 PDT
Created attachment 148491 [details]
Patch
Comment 4 Yury Semikhatsky 2012-06-20 00:10:22 PDT
Comment on attachment 148491 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=148491&action=review

> Source/WebCore/inspector/InjectedScriptBase.h:53
> +    virtual String name() const = 0;

Just pass it as a constructor parameter?

> Source/WebCore/inspector/InjectedScriptBase.h:70
> +    friend class InjectedScriptModule;

I'd rather introduce protected method initialize(ScriptObject, inspectedStateAccessCheck)

> Source/WebCore/inspector/InjectedScriptModule.cpp:51
> +    ASSERT(!injectedScript.hasNoValue());

If InjectedScript is required we may have injectModule method defined on InjectedScript and avoid this check and InjectedScriptManager parameter.
Comment 5 Andrey Adaikin 2012-06-20 09:56:21 PDT
Comment on attachment 148491 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=148491&action=review

>> Source/WebCore/inspector/InjectedScriptBase.h:53
>> +    virtual String name() const = 0;
> 
> Just pass it as a constructor parameter?

Done.

>> Source/WebCore/inspector/InjectedScriptBase.h:70
>> +    friend class InjectedScriptModule;
> 
> I'd rather introduce protected method initialize(ScriptObject, inspectedStateAccessCheck)

Done.

>> Source/WebCore/inspector/InjectedScriptModule.cpp:51
>> +    ASSERT(!injectedScript.hasNoValue());
> 
> If InjectedScript is required we may have injectModule method defined on InjectedScript and avoid this check and InjectedScriptManager parameter.

The previous attachment does suggest a solution with injectModule defined on the InjectedScript. But ultimately we would like the InjectedScript be a module itself (e.g. smth like GenericInjectedScriptModule), and prohibit it to inject other modules. The "injectModule" method will be in a separate entity (let it call InjectedModuleManager) that will be also shared across all modules to reuse methods like bindObject, wrapObject and etc.

In other words, now we have: InjectedScript = GenericInjectedScriptModule + InjectedModuleManager, which should be split up accordingly in a future refactoring. Thus, not having the "injectModule" method defined on InjectedScript helps the future efforts.
Comment 6 Andrey Adaikin 2012-06-20 10:04:05 PDT
Created attachment 148589 [details]
Patch
Comment 7 WebKit Review Bot 2012-06-20 11:28:23 PDT
Comment on attachment 148589 [details]
Patch

Clearing flags on attachment: 148589

Committed r120842: <http://trac.webkit.org/changeset/120842>
Comment 8 WebKit Review Bot 2012-06-20 11:28:29 PDT
All reviewed patches have been landed.  Closing bug.