Changeset 65082 in webkit
- Timestamp:
- Aug 10, 2010 11:57:01 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r65078 r65082 1 2010-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 1 12 2010-08-10 Ryosuke Niwa <rniwa@webkit.org> 2 13 -
trunk/WebCore/ChangeLog
r65079 r65082 1 2010-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 1 42 2010-08-10 Gavin Barraclough <barraclough@apple.com> 2 43 -
trunk/WebCore/WebCore.order
r65014 r65082 7341 7341 __ZN7WebCore21jsHTMLMediaElementSrcEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE 7342 7342 __ZN7WebCore39jsHTMLMediaElementPrototypeFunctionLoadEPN3JSC9ExecStateEPNS0_8JSObjectENS0_7JSValueERKNS0_7ArgListE 7343 __ZN7WebCore21processingUserGestureE PN3JSC9ExecStateE7344 __ZN K7WebCore16ScriptController21processingUserGestureEPNS_15DOMWrapperWorldE7343 __ZN7WebCore21processingUserGestureEv 7344 __ZN7WebCore16ScriptController21processingUserGestureEv 7345 7345 __ZN7WebCore16HTMLMediaElement4loadEbRi 7346 7346 __ZN7WebCore11MediaPlayerD0Ev -
trunk/WebCore/bindings/js/JSDOMBinding.cpp
r61531 r65082 680 680 } 681 681 682 bool processingUserGesture(ExecState* exec) 683 { 684 Frame* frame = toDynamicFrame(exec); 685 return frame && frame->script()->processingUserGesture(currentWorld(exec)); 682 bool processingUserGesture() 683 { 684 return ScriptController::processingUserGesture(); 686 685 } 687 686 -
trunk/WebCore/bindings/js/JSDOMBinding.h
r65021 r65082 314 314 Frame* toLexicalFrame(JSC::ExecState*); 315 315 Frame* toDynamicFrame(JSC::ExecState*); 316 bool processingUserGesture( JSC::ExecState*);316 bool processingUserGesture(); 317 317 KURL completeURL(JSC::ExecState*, const String& relativeURL); 318 318 -
trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp
r65077 r65082 513 513 if (!protocolIsJavaScript(url) || allowsAccessFrom(exec)) { 514 514 // 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()); 516 516 } 517 517 } … … 743 743 if (!protocolIsJavaScript(url) || newWindow->allowsAccessFrom(exec)) { 744 744 KURL completedURL = url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(exec, url); 745 bool userGesture = processingUserGesture( exec);745 bool userGesture = processingUserGesture(); 746 746 747 747 if (created) … … 754 754 } 755 755 756 static bool domWindowAllowPopUp(Frame* activeFrame , ExecState* exec)756 static bool domWindowAllowPopUp(Frame* activeFrame) 757 757 { 758 758 ASSERT(activeFrame); 759 if ( activeFrame->script()->processingUserGesture(currentWorld(exec)))759 if (ScriptController::processingUserGesture()) 760 760 return true; 761 761 return DOMWindow::allowPopUp(activeFrame); … … 782 782 // Because FrameTree::find() returns true for empty strings, we must check for empty framenames. 783 783 // 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))) 785 785 return jsUndefined(); 786 786 … … 806 806 const JSDOMWindow* targetedWindow = toJSDOMWindow(frame, currentWorld(exec)); 807 807 if (!completedURL.isEmpty() && (!protocolIsJavaScript(completedURL) || (targetedWindow && targetedWindow->allowsAccessFrom(exec)))) { 808 bool userGesture = processingUserGesture( exec);808 bool userGesture = processingUserGesture(); 809 809 810 810 // For whatever reason, Firefox uses the dynamicGlobalObject to … … 852 852 return jsUndefined(); 853 853 854 if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame , exec))854 if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame)) 855 855 return jsUndefined(); 856 856 -
trunk/WebCore/bindings/js/JSDocumentCustom.cpp
r59058 r65082 89 89 str = activeFrame->document()->completeURL(str).string(); 90 90 91 bool userGesture = activeFrame->script()->processingUserGesture(currentWorld(exec));91 bool userGesture = ScriptController::processingUserGesture(); 92 92 frame->redirectScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture); 93 93 } -
trunk/WebCore/bindings/js/JSLocationCustom.cpp
r60392 r65082 192 192 193 193 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()); 195 195 } 196 196 … … 326 326 327 327 if (!protocolIsJavaScript(frame->loader()->url())) 328 frame->redirectScheduler()->scheduleRefresh(processingUserGesture( exec));328 frame->redirectScheduler()->scheduleRefresh(processingUserGesture()); 329 329 return jsUndefined(); 330 330 } -
trunk/WebCore/bindings/js/ScriptController.cpp
r63662 r65082 245 245 } 246 246 247 bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const 248 { 249 if (m_allowPopupsFromPlugin || isJavaScriptAnchorNavigation()) 247 bool 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()) 250 262 return true; 251 263 252 264 // If a DOM event is being processed, check that it was initiated by the user 253 265 // 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))) 255 267 if (Event* event = shell->window()->currentEvent()) 256 268 return event->fromUserGesture(); -
trunk/WebCore/bindings/js/ScriptController.h
r65021 r65082 111 111 112 112 void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; } 113 bool processingUserGesture(DOMWrapperWorld*) const;113 static bool processingUserGesture(); 114 114 bool anyPageIsProcessingUserGesture() const; 115 115 -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r65077 r65082 1994 1994 if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { 1995 1995 $functionString .= ", " if $paramIndex; 1996 $functionString .= "processingUserGesture( exec)";1996 $functionString .= "processingUserGesture()"; 1997 1997 $paramIndex++; 1998 1998 } -
trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r65005 r65082 1106 1106 return JSValue::encode(jsUndefined()); 1107 1107 1108 imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture( exec));1108 imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture()); 1109 1109 return JSValue::encode(jsUndefined()); 1110 1110 } … … 1134 1134 return JSValue::encode(jsUndefined()); 1135 1135 1136 imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture( exec));1136 imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture()); 1137 1137 return JSValue::encode(jsUndefined()); 1138 1138 } -
trunk/WebCore/bindings/v8/ScriptController.cpp
r63845 r65082 161 161 } 162 162 163 bool ScriptController::processingUserGesture(DOMWrapperWorld*) const 164 { 163 bool ScriptController::processingUserGesture() 164 { 165 Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext(); 165 166 // No script is running, so it is user-initiated unless the gesture stack 166 167 // explicitly says it is not. 167 if (! m_proxy->executingScript())168 if (!activeFrame) 168 169 return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture; 169 170 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); 172 175 // FIXME: find all cases context can be empty: 173 176 // 1) JS is disabled; … … 189 192 return event->fromUserGesture(); 190 193 } 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()) { 192 199 // This is the <a href="javascript:window.open('...')> case -> we let it through. 193 200 return true; … … 202 209 { 203 210 // FIXME: is this right? 204 return processingUserGesture();211 return ScriptController::processingUserGesture(); 205 212 } 206 213 -
trunk/WebCore/bindings/v8/ScriptController.h
r65021 r65082 155 155 // FIXME: Currently we don't use the parameter world at all. 156 156 // See http://trac.webkit.org/changeset/54182 157 bool processingUserGesture(DOMWrapperWorld* world = 0) const;157 static bool processingUserGesture(); 158 158 bool anyPageIsProcessingUserGesture() const; 159 159 -
trunk/WebCore/bindings/v8/specialization/V8BindingState.cpp
r64991 r65082 82 82 bool State<V8Binding>::processingUserGesture() 83 83 { 84 Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); 85 return frame && frame->script()->processingUserGesture(); 84 return ScriptController::processingUserGesture(); 86 85 } 87 86 -
trunk/WebCore/loader/FrameLoader.cpp
r64939 r65082 1130 1130 if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) 1131 1131 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. 1133 1133 } 1134 1134
Note: See TracChangeset
for help on using the changeset viewer.