Commit 05a4f6a0 authored by cwzwarich@webkit.org's avatar cwzwarich@webkit.org

2008-12-18 Cameron Zwarich <zwarich@apple.com>

        Reviewed by Geoff Garen.

        Bug 21855: REGRESSION (r37323): Gmail complains about popup blocking when opening a link
        <https://bugs.webkit.org/show_bug.cgi?id=21855>
        <rdar://problem/6278244>

        If JavaScript is not currently executing, the handleEvent member function
        of JSAbstractEventListener should set the dynamic global object to the
        global object of the context in which the event occurred.
        
        If this is not set, then JavaScriptCore will simply take the global object
        of the context where the event handler function was created, which may be
        a different frame. This will cause the popup blocker to incorrectly block
        windows opened from onclick events inside of an iframe whose handler was
        created in the outer frame, as it will check the outer frame and see that
        it is not processing any events.

        JavaScriptCore:

        * interpreter/Interpreter.cpp:
        * runtime/JSGlobalObject.h:
        (JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope):
        (JSC::DynamicGlobalObjectScope::~DynamicGlobalObjectScope):

        WebCore:

        * bindings/js/JSEventListener.cpp:
        (WebCore::JSAbstractEventListener::handleEvent):

        WebKitTools:

        * DumpRenderTree/mac/EventSendingController.h:
        * DumpRenderTree/mac/EventSendingController.mm:
        (+[EventSendingController isSelectorExcludedFromWebScript:]): Expose
        scheduleAsynchronousClick to JavaScript.
        (-[EventSendingController scheduleAsynchronousClick]): Add.

        LayoutTests:

        * fast/events/popup-blocking-click-in-iframe-expected.txt: Added.
        * fast/events/popup-blocking-click-in-iframe.html: Added.
        * fast/events/resources/popup-blocking-click-in-iframe-otherFrame.html: Added.
        * platform/gtk/Skipped:
        * platform/qt/Skipped:
        * platform/win/Skipped:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@39377 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cd92f578
