[Webkit-unassigned] [Bug 136542] Web Inspector: breakpoint actions should work regardless of Content Security Policy

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Sep 4 18:45:01 PDT 2014


Mark Lam <mark.lam at apple.com> changed:

           What    |Removed                     |Added
 Attachment #237664|review?                     |review-
               Flag|                            |

--- Comment #3 from Mark Lam <mark.lam at apple.com>  2014-09-04 18:45:06 PST ---
(From update of attachment 237664)
View in context: https://bugs.webkit.org/attachment.cgi?id=237664&action=review

> Source/JavaScriptCore/ChangeLog:9
> +        JSGlobalObject for the duration of scope, returning the eval enabled state to its

/duration of scope/duration of a scope/

> Source/JavaScriptCore/ChangeLog:11
> +        to allow breakpoint actions to execute JS in pages with CSP that would normally

Would you mind spelling out Content Security Policy instead of the CSP abbreviation?  Thanks.

> Source/JavaScriptCore/ChangeLog:14
> +        Refactored Inspector::InjectedScriptBase to use RAII object instead of manually

/use RAII/use the RAII/

> Source/JavaScriptCore/ChangeLog:15
> +        setting/resetting eval enabled state.

/...ing eval enabled/...ing the eval enabled/

> Source/JavaScriptCore/debugger/DebuggerEvalEnabler.h:46
> +    explicit DebuggerEvalEnabler(const ExecState* exec)
> +        : m_globalObject(nullptr)
> +        , m_evalEnabled(false)
> +    {
> +        if (exec) {
> +            m_globalObject = exec->lexicalGlobalObject();
> +            m_evalEnabled = m_globalObject->evalEnabled();
> +        }
> +        if (m_globalObject && !m_evalEnabled)
> +            m_globalObject->setEvalEnabled(true, m_globalObject->evalDisabledErrorMessage());
> +    }

I suggest renaming m_evalEnabled to m_evalWasEnabled to indicate that it is referring to the original state.  Actually, I think you should use m_evalwasDisabled instead because that would remove the need for a lot of negation in the code (making the logic simpler).

I think it's weird that the exec can be NULL, but that appears to be a due to InjectedScriptBase getting the exec from ScriptObject::scriptState() which can currently be NULL.  I suggest adding a comment in the ChangeLog to document this so that we'll have a record of why this NULL check exists, and can remove it in the future if we fix ScriptObject::scriptState() to never be NULL (at least for the duration when the DebuggerEvalEnabler is called).

Why not just cache the ExecState, and do a conditional on that?  I suggest the following:

    explicit DebuggerEvalEnabler(const ExecState* exec)
        : m_exec(exec)
        , m_evalWasDisabled(false)
        if (exec) {
            JSGlobalObject* globalObject = exec->lexicalGlobalObject();
            m_evalWasDisabled = !m_globalObject->evalEnabled();
            if (m_evalWasDisabled)
                globalObject->setEvalEnabled(true, globalObject->evalDisabledErrorMessage());

        if (m_evalWasDisabled) {
            JSGlobalObject* globalObject = exec->lexicalGlobalObject();
            globalObject()->setEvalEnabled(false, globalObject->evalDisabledErrorMessage());

I think the code is a little simpler this way.

Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

More information about the webkit-unassigned mailing list