Title: [94220] branches/safari-534.51-branch
Revision
94220
Author
lforsch...@apple.com
Date
2011-08-31 13:12:31 -0700 (Wed, 31 Aug 2011)

Log Message

Merged r92982.

Modified Paths

Added Paths

Diff

Modified: branches/safari-534.51-branch/LayoutTests/ChangeLog (94219 => 94220)


--- branches/safari-534.51-branch/LayoutTests/ChangeLog	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/LayoutTests/ChangeLog	2011-08-31 20:12:31 UTC (rev 94220)
@@ -1,5 +1,19 @@
 2011-08-29  Lucas Forschler  <lforsch...@apple.com>
 
+    Merged 92982
+
+    2011-08-12  Andy Estes  <aes...@apple.com>
+
+            Cancel in onbeforeunload dialog sometime causes a button to stop working.
+            https://bugs.webkit.org/show_bug.cgi?id=26211
+
+            Reviewed by Alexey Proskuryakov.
+
+            * fast/loader/form-submission-after-beforeunload-cancel-expected.txt: Added.
+            * fast/loader/form-submission-after-beforeunload-cancel.html: Added.
+
+2011-08-29  Lucas Forschler  <lforsch...@apple.com>
+
     Merged 93934
 
     2011-08-26  Gavin Barraclough  <barraclo...@apple.com>

Copied: branches/safari-534.51-branch/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel-expected.txt (from rev 92982, trunk/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel-expected.txt) (0 => 94220)


--- branches/safari-534.51-branch/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel-expected.txt	                        (rev 0)
+++ branches/safari-534.51-branch/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel-expected.txt	2011-08-31 20:12:31 UTC (rev 94220)
@@ -0,0 +1,3 @@
+CONFIRM NAVIGATION: Click 'Stay on Page'
+CONFIRM NAVIGATION: Click 'Leave Page'
+PASS

Copied: branches/safari-534.51-branch/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel.html (from rev 92982, trunk/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel.html) (0 => 94220)


--- branches/safari-534.51-branch/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel.html	                        (rev 0)
+++ branches/safari-534.51-branch/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel.html	2011-08-31 20:12:31 UTC (rev 94220)
@@ -0,0 +1,43 @@
+<script>
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.dumpAsText();
+    layoutTestController.setShouldStayOnPageAfterHandlingBeforeUnload(true);
+}
+
+_confirmationDialogDisplayedOnce = false;
+
+window.addEventListener("beforeunload", function() {
+
+    if (window._confirmationDialogDisplayedOnce)
+        return "Click 'Leave Page'";
+
+    window.setTimeout(function() {
+        if (window.layoutTestController)
+            layoutTestController.setShouldStayOnPageAfterHandlingBeforeUnload(false);
+
+        window.setTimeout(function() {
+            document.getElementById("console").innerHTML = "FAIL";
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }, 0);
+
+        document.forms[0].submit();
+    }, 0);
+    
+    window._confirmationDialogDisplayedOnce = true;
+    
+    return "Click 'Stay on Page'";
+});
+</script>
+
+<p>This tests that submitting a form a second time after canceling the first submission in a onbeforeunload handler is allowed. To test manually, follow the instructions in the _javascript_ confirmation dialogs.</p>
+
+<div id="console"></div>
+
+<form action="" method="POST">
+</form>
+
+<script>
+document.forms[0].submit();
+</script>
\ No newline at end of file

Modified: branches/safari-534.51-branch/Source/WebCore/ChangeLog (94219 => 94220)


--- branches/safari-534.51-branch/Source/WebCore/ChangeLog	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Source/WebCore/ChangeLog	2011-08-31 20:12:31 UTC (rev 94220)
@@ -1,5 +1,29 @@
 2011-08-29  Lucas Forschler  <lforsch...@apple.com>
 
