Changeset 142654 in webkit


Ignore:
Timestamp:
Feb 12, 2013 12:45:44 PM (11 years ago)
Author:
vivek.vg@samsung.com
Message:

Web Inspector: JavaScript execution disabled by browser/UA should be notified to the front-end
https://bugs.webkit.org/show_bug.cgi?id=109402

Reviewed by Yury Semikhatsky.

Source/WebCore:

Whenever the UA/Browser changes the Script Execution state of a page, it should notify the
inspector front-end. Added the InspectorInstrumentation method didScriptExecutionStateChange
to achieve this. Also the state change triggered by the inspector should be ignored to avoid
infinite loop.

Test: inspector/script-execution-state-change-notification.html

  • inspector/Inspector.json:
  • inspector/InspectorInstrumentation.cpp:

(WebCore):
(WebCore::InspectorInstrumentation::scriptsEnabledImpl):

  • inspector/InspectorInstrumentation.h:

(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::scriptsEnabled):
(WebCore):

  • inspector/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::InspectorPageAgent):
(WebCore::InspectorPageAgent::setScriptExecutionDisabled):
(WebCore::InspectorPageAgent::scriptsEnabled):
(WebCore):

  • inspector/InspectorPageAgent.h:

(InspectorPageAgent):

  • inspector/front-end/ResourceTreeModel.js:

(WebInspector.PageDispatcher.prototype.javascriptDialogClosed):
(WebInspector.PageDispatcher.prototype.scriptsEnabled):

  • page/Settings.cpp:

(WebCore::Settings::setScriptEnabled):

LayoutTests:

