Commit 930e76d0 authored by slewis@apple.com's avatar slewis@apple.com

2008-05-15 Stephanie Lewis <slewis@apple.com>

        Reviewed by Anders.

        Keep track on pending unload event counts

        No change in behavior so no new tests, but I am dumping the 
        unload event count to track the new variable.

        * WebCore.base.exp:

        increment/decrement the count when an event is added/removed
        * dom/Document.cpp:
        (WebCore::Document::removeHTMLWindowEventListener):
        (WebCore::Document::addWindowEventListener):
        (WebCore::Document::removeWindowEventListener):
        (WebCore::Document::setPendingFrameUnloadEventCount):
        * dom/Document.h:

        set the count to 0 for each frame after the unload event has been dispatched
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::stopLoading):

        keep track of the number of pending unload events for the eventHandler's frame
        * page/EventHandler.cpp:
        (WebCore::EventHandler::EventHandler):
       (WebCore::EventHandler::pendingFrameUnloadEventCount):
        (WebCore::EventHandler::setPendingFrameUnloadEventCount):
        * page/EventHandler.h:

        keep track of the total number of pending unload events for all of the frames
        * page/Page.cpp:
        (WebCore::Page::Page):
        (WebCore::Page::pendingUnloadEventCount):
        (WebCore::Page::setPendingUnloadEventCount):
           age/Page.h:

        get the pending frame unload count from WebCore

        * WebView/WebFrame.mm:
        (-[WebFrame _pendingFrameUnloadEventCount]):
        * WebView/WebFramePrivate.h:

        Dump the unload count for a frame after parsing is finished.

        * DumpRenderTree/mac/FrameLoadDelegate.mm:
        (-[FrameLoadDelegate webView:didFinishDocumentLoadForFrame:]):

        Dump unload event counts for frames.

        * fast/dom/Window/get-set-properties-expected.txt:
        * fast/events/onunload-expected.txt:
        * fast/events/onunload-not-on-body-expected.txt:
        * fast/events/onunload-window-property-expected.txt:
        * fast/forms/button-state-restore-expected.txt:
        * fast/history/history_reload-expected.txt:
        * fast/loader/onunload-form-submit-crash-2-expected.txt:
        * fast/loader/onunload-form-submit-crash-expected.txt:
        * http/tests/xmlhttprequest/xhr-onunload-expected.txt:
        * platform/mac/fast/loader/start-load-in-unload-expected.txt:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33503 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d2636d46