+    Merged 92982
+
+    2011-08-12  Andy Estes  <aes...@apple.com>
+
+            Cancel in onbeforeunload dialog sometime causes a button to stop working.
+            https://bugs.webkit.org/show_bug.cgi?id=26211
+
+            Reviewed by Alexey Proskuryakov.
+
+            Test: fast/loader/form-submission-after-beforeunload-cancel.html
+
+            If an onbeforeunload handler cancels a navigation that was triggered by
+            a form submission, WebCore's multiple form submission protection
+            prevents the form from being submitted a second time even though no
+            first submission actually took place. Fix this by clearing
+            m_submittedFormURL if the onbeforeunload handler cancels the load. This
+            allows the submission to be retried.
+
+            * loader/FrameLoader.cpp:
+            (WebCore::FrameLoader::shouldClose): Set m_submittedFormURL to KURL()
+            if shouldClose() will return false.
+
+2011-08-29  Lucas Forschler  <lforsch...@apple.com>
+
     Merged 93459
 
     2011-08-19  Jeff Miller  <je...@apple.com>

Modified: branches/safari-534.51-branch/Source/WebCore/loader/FrameLoader.cpp (94219 => 94220)


--- branches/safari-534.51-branch/Source/WebCore/loader/FrameLoader.cpp	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Source/WebCore/loader/FrameLoader.cpp	2011-08-31 20:12:31 UTC (rev 94220)
@@ -2996,6 +2996,9 @@
             shouldClose = true;
     }
 
+    if (!shouldClose)
+        m_submittedFormURL = KURL();
+
     return shouldClose;
 }
 

Modified: branches/safari-534.51-branch/Tools/ChangeLog (94219 => 94220)