Tests that whenever Script Execution state is changed outside inspector, its notified to the Inspector front-end.

  • inspector/script-execution-state-change-notification-expected.txt: Added.
  • inspector/script-execution-state-change-notification.html: Added.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142645 r142654  
     12013-02-12  Vivek Galatage  <vivek.vg@samsung.com>
     2
     3        Web Inspector: JavaScript execution disabled by browser/UA should be notified to the front-end
     4        https://bugs.webkit.org/show_bug.cgi?id=109402
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Tests that whenever Script Execution state is changed outside inspector, its notified to the Inspector front-end.
     9
     10        * inspector/script-execution-state-change-notification-expected.txt: Added.
     11        * inspector/script-execution-state-change-notification.html: Added.
     12
    1132013-02-12  Uday Kiran  <udaykiran@motorola.com>
    214
  • trunk/LayoutTests/platform/mac/TestExpectations

    r142439 r142654  
    305305# https://bugs.webkit.org/show_bug.cgi?id=96942
    306306http/tests/inspector/network/network-xhr-replay.html
     307
     308webkit.org/b/109546 inspector/script-execution-state-change-notification.html [ Skip ]
    307309
    308310# Safari doesn't allow to customize outermost scrollbars.
  • trunk/Source/WebCore/ChangeLog

    r142652 r142654  
     12013-02-12  Vivek Galatage  <vivek.vg@samsung.com>
     2
     3        Web Inspector: JavaScript execution disabled by browser/UA should be notified to the front-end
     4        https://bugs.webkit.org/show_bug.cgi?id=109402
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Whenever the UA/Browser changes the Script Execution state of a page, it should notify the
     9        inspector front-end. Added the InspectorInstrumentation method didScriptExecutionStateChange
     10        to achieve this. Also the state change triggered by the inspector should be ignored to avoid
     11        infinite loop.
     12
     13        Test: inspector/script-execution-state-change-notification.html
     14
     15        * inspector/Inspector.json:
     16        * inspector/InspectorInstrumentation.cpp:
     17        (WebCore):
     18        (WebCore::InspectorInstrumentation::scriptsEnabledImpl):
     19        * inspector/InspectorInstrumentation.h:
     20        (InspectorInstrumentation):
     21        (WebCore::InspectorInstrumentation::scriptsEnabled):
     22        (WebCore):
     23        * inspector/InspectorPageAgent.cpp:
     24        (WebCore::InspectorPageAgent::InspectorPageAgent):
     25        (WebCore::InspectorPageAgent::setScriptExecutionDisabled):
     26        (WebCore::InspectorPageAgent::scriptsEnabled):
     27        (WebCore):
     28        * inspector/InspectorPageAgent.h:
     29        (InspectorPageAgent):
     30        * inspector/front-end/ResourceTreeModel.js:
     31        (WebInspector.PageDispatcher.prototype.javascriptDialogClosed):
     32        (WebInspector.PageDispatcher.prototype.scriptsEnabled):
     33        * page/Settings.cpp:
     34        (WebCore::Settings::setScriptEnabled):
     35
    1362013-02-12  Antti Koivisto  <antti@apple.com>
    237
  • trunk/Source/WebCore/inspector/Inspector.json

    r142627 r142654  
    559559                "name": "javascriptDialogClosed",
    560560                "description": "Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) has been closed.",
     561                "hidden": true
     562            },
     563            {
     564                "name": "scriptsEnabled",
     565                "description": "Fired when the JavaScript is enabled/disabled on the page",
     566                "parameters": [
     567                    { "name": "isEnabled", "type": "boolean", "description": "Whether script execution is enabled or disabled on the page." }
     568                ],
    561569                "hidden": true
    562570            }
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r142575 r142654  
    448448}
    449449
     450void InspectorInstrumentation::scriptsEnabledImpl(InstrumentingAgents* instrumentingAgents, bool isEnabled)
     451{
     452    if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
     453        pageAgent->scriptsEnabled(isEnabled);
     454}
     455
    450456void InspectorInstrumentation::didCreateIsolatedContextImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, ScriptState* scriptState, SecurityOrigin* origin)
    451457{
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r142598 r142654  
    153153    static InspectorInstrumentationCookie willEvaluateScript(Frame*, const String& url, int lineNumber);
    154154    static void didEvaluateScript(const InspectorInstrumentationCookie&);
     155    static void scriptsEnabled(Page*, bool isEnabled);
    155156    static void didCreateIsolatedContext(Frame*, ScriptState*, SecurityOrigin*);
    156157    static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext*, int timerId);
     
    357358    static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents*, const String& url, int lineNumber, Frame*);
    358359    static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&);
     360    static void scriptsEnabledImpl(InstrumentingAgents*, bool isEnabled);
    359361    static void didCreateIsolatedContextImpl(InstrumentingAgents*, Frame*, ScriptState*, SecurityOrigin*);
    360362    static InspectorInstrumentationCookie willFireTimerImpl(InstrumentingAgents*, int timerId, ScriptExecutionContext*);
     
    967969}
    968970
     971inline void InspectorInstrumentation::scriptsEnabled(Page* page, bool isEnabled)
     972{
     973    FAST_RETURN_IF_NO_FRONTENDS(void());
     974    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
     975        return scriptsEnabledImpl(instrumentingAgents, isEnabled);
     976}
     977
    969978inline void InspectorInstrumentation::didCreateIsolatedContext(Frame* frame, ScriptState* scriptState, SecurityOrigin* origin)
    970979{
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r142247 r142654  
    338338    , m_isFirstLayoutAfterOnLoad(false)
    339339    , m_geolocationOverridden(false)
     340    , m_ignoreScriptsEnabledNotification(false)
    340341{
    341342}
     
    813814
    814815    Settings* settings = mainFrame()->settings();
    815     if (settings)
     816    if (settings) {
     817        m_ignoreScriptsEnabledNotification = true;
    816818        settings->setScriptEnabled(!value);
     819        m_ignoreScriptsEnabledNotification = false;
     820    }
    817821}
    818822
     
    10281032    if (m_enabled)
    10291033        m_overlay->update();
     1034}
     1035
     1036void InspectorPageAgent::scriptsEnabled(bool isEnabled)
     1037{
     1038    if (m_ignoreScriptsEnabledNotification)
     1039        return;
     1040
     1041    m_frontend->scriptsEnabled(isEnabled);
    10301042}
    10311043
  • trunk/Source/WebCore/inspector/InspectorPageAgent.h

    r142144 r142654  
    157157    void didScroll();
    158158    void didRecalculateStyle();
     159    void scriptsEnabled(bool isEnabled);
    159160
    160161    // Inspector Controller API
     
    206207    bool m_isFirstLayoutAfterOnLoad;
    207208    bool m_geolocationOverridden;
     209    bool m_ignoreScriptsEnabledNotification;
    208210    RefPtr<GeolocationPosition> m_geolocationPosition;
    209211    RefPtr<GeolocationPosition> m_platformGeolocationPosition;
  • trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js

    r141555 r142654  
    626626    javascriptDialogClosed: function()
    627627    {
     628    },
     629
     630    scriptsEnabled: function(isEnabled)
     631    {
     632        WebInspector.settings.javaScriptDisabled.set(!isEnabled);
    628633    }
    629634}
  • trunk/Source/WebCore/page/Settings.cpp

    r141837 r142654  
    3838#include "HTMLMediaElement.h"
    3939#include "HistoryItem.h"
     40#include "InspectorInstrumentation.h"
    4041#include "Page.h"
    4142#include "PageCache.h"
     
    416417{
    417418    m_isScriptEnabled = isScriptEnabled;
     419    InspectorInstrumentation::scriptsEnabled(m_page, m_isScriptEnabled);
    418420}
    419421
Note: See TracChangeset for help on using the changeset viewer.