Changeset 65082 in webkit


Ignore:
Timestamp:
Aug 10, 2010 11:57:01 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-08-10 Johnny Ding <jnd@chromium.org>

Reviewed by Adam Barth.

Change the ScriptController::processingUserGesture to static method
and use dynamic(JSC binding)/entered(V8 binding) frame to check the user gesture.
https://bugs.webkit.org/show_bug.cgi?id=42827.

Test: fast/events/popup-blocked-from-iframe-script.html

  • WebCore.order:
  • bindings/js/JSDOMBinding.cpp: (WebCore::processingUserGesture):
  • bindings/js/JSDOMBinding.h:
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::setLocation): (WebCore::createWindow): (WebCore::domWindowAllowPopUp): (WebCore::JSDOMWindow::open): (WebCore::JSDOMWindow::showModalDialog):
  • bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::setLocation):
  • bindings/js/JSLocationCustom.cpp: (WebCore::navigateIfAllowed): (WebCore::JSLocation::reload):
  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::processingUserGesture):
  • bindings/js/ScriptController.h:
  • bindings/scripts/CodeGeneratorJS.pm:
  • bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture): (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD):
  • bindings/v8/ScriptController.cpp: (WebCore::ScriptController::processingUserGesture): (WebCore::ScriptController::anyPageIsProcessingUserGesture):
  • bindings/v8/ScriptController.h:
  • bindings/v8/specialization/V8BindingState.cpp: (WebCore::::processingUserGesture):
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::isProcessingUserGesture):

2010-08-10 Johnny Ding <jnd@chromium.org>

Reviewed by Adam Barth.

Change the ScriptController::processingUserGesture to static method
and use dynamic(JSC binding)/entered(V8 binding) frame to check the user gesture.
https://bugs.webkit.org/show_bug.cgi?id=42827

  • fast/events/popup-blocked-from-iframe-script-expected.txt: Added.
  • fast/events/popup-blocked-from-iframe-script.html: Added.
Location:
trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r65078 r65082  
     12010-08-10  Johnny Ding  <jnd@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Change the ScriptController::processingUserGesture to static method
     6        and use dynamic(JSC binding)/entered(V8 binding) frame to check the user gesture.
     7        https://bugs.webkit.org/show_bug.cgi?id=42827
     8
     9        * fast/events/popup-blocked-from-iframe-script-expected.txt: Added.
     10        * fast/events/popup-blocked-from-iframe-script.html: Added.
     11
    1122010-08-10  Ryosuke Niwa  <rniwa@webkit.org>
    213
  • trunk/WebCore/ChangeLog

    r65079 r65082  
     12010-08-10  Johnny Ding  <jnd@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Change the ScriptController::processingUserGesture to static method
     6        and use dynamic(JSC binding)/entered(V8 binding) frame to check the user gesture.
     7        https://bugs.webkit.org/show_bug.cgi?id=42827.
     8
     9        Test: fast/events/popup-blocked-from-iframe-script.html
     10
     11        * WebCore.order:
     12        * bindings/js/JSDOMBinding.cpp:
     13        (WebCore::processingUserGesture):
     14        * bindings/js/JSDOMBinding.h:
     15        * bindings/js/JSDOMWindowCustom.cpp:
     16        (WebCore::JSDOMWindow::setLocation):
     17        (WebCore::createWindow):
     18        (WebCore::domWindowAllowPopUp):
     19        (WebCore::JSDOMWindow::open):
     20        (WebCore::JSDOMWindow::showModalDialog):
     21        * bindings/js/JSDocumentCustom.cpp:
     22        (WebCore::JSDocument::setLocation):
     23        * bindings/js/JSLocationCustom.cpp:
     24        (WebCore::navigateIfAllowed):
     25        (WebCore::JSLocation::reload):
     26        * bindings/js/ScriptController.cpp:
     27        (WebCore::ScriptController::processingUserGesture):
     28        * bindings/js/ScriptController.h:
     29        * bindings/scripts/CodeGeneratorJS.pm:
     30        * bindings/scripts/test/JS/JSTestObj.cpp:
     31        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture):
     32        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD):
     33        * bindings/v8/ScriptController.cpp:
     34        (WebCore::ScriptController::processingUserGesture):
     35        (WebCore::ScriptController::anyPageIsProcessingUserGesture):
     36        * bindings/v8/ScriptController.h:
     37        * bindings/v8/specialization/V8BindingState.cpp:
     38        (WebCore::::processingUserGesture):
     39        * loader/FrameLoader.cpp:
     40        (WebCore::FrameLoader::isProcessingUserGesture):
     41
    1422010-08-10  Gavin Barraclough  <barraclough@apple.com>
    243
  • trunk/WebCore/WebCore.order

    r65014 r65082  
    73417341__ZN7WebCore21jsHTMLMediaElementSrcEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE
    73427342__ZN7WebCore39jsHTMLMediaElementPrototypeFunctionLoadEPN3JSC9ExecStateEPNS0_8JSObjectENS0_7JSValueERKNS0_7ArgListE
    7343 __ZN7WebCore21processingUserGestureEPN3JSC9ExecStateE
    7344 __ZNK7WebCore16ScriptController21processingUserGestureEPNS_15DOMWrapperWorldE
     7343__ZN7WebCore21processingUserGestureEv
     7344__ZN7WebCore16ScriptController21processingUserGestureEv
    73457345__ZN7WebCore16HTMLMediaElement4loadEbRi
    73467346__ZN7WebCore11MediaPlayerD0Ev
  • trunk/WebCore/bindings/js/JSDOMBinding.cpp

    r61531 r65082  
    680680}
    681681
    682 bool processingUserGesture(ExecState* exec)
    683 {
    684     Frame* frame = toDynamicFrame(exec);
    685     return frame && frame->script()->processingUserGesture(currentWorld(exec));
     682bool processingUserGesture()
     683{
     684    return ScriptController::processingUserGesture();
    686685}
    687686
  • trunk/WebCore/bindings/js/JSDOMBinding.h

    r65021 r65082  
    314314    Frame* toLexicalFrame(JSC::ExecState*);
    315315    Frame* toDynamicFrame(JSC::ExecState*);
    316     bool processingUserGesture(JSC::ExecState*);
     316    bool processingUserGesture();
    317317    KURL completeURL(JSC::ExecState*, const String& relativeURL);
    318318   
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r65077 r65082  
    513513    if (!protocolIsJavaScript(url) || allowsAccessFrom(exec)) {
    514514        // We want a new history item if this JS was called via a user gesture
    515         frame->redirectScheduler()->scheduleLocationChange(url, lexicalFrame->loader()->outgoingReferrer(), !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, processingUserGesture(exec));
     515        frame->redirectScheduler()->scheduleLocationChange(url, lexicalFrame->loader()->outgoingReferrer(), !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, processingUserGesture());
    516516    }
    517517}
     
    743743    if (!protocolIsJavaScript(url) || newWindow->allowsAccessFrom(exec)) {
    744744        KURL completedURL = url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(exec, url);
    745         bool userGesture = processingUserGesture(exec);
     745        bool userGesture = processingUserGesture();
    746746
    747747        if (created)
     
    754754}
    755755
    756 static bool domWindowAllowPopUp(Frame* activeFrame, ExecState* exec)
     756static bool domWindowAllowPopUp(Frame* activeFrame)
    757757{
    758758    ASSERT(activeFrame);
    759     if (activeFrame->script()->processingUserGesture(currentWorld(exec)))
     759    if (ScriptController::processingUserGesture())
    760760        return true;
    761761    return DOMWindow::allowPopUp(activeFrame);
     
    782782    // Because FrameTree::find() returns true for empty strings, we must check for empty framenames.
    783783    // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker.
    784     if (!domWindowAllowPopUp(dynamicFrame, exec) && (frameName.isEmpty() || !frame->tree()->find(frameName)))
     784    if (!domWindowAllowPopUp(dynamicFrame) && (frameName.isEmpty() || !frame->tree()->find(frameName)))
    785785        return jsUndefined();
    786786
     
    806806        const JSDOMWindow* targetedWindow = toJSDOMWindow(frame, currentWorld(exec));
    807807        if (!completedURL.isEmpty() && (!protocolIsJavaScript(completedURL) || (targetedWindow && targetedWindow->allowsAccessFrom(exec)))) {
    808             bool userGesture = processingUserGesture(exec);
     808            bool userGesture = processingUserGesture();
    809809
    810810            // For whatever reason, Firefox uses the dynamicGlobalObject to
     
    852852        return jsUndefined();
    853853
    854     if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame, exec))
     854    if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame))
    855855        return jsUndefined();
    856856
  • trunk/WebCore/bindings/js/JSDocumentCustom.cpp

    r59058 r65082  
    8989        str = activeFrame->document()->completeURL(str).string();
    9090
    91     bool userGesture = activeFrame->script()->processingUserGesture(currentWorld(exec));
     91    bool userGesture = ScriptController::processingUserGesture();
    9292    frame->redirectScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
    9393}
  • trunk/WebCore/bindings/js/JSLocationCustom.cpp

    r60392 r65082  
    192192
    193193    if (!protocolIsJavaScript(url) || allowsAccessFromFrame(exec, frame))
    194         frame->redirectScheduler()->scheduleLocationChange(url.string(), lexicalFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture(exec));
     194        frame->redirectScheduler()->scheduleLocationChange(url.string(), lexicalFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture());
    195195}
    196196
     
    326326
    327327    if (!protocolIsJavaScript(frame->loader()->url()))
    328         frame->redirectScheduler()->scheduleRefresh(processingUserGesture(exec));
     328        frame->redirectScheduler()->scheduleRefresh(processingUserGesture());
    329329    return jsUndefined();
    330330}
  • trunk/WebCore/bindings/js/ScriptController.cpp

    r63662 r65082  
    245245}
    246246
    247 bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const
    248 {
    249     if (m_allowPopupsFromPlugin || isJavaScriptAnchorNavigation())
     247bool ScriptController::processingUserGesture()
     248{
     249    ExecState* exec = JSMainThreadExecState::currentState();
     250    Frame* frame = exec ? toDynamicFrame(exec) : 0;
     251    // No script is running, so it is user-initiated unless the gesture stack
     252    // explicitly says it is not.
     253    if (!frame)
     254        return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
     255
     256    // FIXME: We check the plugin popup flag and javascript anchor navigation
     257    // from the dynamic frame becuase they should only be initiated on the
     258    // dynamic frame in which execution began if they do happen.
     259    ScriptController* scriptController = frame->script();
     260    ASSERT(scriptController);
     261    if (scriptController->allowPopupsFromPlugin() || scriptController->isJavaScriptAnchorNavigation())
    250262        return true;
    251263
    252264    // If a DOM event is being processed, check that it was initiated by the user
    253265    // and that it is in the whitelist of event types allowed to generate pop-ups.
    254     if (JSDOMWindowShell* shell = existingWindowShell(world))
     266    if (JSDOMWindowShell* shell = scriptController->existingWindowShell(currentWorld(exec)))
    255267        if (Event* event = shell->window()->currentEvent())
    256268            return event->fromUserGesture();
  • trunk/WebCore/bindings/js/ScriptController.h

    r65021 r65082  
    111111   
    112112    void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; }
    113     bool processingUserGesture(DOMWrapperWorld*) const;
     113    static bool processingUserGesture();
    114114    bool anyPageIsProcessingUserGesture() const;
    115115
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r65077 r65082  
    19941994                    if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {
    19951995                        $functionString .= ", " if $paramIndex;
    1996                         $functionString .= "processingUserGesture(exec)";
     1996                        $functionString .= "processingUserGesture()";
    19971997                        $paramIndex++;
    19981998                    }
  • trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r65005 r65082  
    11061106        return JSValue::encode(jsUndefined());
    11071107
    1108     imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture(exec));
     1108    imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture());
    11091109    return JSValue::encode(jsUndefined());
    11101110}
     
    11341134        return JSValue::encode(jsUndefined());
    11351135
    1136     imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture(exec));
     1136    imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture());
    11371137    return JSValue::encode(jsUndefined());
    11381138}
  • trunk/WebCore/bindings/v8/ScriptController.cpp

    r63845 r65082  
    161161}
    162162
    163 bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
    164 {
     163bool ScriptController::processingUserGesture()
     164{
     165    Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext();
    165166    // No script is running, so it is user-initiated unless the gesture stack
    166167    // explicitly says it is not.
    167     if (!m_proxy->executingScript())
     168    if (!activeFrame)
    168169        return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
    169170
    170     v8::HandleScope handleScope;
    171     v8::Handle<v8::Context> v8Context = m_proxy->mainWorldContext();
     171    V8Proxy* activeProxy = activeFrame->script()->proxy();
     172
     173    v8::HandleScope handleScope;
     174    v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(activeFrame);
    172175    // FIXME: find all cases context can be empty:
    173176    //  1) JS is disabled;
     
    189192        return event->fromUserGesture();
    190193    }
    191     if (m_sourceURL && m_sourceURL->isNull() && !m_proxy->timerCallback()) {
     194    // FIXME: We check the javascript anchor navigation from the last entered
     195    // frame becuase it should only be initiated on the last entered frame in
     196    // which execution began if it does happen.   
     197    const String* sourceURL = activeFrame->script()->sourceURL();
     198    if (sourceURL && sourceURL->isNull() && !activeProxy->timerCallback()) {
    192199        // This is the <a href="javascript:window.open('...')> case -> we let it through.
    193200        return true;
     
    202209{
    203210    // FIXME: is this right?
    204     return processingUserGesture();
     211    return ScriptController::processingUserGesture();
    205212}
    206213
  • trunk/WebCore/bindings/v8/ScriptController.h

    r65021 r65082  
    155155    // FIXME: Currently we don't use the parameter world at all.
    156156    // See http://trac.webkit.org/changeset/54182
    157     bool processingUserGesture(DOMWrapperWorld* world = 0) const;
     157    static bool processingUserGesture();
    158158    bool anyPageIsProcessingUserGesture() const;
    159159
  • trunk/WebCore/bindings/v8/specialization/V8BindingState.cpp

    r64991 r65082  
    8282bool State<V8Binding>::processingUserGesture()
    8383{
    84     Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
    85     return frame && frame->script()->processingUserGesture();
     84    return ScriptController::processingUserGesture();
    8685}
    8786
  • trunk/WebCore/loader/FrameLoader.cpp

    r64939 r65082  
    11301130    if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
    11311131        return true; // If JavaScript is disabled, a user gesture must have initiated the navigation.
    1132     return frame->script()->processingUserGesture(mainThreadNormalWorld()); // FIXME: Use pageIsProcessingUserGesture.
     1132    return ScriptController::processingUserGesture(); // FIXME: Use pageIsProcessingUserGesture.
    11331133}
    11341134
Note: See TracChangeset for help on using the changeset viewer.