--- branches/safari-534.51-branch/Tools/ChangeLog	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/ChangeLog	2011-08-31 20:12:31 UTC (rev 94220)
@@ -1,3 +1,72 @@
+2011-08-29  Lucas Forschler  <lforsch...@apple.com>
+
+    Merged 92982
+
+    2011-08-12  Andy Estes  <aes...@apple.com>
+
+            Cancel in onbeforeunload dialog sometime causes a button to stop working.
+            https://bugs.webkit.org/show_bug.cgi?id=26211
+
+            Reviewed by Alexey Proskuryakov.
+
+            Implement a new LayoutTestController method that a test can call to set
+            the return value of DumpRenderTree's beforeunload UI delegate.
+
+            * DumpRenderTree/LayoutTestController.cpp:
+            (LayoutTestController::LayoutTestController): Initialize
+            m_shouldStayOnPageAfterHandlingBeforeUnload.
+            (setShouldStayOnPageAfterHandlingBeforeUnloadCallback): Call
+            LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload().
+            (LayoutTestController::staticFunctions): Register
+            'setShouldStayOnPageAfterHandlingBeforeUnload' as a static function.
+            * DumpRenderTree/LayoutTestController.h: 
+            (LayoutTestController::shouldStayOnPageAfterHandlingBeforeUnload):
+            (LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload):
+            * DumpRenderTree/chromium/LayoutTestController.cpp:
+            (LayoutTestController::LayoutTestController): Initialize
+            m_shouldStayOnPageAfterHandlingBeforeUnload and bind
+            'setShouldStayOnPageAfterHandlingBeforeUnload' to its c++ setter.
+            (LayoutTestController::reset): Reset
+            m_shouldStayOnPageAfterHandlingBeforeUnload to false.
+            (LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload):
+            Set m_shouldStayOnPageAfterHandlingBeforeUnload to the value passed in
+            from _javascript_.
+            * DumpRenderTree/chromium/LayoutTestController.h:
+            (LayoutTestController::shouldStayOnPageAfterHandlingBeforeUnload):
+            * DumpRenderTree/chromium/WebViewHost.cpp:
+            (WebViewHost::runModalBeforeUnloadDialog): Add the correct logging and
+            return the inverse of
+            LayoutTestController::shouldStayOnPageAfterHandlingBeforeUnload().
+            * DumpRenderTree/mac/UIDelegate.mm:
+            (-[UIDelegate webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:]): Ditto.
+            * DumpRenderTree/win/UIDelegate.cpp:
+            (UIDelegate::runBeforeUnloadConfirmPanelWithMessage): Ditto.
+            * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
+            Define setShouldStayOnPageAfterHandlingBeforeUnload().
+            * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+            (WTR::InjectedBundle::postNewBeforeUnloadReturnValue): Post a message
+            to the Test Controller telling it what value it should return in its
+            onbeforeunload UI delegate.
+            * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+            * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+            (WTR::LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload):
+            Call InjectedBundle::postNewBeforeUnloadReturnValue().
+            * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
+            * WebKitTestRunner/TestController.cpp:
+            (WTR::TestController::TestController): Initialize
+            m_beforeUnloadReturnValue to true.
+            (WTR::runBeforeUnloadConfirmPanel): Add the correct logging and return
+            the value of TestController::beforeUnloadReturnValue().
+            (WTR::TestController::resetStateToConsistentValues): Reset
+            m_beforeUnloadReturnValue to true.
+            * WebKitTestRunner/TestController.h:
+            (WTR::TestController::beforeUnloadReturnValue):
+            (WTR::TestController::setBeforeUnloadReturnValue):
+            * WebKitTestRunner/TestInvocation.cpp:
+            (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Handle the
+            message posted from the injected bundle by retrieving the message body
+            as a WKBoolean and calling TestController::setBeforeUnloadReturnValue().
+
 2011-08-09  Gavin Barraclough  <barraclo...@apple.com>
 
         Reviewed by nobody.

Modified: branches/safari-534.51-branch/Tools/DumpRenderTree/LayoutTestController.cpp (94219 => 94220)


--- branches/safari-534.51-branch/Tools/DumpRenderTree/LayoutTestController.cpp	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/DumpRenderTree/LayoutTestController.cpp	2011-08-31 20:12:31 UTC (rev 94220)
@@ -86,6 +86,7 @@
     , m_isPrinting(false)
     , m_deferMainResourceDataLoad(true)
     , m_shouldPaintBrokenImage(true)
+    , m_shouldStayOnPageAfterHandlingBeforeUnload(false)
     , m_testPathOrURL(testPathOrURL)
     , m_expectedPixelHash(expectedPixelHash)
 {
@@ -2172,6 +2173,16 @@
     return JSValueMakeString(context, controller->shadowPseudoId(context, arguments[0]).get());
 }
 
+static JSValueRef setShouldStayOnPageAfterHandlingBeforeUnloadCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    
+    if (argumentCount == 1)
+        controller->setShouldStayOnPageAfterHandlingBeforeUnload(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
 // Static Values
 
 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
@@ -2423,6 +2434,7 @@
         { "originsWithLocalStorage", originsWithLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "shadowPseudoId", shadowPseudoIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setShouldStayOnPageAfterHandlingBeforeUnload", setShouldStayOnPageAfterHandlingBeforeUnloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { 0, 0, 0 }
     };
 

Modified: branches/safari-534.51-branch/Tools/DumpRenderTree/LayoutTestController.h (94219 => 94220)


--- branches/safari-534.51-branch/Tools/DumpRenderTree/LayoutTestController.h	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/DumpRenderTree/LayoutTestController.h	2011-08-31 20:12:31 UTC (rev 94220)
@@ -305,6 +305,9 @@
     void evaluateInWebInspector(long callId, JSStringRef script);
     void evaluateScriptInIsolatedWorld(unsigned worldId, JSObjectRef globalObject, JSStringRef script);
 
+    bool shouldStayOnPageAfterHandlingBeforeUnload() const { return m_shouldStayOnPageAfterHandlingBeforeUnload; }
+    void setShouldStayOnPageAfterHandlingBeforeUnload(bool shouldStayOnPageAfterHandlingBeforeUnload) { m_shouldStayOnPageAfterHandlingBeforeUnload = shouldStayOnPageAfterHandlingBeforeUnload; }
+
     void setPOSIXLocale(JSStringRef locale);
 
     void setWebViewEditable(bool);
@@ -393,6 +396,7 @@
     bool m_isPrinting;
     bool m_deferMainResourceDataLoad;
     bool m_shouldPaintBrokenImage;
+    bool m_shouldStayOnPageAfterHandlingBeforeUnload;
 
     std::string m_authenticationUsername;
     std::string m_authenticationPassword; 

Modified: branches/safari-534.51-branch/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (94219 => 94220)


--- branches/safari-534.51-branch/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-08-31 20:12:31 UTC (rev 94220)
@@ -75,6 +75,7 @@
     , m_deferMainResourceDataLoad(false)
     , m_showDebugLayerTree(false)
     , m_workQueue(this)
+    , m_shouldStayOnPageAfterHandlingBeforeUnload(false)
 {
 
     // Initialize the map that associates methods of this class with the names
@@ -213,6 +214,7 @@
     bindMethod("deleteLocalStorageForOrigin", &LayoutTestController::deleteLocalStorageForOrigin);
     bindMethod("observeStorageTrackerNotifications", &LayoutTestController::observeStorageTrackerNotifications);
     bindMethod("syncLocalStorage", &LayoutTestController::syncLocalStorage);
+    bindMethod("setShouldStayOnPageAfterHandlingBeforeUnload", &LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload);
     
     // The fallback method is called when an unknown method is invoked.
     bindFallbackMethod(&LayoutTestController::fallbackMethod);
@@ -600,6 +602,7 @@
         m_closeRemainingWindows = true;
     m_workQueue.reset();
     m_taskList.revokeAll();
+    m_shouldStayOnPageAfterHandlingBeforeUnload = false;
 }
 
 void LayoutTestController::locationChangeDone()
@@ -1803,6 +1806,14 @@
     // Not Implemented
 }
 
+void LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() == 1 && arguments[0].isBool())
+        m_shouldStayOnPageAfterHandlingBeforeUnload = arguments[0].toBoolean();
+
+    result->setNull();
+}
+
 void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() > 0 && arguments[0].isBool()) {

Modified: branches/safari-534.51-branch/Tools/DumpRenderTree/chromium/LayoutTestController.h (94219 => 94220)


--- branches/safari-534.51-branch/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-08-31 20:12:31 UTC (rev 94220)
@@ -375,6 +375,8 @@
     void setPageVisibility(const CppArgumentList&, CppVariant*);
     void resetPageVisibility(const CppArgumentList&, CppVariant*);
 
+    void setShouldStayOnPageAfterHandlingBeforeUnload(const CppArgumentList&, CppVariant*);
+
 public:
     // The following methods are not exposed to _javascript_.
     void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); }
@@ -435,6 +437,8 @@
 
     TaskList* taskList() { return &m_taskList; }
 
+    bool shouldStayOnPageAfterHandlingBeforeUnload() const { return m_shouldStayOnPageAfterHandlingBeforeUnload; }
+
 private:
     friend class WorkItem;
     friend class WorkQueue;
@@ -597,6 +601,8 @@
     WebKit::WebURL m_userStyleSheetLocation;
 
     OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock;
+
+    bool m_shouldStayOnPageAfterHandlingBeforeUnload;
 };
 
 #endif // LayoutTestController_h

Modified: branches/safari-534.51-branch/Tools/DumpRenderTree/chromium/WebViewHost.cpp (94219 => 94220)


--- branches/safari-534.51-branch/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2011-08-31 20:12:31 UTC (rev 94220)
@@ -467,9 +467,10 @@
     return true;
 }
 
-bool WebViewHost::runModalBeforeUnloadDialog(WebFrame*, const WebString&)
+bool WebViewHost::runModalBeforeUnloadDialog(WebFrame*, const WebString& message)
 {
-    return true; // Allow window closure.
+    printf("CONFIRM NAVIGATION: %s\n", message.utf8().data());
+    return !layoutTestController()->shouldStayOnPageAfterHandlingBeforeUnload();
 }
 
 void WebViewHost::showContextMenu(WebFrame*, const WebContextMenuData& contextMenuData)

Modified: branches/safari-534.51-branch/Tools/DumpRenderTree/mac/UIDelegate.mm (94219 => 94220)


--- branches/safari-534.51-branch/Tools/DumpRenderTree/mac/UIDelegate.mm	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/DumpRenderTree/mac/UIDelegate.mm	2011-08-31 20:12:31 UTC (rev 94220)
@@ -107,7 +107,8 @@
 {
     if (!done)
         printf("CONFIRM NAVIGATION: %s\n", [message UTF8String]);
-    return YES;
+    
+    return !gLayoutTestController->shouldStayOnPageAfterHandlingBeforeUnload();
 }
 
 

Modified: branches/safari-534.51-branch/Tools/DumpRenderTree/win/UIDelegate.cpp (94219 => 94220)


--- branches/safari-534.51-branch/Tools/DumpRenderTree/win/UIDelegate.cpp	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/DumpRenderTree/win/UIDelegate.cpp	2011-08-31 20:12:31 UTC (rev 94220)
@@ -465,14 +465,15 @@
 
 HRESULT STDMETHODCALLTYPE UIDelegate::runBeforeUnloadConfirmPanelWithMessage( 
     /* [in] */ IWebView* /*sender*/,
-    /* [in] */ BSTR /*message*/,
+    /* [in] */ BSTR message,
     /* [in] */ IWebFrame* /*initiatedByFrame*/,
     /* [retval][out] */ BOOL* result)
 {
     if (!result)
         return E_POINTER;
-    *result = TRUE;
-    return E_NOTIMPL;
+    printf("CONFIRM NAVIGATION: %S\n", message ? message : L"");
+    *result = !gLayoutTestController->shouldStayOnPageAfterHandlingBeforeUnload();
+    return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE UIDelegate::webViewAddMessageToConsole( 

Modified: branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl (94219 => 94220)


--- branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl	2011-08-31 20:12:31 UTC (rev 94220)
@@ -112,6 +112,8 @@
         void setPOSIXLocale(in DOMString locale);
 
         void setWillSendRequestReturnsNull(in boolean flag);
+        
+        void setShouldStayOnPageAfterHandlingBeforeUnload(in boolean flag);
     };
 
 }

Modified: branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (94219 => 94220)


--- branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2011-08-31 20:12:31 UTC (rev 94220)
@@ -228,5 +228,12 @@
     for (size_t i = 0; i < size; ++i)
         m_pages[i]->dumpBackForwardList();
 }
+    
+void InjectedBundle::postNewBeforeUnloadReturnValue(bool value)
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("BeforeUnloadReturnValue"));
+    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
+    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+}
 
 } // namespace WTR

Modified: branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (94219 => 94220)


--- branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2011-08-31 20:12:31 UTC (rev 94220)
@@ -71,6 +71,8 @@
     void setTopLoadingFrame(WKBundleFrameRef frame) { m_topLoadingFrame = frame; }
 
     bool shouldDumpPixels() const { return m_dumpPixels; }
+    
+    void postNewBeforeUnloadReturnValue(bool);
 
 private:
     InjectedBundle();

Modified: branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp (94219 => 94220)


--- branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2011-08-31 20:12:31 UTC (rev 94220)
@@ -521,4 +521,10 @@
     setlocale(LC_ALL, localeBuf);
 }
 
+
+void LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload(bool shouldStayOnPage)
+{
+    InjectedBundle::shared().postNewBeforeUnloadReturnValue(!shouldStayOnPage);
+}
+
 } // namespace WTR

Modified: branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h (94219 => 94220)


--- branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h	2011-08-31 20:12:31 UTC (rev 94220)
@@ -162,6 +162,8 @@
     bool willSendRequestReturnsNull() { return m_willSendRequestReturnsNull; }
     void setWillSendRequestReturnsNull(bool f) { m_willSendRequestReturnsNull = f; }
 
+    void setShouldStayOnPageAfterHandlingBeforeUnload(bool);
+
 private:
     static const double waitToDumpWatchdogTimerInterval;
 

Modified: branches/safari-534.51-branch/Tools/WebKitTestRunner/TestController.cpp (94219 => 94220)


--- branches/safari-534.51-branch/Tools/WebKitTestRunner/TestController.cpp	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/WebKitTestRunner/TestController.cpp	2011-08-31 20:12:31 UTC (rev 94220)
@@ -68,6 +68,7 @@
     , m_shortTimeout(defaultShortTimeout)
     , m_didPrintWebProcessCrashedMessage(false)
     , m_shouldExitWhenWebProcessCrashes(true)
+    , m_beforeUnloadReturnValue(true)
 {
     initialize(argc, argv);
     controller = this;
@@ -105,8 +106,9 @@
 
 static bool runBeforeUnloadConfirmPanel(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo)
 {
-    printf("%s\n", toSTD(message).c_str());
-    return true;
+    TestController* testController = static_cast<TestController*>(const_cast<void*>(clientInfo));
+    printf("CONFIRM NAVIGATION: %s\n", toSTD(message).c_str());
+    return testController->beforeUnloadReturnValue();
 }
 
 static unsigned long long exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef, WKStringRef, unsigned long long, unsigned long long, unsigned long long, unsigned long long, const void*)
@@ -358,6 +360,8 @@
 bool TestController::resetStateToConsistentValues()
 {
     m_state = Resetting;
+    
+    m_beforeUnloadReturnValue = true;
 
     WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("Reset"));
     WKRetainPtr<WKMutableDictionaryRef> resetMessageBody = adoptWK(WKMutableDictionaryCreate());

Modified: branches/safari-534.51-branch/Tools/WebKitTestRunner/TestController.h (94219 => 94220)


--- branches/safari-534.51-branch/Tools/WebKitTestRunner/TestController.h	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/WebKitTestRunner/TestController.h	2011-08-31 20:12:31 UTC (rev 94220)
@@ -56,6 +56,9 @@
     enum TimeoutDuration { ShortTimeout, LongTimeout };
     void runUntil(bool& done, TimeoutDuration);
     void notifyDone();
+    
+    bool beforeUnloadReturnValue() const { return m_beforeUnloadReturnValue; }
+    void setBeforeUnloadReturnValue(bool value) { m_beforeUnloadReturnValue = value; }
 
 private:
     void initialize(int argc, const char* argv[]);
@@ -121,6 +124,8 @@
 
     bool m_didPrintWebProcessCrashedMessage;
     bool m_shouldExitWhenWebProcessCrashes;
+    
+    bool m_beforeUnloadReturnValue;
 };
 
 } // namespace WTR

Modified: branches/safari-534.51-branch/Tools/WebKitTestRunner/TestInvocation.cpp (94219 => 94220)


--- branches/safari-534.51-branch/Tools/WebKitTestRunner/TestInvocation.cpp	2011-08-31 20:09:35 UTC (rev 94219)
+++ branches/safari-534.51-branch/Tools/WebKitTestRunner/TestInvocation.cpp	2011-08-31 20:12:31 UTC (rev 94220)
@@ -223,6 +223,13 @@
         TestController::shared().notifyDone();
         return;
     }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "BeforeUnloadReturnValue")) {
+        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+        WKBooleanRef beforeUnloadReturnValue = static_cast<WKBooleanRef>(messageBody);
+        TestController::shared().setBeforeUnloadReturnValue(WKBooleanGetValue(beforeUnloadReturnValue));
+        return;
+    }
 
     ASSERT_NOT_REACHED();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to