2008-05-15 Stephanie Lewis <slewis@apple.com>
Reviewed by Anders.
Dump unload event counts for frames.
* fast/dom/Window/get-set-properties-expected.txt:
* fast/events/onunload-expected.txt:
* fast/events/onunload-not-on-body-expected.txt:
* fast/events/onunload-window-property-expected.txt:
* fast/forms/button-state-restore-expected.txt:
* fast/history/history_reload-expected.txt:
* fast/loader/onunload-form-submit-crash-2-expected.txt:
* fast/loader/onunload-form-submit-crash-expected.txt:
* http/tests/xmlhttprequest/xhr-onunload-expected.txt:
* platform/mac/fast/loader/start-load-in-unload-expected.txt:
2008-05-15 David Kilzer <ddkilzer@apple.com>
Bug 19085: font-family: initial sets font-family differently than font: initial
main frame "window.marker.toString()" - has 1 onunload handler(s)
This page tests getting and setting window properties and functions.
......
main frame "1" - has 1 onunload handler(s)
ALERT: unload
You should have seen an unload alert appear.
frame "<!--framePath /1/<!--frame2-->-->" - has 1 onunload handler(s)
ALERT: unload
you should only see one unload alert appear.
main frame "1" - has 1 onunload handler(s)
ALERT: unload
You should have seen an unload alert appear.
main frame "1" - has 1 onunload handler(s)
main frame "1" - has 1 onunload handler(s)
This is a test for http://bugs.webkit.org/show_bug.cgi?id=14400 Assertion failure (SHOULD NEVER BE REACHED) going back on YouTube.
Test result: PASS
......
main frame - has 1 onunload handler(s)
main frame - has 1 onunload handler(s)
This tests that history.go(0) will force a page reload.
Test Passed
main frame - has 1 onunload handler(s)
main frame - has 1 onunload handler(s)
SUCCESS
main frame - has 1 onunload handler(s)
Bug: rdar://problem/4268278 Submitting a form in onUnload event handler causes crash in -[WebDataSource(WebPrivate) _commitIfReady:]
If this test passes, you'll see a PASS message below.
......
main frame - has 1 onunload handler(s)
Test for bug 10852: REGRESSION: Reproducible crash in XMLHttpRequest::abort().
Press Cmd+R to reload (should not crash).
main frame - has 1 onunload handler(s)
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
......
2008-05-15 Stephanie Lewis <slewis@apple.com>
Reviewed by Anders.
Keep track on pending unload event counts
No change in behavior so no new tests, but I am dumping the
unload event count to track the new variable.
* WebCore.base.exp:
increment/decrement the count when an event is added/removed
* dom/Document.cpp:
(WebCore::Document::removeHTMLWindowEventListener):
(WebCore::Document::addWindowEventListener):
(WebCore::Document::removeWindowEventListener):
(WebCore::Document::setPendingFrameUnloadEventCount):
* dom/Document.h:
set the count to 0 for each frame after the unload event has been dispatched
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::stopLoading):
keep track of the number of pending unload events for the eventHandler's frame
* page/EventHandler.cpp:
(WebCore::EventHandler::EventHandler):
(WebCore::EventHandler::pendingFrameUnloadEventCount):
(WebCore::EventHandler::setPendingFrameUnloadEventCount):
* page/EventHandler.h:
keep track of the total number of pending unload events for all of the frames
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::pendingUnloadEventCount):
(WebCore::Page::setPendingUnloadEventCount):
* page/Page.h:
2008-05-15 Steve Falkenburg <sfalken@apple.com>
Fix build.
......@@ -96,6 +96,7 @@ __ZN7WebCore12EventHandler20handleTextInputEventERKNS_6StringEPNS_5EventEbb
__ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_8IntPointEb
__ZN7WebCore12EventHandler20sendContextMenuEventERKNS_18PlatformMouseEventE
__ZN7WebCore12EventHandler27capsLockStateMayHaveChangedEv
__ZN7WebCore12EventHandler28pendingFrameUnloadEventCountEv
__ZN7WebCore12EventHandler7mouseUpEP7NSEvent
__ZN7WebCore12EventHandler8keyEventEP7NSEvent
__ZN7WebCore12EventHandler8keyEventERKNS_21PlatformKeyboardEventE
......@@ -305,6 +306,7 @@ __ZN7WebCore4Page15backForwardListEv
__ZN7WebCore4Page16setDefersLoadingEb
__ZN7WebCore4Page18removeSchedulePairEN3WTF10PassRefPtrINS_12SchedulePairEEE
__ZN7WebCore4Page23clearUndoRedoOperationsEv
__ZN7WebCore4Page23pendingUnloadEventCountEv
__ZN7WebCore4Page37setInLowQualityImageInterpolationModeEb
__ZN7WebCore4Page6goBackEv
__ZN7WebCore4Page8goToItemEPNS_11HistoryItemENS_13FrameLoadTypeE
......
......@@ -2645,6 +2645,8 @@ void Document::removeHTMLWindowEventListener(const AtomicString &eventType)
RegisteredEventListenerList::iterator it = m_windowEventListeners.begin();
for (; it != m_windowEventListeners.end(); ++it)
if ( (*it)->eventType() == eventType && (*it)->listener()->isHTMLEventListener()) {
if (eventType == ((AtomicString)unloadEvent))
setPendingFrameUnloadEventCount(-1);
m_windowEventListeners.remove(it);
return;
}
......@@ -2652,6 +2654,8 @@ void Document::removeHTMLWindowEventListener(const AtomicString &eventType)
void Document::addWindowEventListener(const AtomicString &eventType, PassRefPtr<EventListener> listener, bool useCapture)
{
if (eventType == ((AtomicString)unloadEvent))
setPendingFrameUnloadEventCount(1);
// Remove existing identical listener set with identical arguments.
// The DOM 2 spec says that "duplicate instances are discarded" in this case.
removeWindowEventListener(eventType, listener.get(), useCapture);
......@@ -2664,6 +2668,8 @@ void Document::removeWindowEventListener(const AtomicString &eventType, EventLis
RegisteredEventListenerList::iterator it = m_windowEventListeners.begin();
for (; it != m_windowEventListeners.end(); ++it)
if (*(*it) == rl) {
if (eventType == ((AtomicString)unloadEvent))
setPendingFrameUnloadEventCount(-1);
m_windowEventListeners.remove(it);
return;
}
......@@ -2679,6 +2685,12 @@ bool Document::hasWindowEventListener(const AtomicString &eventType)
return false;
}
void Document::setPendingFrameUnloadEventCount(int delta)
{
if (m_frame)
m_frame->eventHandler()->setPendingFrameUnloadEventCount(delta);
}
PassRefPtr<EventListener> Document::createHTMLEventListener(const String& functionName, const String& code, Node *node)
{
if (Frame* frm = frame())
......
......@@ -538,6 +538,8 @@ public:
void addWindowEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
void removeWindowEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
bool hasWindowEventListener(const AtomicString& eventType);
void setPendingFrameUnloadEventCount(int frameUnloadEventCount);
PassRefPtr<EventListener> createHTMLEventListener(const String& functionName, const String& code, Node*);
......
......@@ -586,6 +586,8 @@ void FrameLoader::stopLoading(bool sendUnload)
if (m_frame->document())
m_frame->document()->updateRendering();
m_wasUnloadEventEmitted = true;
if (m_frame->eventHandler()->pendingFrameUnloadEventCount())
m_frame->eventHandler()->setPendingFrameUnloadEventCount(-m_frame->eventHandler()->pendingFrameUnloadEventCount());
}
}
if (m_frame->document() && !m_frame->document()->inPageCache())
......
......@@ -111,6 +111,7 @@ EventHandler::EventHandler(Frame* frame)
, m_capturingMouseEventsNode(0)
, m_clickCount(0)
, m_mouseDownTimestamp(0)
, m_pendingFrameUnloadEventCount(0)
#if PLATFORM(MAC)
, m_mouseDownView(nil)
, m_sendingEventToSubview(false)
......@@ -1868,6 +1869,19 @@ void EventHandler::capsLockStateMayHaveChanged()
if (Node* node = d->focusedNode())
if (RenderObject* r = node->renderer())
r->capsLockStateMayHaveChanged();
}
}
unsigned EventHandler::pendingFrameUnloadEventCount()
{
return m_pendingFrameUnloadEventCount;
}
void EventHandler::setPendingFrameUnloadEventCount(int delta)
{
ASSERT( (delta + (int)m_pendingFrameUnloadEventCount) >= 0 );
m_pendingFrameUnloadEventCount += delta;
m_frame->page()->setPendingUnloadEventCount(delta);
return;
}
}
......@@ -154,6 +154,9 @@ public:
void capsLockStateMayHaveChanged();
unsigned pendingFrameUnloadEventCount();
void setPendingFrameUnloadEventCount(int delta);
#if PLATFORM(MAC)
PassRefPtr<KeyboardEvent> currentKeyboardEvent() const;
......@@ -314,6 +317,8 @@ private:
PlatformMouseEvent m_mouseDown;
static unsigned s_accessKeyModifiers;
unsigned m_pendingFrameUnloadEventCount;
#if PLATFORM(MAC)
NSView *m_mouseDownView;
......
......@@ -130,6 +130,7 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi
, m_userStyleSheetModificationTime(0)
, m_group(0)
, m_debugger(0)
, m_pendingUnloadEventCount(0)
{
if (!allPages) {
allPages = new HashSet<Page*>;
......@@ -520,5 +521,18 @@ void Page::setSessionStorage(PassRefPtr<SessionStorage> newStorage)
m_sessionStorage = newStorage;
}
#endif
unsigned Page::pendingUnloadEventCount()
{
return m_pendingUnloadEventCount;
}
void Page::setPendingUnloadEventCount(int delta)
{
ASSERT( (delta + (int)m_pendingUnloadEventCount) >= 0 );
m_pendingUnloadEventCount += delta;
return;
}
} // namespace WebCore
......@@ -143,6 +143,9 @@ namespace WebCore {
void userStyleSheetLocationChanged();
const String& userStyleSheet() const;
void setPendingUnloadEventCount(int frameUnloadEventCount);
unsigned pendingUnloadEventCount();
static void setDebuggerForAllPages(KJS::Debugger*);
void setDebugger(KJS::Debugger*);
......@@ -203,6 +206,8 @@ namespace WebCore {
PageGroup* m_group;
KJS::Debugger* m_debugger;
unsigned m_pendingUnloadEventCount;
#if ENABLE(DOM_STORAGE)
RefPtr<SessionStorage> m_sessionStorage;
......
2008-05-15 Stephanie Lewis <slewis@apple.com>
Reviewed by Anders.
get the pending frame unload count from WebCore
* WebView/WebFrame.mm:
(-[WebFrame _pendingFrameUnloadEventCount]):
* WebView/WebFramePrivate.h:
2008-05-15 John Sullivan <sullivan@apple.com>
Reviewed by Kevin Decker
......
......@@ -1082,6 +1082,11 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
return document && document->isImageDocument();
}
- (unsigned)_pendingFrameUnloadEventCount
{
return _private->coreFrame->eventHandler()->pendingFrameUnloadEventCount();
}
@end
@implementation WebFrame
......
......@@ -66,4 +66,5 @@ typedef enum {
- (BOOL)_isDisplayingStandaloneImage;
- (unsigned) _pendingFrameUnloadEventCount;
@end
2008-05-15 Stephanie Lewis <slewis@apple.com>
Reviewed by Anders.
Dump the unload count for a frame after parsing is finished.
* DumpRenderTree/mac/FrameLoadDelegate.mm:
(-[FrameLoadDelegate webView:didFinishDocumentLoadForFrame:]):
2008-05-15 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Dan Bernstein.
......
......@@ -319,6 +319,12 @@
if (!done && layoutTestController->dumpFrameLoadCallbacks()) {
NSString *string = [NSString stringWithFormat:@"%@ - didFinishDocumentLoadForFrame", [frame _drt_descriptionSuitableForTestResult]];
printf ("%s\n", [string UTF8String]);
} else if (!done) {
unsigned pendingFrameUnloadEvents = [frame _pendingFrameUnloadEventCount];
if (pendingFrameUnloadEvents) {
NSString *string = [NSString stringWithFormat:@"%@ - has %u onunload handler(s)", [frame _drt_descriptionSuitableForTestResult], pendingFrameUnloadEvents];
printf ("%s\n", [string UTF8String]);
}
}
}
......
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