2008-12-18 Cameron Zwarich <zwarich@apple.com>
Reviewed by Geoff Garen.
Bug 21855: REGRESSION (r37323): Gmail complains about popup blocking when opening a link
<https://bugs.webkit.org/show_bug.cgi?id=21855>
<rdar://problem/6278244>
Move DynamicGlobalObjectScope to JSGlobalObject.h so that it can be used
from WebCore.
* interpreter/Interpreter.cpp:
* runtime/JSGlobalObject.h:
(JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope):
(JSC::DynamicGlobalObjectScope::~DynamicGlobalObjectScope):
2008-12-17 Geoffrey Garen <ggaren@apple.com>
Reviewed by Gavin Barraclough.
......
......@@ -864,25 +864,6 @@ NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSV
return handler;
}
class DynamicGlobalObjectScope : Noncopyable {
public:
DynamicGlobalObjectScope(CallFrame* callFrame, JSGlobalObject* dynamicGlobalObject)
: m_dynamicGlobalObjectSlot(callFrame->globalData().dynamicGlobalObject)
, m_savedDynamicGlobalObject(m_dynamicGlobalObjectSlot)
{
m_dynamicGlobalObjectSlot = dynamicGlobalObject;
}
~DynamicGlobalObjectScope()
{
m_dynamicGlobalObjectSlot = m_savedDynamicGlobalObject;
}
private:
JSGlobalObject*& m_dynamicGlobalObjectSlot;
JSGlobalObject* m_savedDynamicGlobalObject;
};
JSValue* Interpreter::execute(ProgramNode* programNode, CallFrame* callFrame, ScopeChainNode* scopeChain, JSObject* thisObj, JSValue** exception)
{
ASSERT(!scopeChain->globalData->exception);
......
......@@ -355,7 +355,26 @@ namespace JSC {
ASSERT(globalData().dynamicGlobalObject);
return globalData().dynamicGlobalObject;
}
class DynamicGlobalObjectScope : Noncopyable {
public:
DynamicGlobalObjectScope(CallFrame* callFrame, JSGlobalObject* dynamicGlobalObject)
: m_dynamicGlobalObjectSlot(callFrame->globalData().dynamicGlobalObject)
, m_savedDynamicGlobalObject(m_dynamicGlobalObjectSlot)
{
m_dynamicGlobalObjectSlot = dynamicGlobalObject;
}
~DynamicGlobalObjectScope()
{
m_dynamicGlobalObjectSlot = m_savedDynamicGlobalObject;
}
private:
JSGlobalObject*& m_dynamicGlobalObjectSlot;
JSGlobalObject* m_savedDynamicGlobalObject;
};
} // namespace JSC
#endif // JSGlobalObject_h
2008-12-18 Cameron Zwarich <zwarich@apple.com>
Reviewed by Geoff Garen.
Add tests for bug 21855: REGRESSION (r37323): Gmail complains about popup blocking when opening a link
<https://bugs.webkit.org/show_bug.cgi?id=21855>
<rdar://problem/6278244>
Since DumpRenderTree support was added in order to support these tests,
they are skipped on non-Mac platforms.
* fast/events/popup-blocking-click-in-iframe-expected.txt: Added.
* fast/events/popup-blocking-click-in-iframe.html: Added.
* fast/events/resources/popup-blocking-click-in-iframe-otherFrame.html: Added.
* platform/gtk/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
2008-12-18 Pamela Greene <pam@chromium.org>
Submitted without review.
......
This tests that popup blocking does not supress windows opened in an iframe if the event handler is a function from an enclosing frame.
To run manually click the link in the iframe above with popup blocking enabled.
Window was opened! Test succeeded!
--------
Frame: 'otherFrame'
--------
Click this text to open a window.
<html>
<head>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.setCanOpenWindows();
layoutTestController.dumpChildFramesAsText();
layoutTestController.waitUntilDone();
layoutTestController.setCloseRemainingWindowsWhenComplete()
layoutTestController.setPopupBlockingEnabled(true);
}
function closeWindow(windowToClose)
{
windowToClose.close();
setTimeout(doneHandler, 1);
function doneHandler()
{
if (!windowToClose.closed)
setTimeout(doneHandler, 1);
else if (window.layoutTestController)
layoutTestController.notifyDone();
}
}
function handleClick(event) {
var newWindow = window.open('resources/window-opened.html', 'badName', 'width=100, height=100');
if (newWindow) {
log("Window was opened! Test succeeded!");
closeWindow(newWindow);
}
event.preventDefault();
return false;
}
function test()
{
if (window.layoutTestController) {
eventSender.mouseMoveTo(2, 2);
eventSender.scheduleAsynchronousClick();
}
}
function log(msg)
{
var res = document.getElementById('res');
res.innerHTML = res.innerHTML + msg + "<br>";
}
</script>
</head>
<body style="border: 0; margin: 0" onload="test()">
<iframe style="border: 0; margin: 0" src="resources/popup-blocking-click-in-iframe-otherFrame.html" id="otherFrame"></iframe>
<p>This tests that popup blocking does not supress windows opened in an iframe if the event handler is a function from an enclosing frame.</p>
<p>To run manually click the link in the iframe above with popup blocking enabled.</p>
<div id="res"></div>
</body>
</html>
<html>
<head>
<script>
function prepareEventHandler()
{
var spanToClick = document.getElementById('clickable');
spanToClick.onclick = parent.handleClick;
}
</script>
</head>
<body style="border: 0; margin: 0" onload="prepareEventHandler()">
<span id="clickable">Click this text to open a window.</a>
</body>
</html>
......@@ -2131,6 +2131,9 @@ transitions
traversal
webarchive
# Needs scheduleAsynchronousClick method for EventSender
fast/events/popup-blocking-click-in-iframe.html
# Tests in plugins/ directory
# Tests that need ObjC plugin
plugins/call-as-function-test.html
......
......@@ -6,6 +6,7 @@ editing/selection/5109817.html
editing/selection/5354455-1.html
editing/selection/5354455-2.html
editing/selection/caret-and-focus-ring.html
fast/events/popup-blocking-click-in-iframe.html
# -------- crashes
fast/events/objc-keyboard-event-creation.html
......
......@@ -359,6 +359,9 @@ editing/execCommand/enabling-and-selection-2.html
# Needs custom policy delegate enhancement in DRT
http/tests/navigation/post-goback-repost-policy.html
# Needs scheduleAsynchronousClick method for EventSender
fast/events/popup-blocking-click-in-iframe.html
################################################################################
######################### All of above may be related ##########################
################################################################################
......
2008-12-18 Cameron Zwarich <zwarich@apple.com>
Reviewed by Geoff Garen.
Bug 21855: REGRESSION (r37323): Gmail complains about popup blocking when opening a link
<https://bugs.webkit.org/show_bug.cgi?id=21855>
<rdar://problem/6278244>
If JavaScript is not currently executing, the handleEvent member function
of JSAbstractEventListener should set the dynamic global object to the
global object of the context in which the event occurred.
If this is not set, then JavaScriptCore will simply take the global object
of the context where the event handler function was created, which may be
a different frame. This will cause the popup blocker to incorrectly block
windows opened from onclick events inside of an iframe whose handler was
created in the outer frame, as it will check the outer frame and see that
it is not processing any events.
* bindings/js/JSEventListener.cpp:
(WebCore::JSAbstractEventListener::handleEvent):
2008-12-17 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dave Hyatt
......@@ -95,6 +95,12 @@ void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent)
Event* savedEvent = globalObject->currentEvent();
globalObject->setCurrentEvent(event);
// If this event handler is the first JavaScript to execute, then the
// dynamic global object should be set to the global object of the
// window in which the event occurred.
JSGlobalData* globalData = globalObject->globalData();
DynamicGlobalObjectScope globalObjectScope(exec, globalData->dynamicGlobalObject ? globalData->dynamicGlobalObject : globalObject);
JSValue* retval;
if (handleEventFunction) {
globalObject->startTimeoutCheck();
......
2008-12-18 Cameron Zwarich <zwarich@apple.com>
Reviewed by Geoff Garen.
Add tests for bug 21855: REGRESSION (r37323): Gmail complains about popup blocking when opening a link
<https://bugs.webkit.org/show_bug.cgi?id=21855>
<rdar://problem/6278244>
Add support for scheduling asynchronous clicks to DumpRenderTree, but
only on the Mac.
* DumpRenderTree/mac/EventSendingController.h:
* DumpRenderTree/mac/EventSendingController.mm:
(+[EventSendingController isSelectorExcludedFromWebScript:]): Expose
scheduleAsynchronousClick to JavaScript.
(-[EventSendingController scheduleAsynchronousClick]): Add.
2008-12-15 Darin Adler <darin@apple.com>
* Scripts/make-js-test-wrappers: Added another exception to avoid overwriting
......
......@@ -43,6 +43,8 @@
+ (void)replaySavedEvents;
+ (void)clearSavedEvents;
- (void)scheduleAsynchronousClick;
- (void)enableDOMUIEventLogging:(WebScriptObject *)node;
- (void)handleEvent:(DOMEvent *)event;
......
......@@ -121,6 +121,7 @@ BOOL replayingSavedEvents;
if (aSelector == @selector(mouseDown:)
|| aSelector == @selector(mouseUp:)
|| aSelector == @selector(contextClick)
|| aSelector == @selector(scheduleAsynchronousClick)
|| aSelector == @selector(mouseMoveToX:Y:)
|| aSelector == @selector(leapForward:)
|| aSelector == @selector(keyDown:withModifiers:)
......@@ -403,6 +404,12 @@ static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction acti
[subView menuForEvent:event];
}
- (void)scheduleAsynchronousClick
{
[self performSelector:@selector(mouseDown:) withObject:nil afterDelay:0];
[self performSelector:@selector(mouseUp:) withObject:nil afterDelay:0];
}
+ (void)saveEvent:(NSInvocation *)event
{
if (!savedMouseEvents)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment