If the fix made in r77401 is broken, this new test will crash.
Fixes <http://webkit.org/b/53616> <rdar://problem/
8949883>.
Reviewed by Sam Weinig.
Tools:
* TestWebKitAPI/Test.h: Moved the bulk of TEST_ASSERT into a new _TEST_ASSERT_HELPER macro.
Added a new TEST_ASSERT_RETURN macro that can be used in functions with a return value.
* TestWebKitAPI/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp: Added.
(TestWebKitAPI::didFinishLoadForFrame): Record that the load is finished.
(TestWebKitAPI::setPageLoaderClient): Hook up the loader client.
(TestWebKitAPI::createSessionStateContainingFormData): Load simple-form.html, submit the
form, an return the session state data.
(TestWebKitAPI::TEST): Create some session state that contains form data from one WKPage,
and restore it into another WKPage.
* TestWebKitAPI/Tests/WebKit2/simple-form.html: Added.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/win/TestWebKitAPI.vcproj:
* TestWebKitAPI/win/copy-resources.cmd:
Added new files.
Source/WebKit2:
Allow passing a null filter callback to WKPageCopySessionState
* UIProcess/cf/WebBackForwardListCF.cpp:
(WebKit::WebBackForwardList::createCFDictionaryRepresentation): Check if the filter is null
before calling it.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77672
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-02-04 Adam Roben <aroben@apple.com>
+
+ Allow passing a null filter callback to WKPageCopySessionState
+
+ WebKit2 part of <http://webkit.org/b/53616> <rdar://problem/8949883>.
+
+ Reviewed by Sam Weinig.
+
+ * UIProcess/cf/WebBackForwardListCF.cpp:
+ (WebKit::WebBackForwardList::createCFDictionaryRepresentation): Check if the filter is null
+ before calling it.
+
2011-02-04 Brian Weinstein <bweinstein@apple.com>
Reviewed by John Sullivan.
for (size_t i = 0; i < m_entries.size(); ++i) {
RefPtr<WebURL> webURL = WebURL::create(m_entries[i]->url());
- if (!filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context))
+ if (filter && !filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context))
continue;
RetainPtr<CFStringRef> url(AdoptCF, m_entries[i]->url().createCFString());
+2011-02-04 Adam Roben <aroben@apple.com>
+
+ Add a test case for encode/decode of FormData/FormDataElement
+
+ If the fix made in r77401 is broken, this new test will crash.
+
+ Fixes <http://webkit.org/b/53616> <rdar://problem/8949883>.
+
+ Reviewed by Sam Weinig.
+
+ * TestWebKitAPI/Test.h: Moved the bulk of TEST_ASSERT into a new _TEST_ASSERT_HELPER macro.
+ Added a new TEST_ASSERT_RETURN macro that can be used in functions with a return value.
+
+ * TestWebKitAPI/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp: Added.
+ (TestWebKitAPI::didFinishLoadForFrame): Record that the load is finished.
+ (TestWebKitAPI::setPageLoaderClient): Hook up the loader client.
+ (TestWebKitAPI::createSessionStateContainingFormData): Load simple-form.html, submit the
+ form, an return the session state data.
+ (TestWebKitAPI::TEST): Create some session state that contains form data from one WKPage,
+ and restore it into another WKPage.
+
+ * TestWebKitAPI/Tests/WebKit2/simple-form.html: Added.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/win/TestWebKitAPI.vcproj:
+ * TestWebKitAPI/win/copy-resources.cmd:
+ Added new files.
+
2011-02-04 Adam Roben <aroben@apple.com>
Move code to run JavaScript tests into its own files
\
void TEST_CLASS_NAME(testSuite, testCaseName)::run()
-#define TEST_ASSERT(expression) do { if (!(expression)) { TestsController::shared().testFailed(__FILE__, __LINE__, #expression); return; } } while (0)
+#define _TEST_ASSERT_HELPER(expression, returnStatement) do { if (!(expression)) { TestsController::shared().testFailed(__FILE__, __LINE__, #expression); returnStatement; } } while (0)
+#define TEST_ASSERT(expression) _TEST_ASSERT_HELPER(expression, return)
+#define TEST_ASSERT_RETURN(expression, returnValue) _TEST_ASSERT_HELPER(expression, return (returnValue))
} // namespace TestWebKitAPI
C02B77F2126612140026BF0F /* SpacebarScrolling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */; };
C02B7854126613AE0026BF0F /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C02B7853126613AE0026BF0F /* Carbon.framework */; };
C0ADBE7C12FCA4D000D2C129 /* JavaScriptTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0ADBE7A12FCA4D000D2C129 /* JavaScriptTest.cpp */; };
+ C0ADBE8312FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */; };
+ C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C0ADBE8412FCA6B600D2C129 /* simple-form.html */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
BCBD3737125ABBEB00D2C29F /* icon.png in Copy Resources */,
1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */,
BC909784125571CF00083756 /* simple.html in Copy Resources */,
+ C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */,
C01A23F21266156700C9ED55 /* spacebar-scrolling.html in Copy Resources */,
BC2D006412AA04CE00E732A3 /* file-with-anchor.html in Copy Resources */,
);
C02B7882126615410026BF0F /* spacebar-scrolling.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "spacebar-scrolling.html"; sourceTree = "<group>"; };
C0ADBE7A12FCA4D000D2C129 /* JavaScriptTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JavaScriptTest.cpp; sourceTree = "<group>"; };
C0ADBE7B12FCA4D000D2C129 /* JavaScriptTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptTest.h; sourceTree = "<group>"; };
+ C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreSessionStateContainingFormData.cpp; sourceTree = "<group>"; };
+ C0ADBE8412FCA6B600D2C129 /* simple-form.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-form.html"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
BC909779125571AB00083756 /* PageLoadBasic.cpp */,
BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */,
333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */,
+ C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */,
C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */,
BC7B619A1299FE9E00D174A4 /* WKPreferences.cpp */,
BC90995D12567BC100083756 /* WKString.cpp */,
1A02C84B125D4A5E00E3F4BD /* find.html */,
BCBD372E125ABBE600D2C29F /* icon.png */,
BC909778125571AB00083756 /* simple.html */,
+ C0ADBE8412FCA6B600D2C129 /* simple-form.html */,
C02B7882126615410026BF0F /* spacebar-scrolling.html */,
);
name = Resources;
BC7B61AA129A038700D174A4 /* WKPreferences.cpp in Sources */,
BC2D004912A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */,
C0ADBE7C12FCA4D000D2C129 /* JavaScriptTest.cpp in Sources */,
+ C0ADBE8312FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- /dev/null
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "Test.h"
+
+#include "JavaScriptTest.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+
+namespace TestWebKitAPI {
+
+static bool didFinishLoad;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+ didFinishLoad = true;
+}
+
+static void setPageLoaderClient(WKPageRef page)
+{
+ WKPageLoaderClient loaderClient;
+ memset(&loaderClient, 0, sizeof(loaderClient));
+ loaderClient.version = 0;
+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+
+ WKPageSetPageLoaderClient(page, &loaderClient);
+}
+
+static WKRetainPtr<WKDataRef> createSessionStateContainingFormData(WKContextRef context)
+{
+ PlatformWebView webView(context);
+ setPageLoaderClient(webView.page());
+
+ WKPageLoadURL(webView.page(), Util::adoptWK(Util::createURLForResource("simple-form", "html")).get());
+ Util::run(&didFinishLoad);
+ didFinishLoad = false;
+
+ TEST_ASSERT_RETURN(runJSTest(webView.page(), "submitForm()", "undefined"), 0);
+ Util::run(&didFinishLoad);
+ didFinishLoad = false;
+
+ return Util::adoptWK(WKPageCopySessionState(webView.page(), 0, 0));
+}
+
+TEST(WebKit2, RestoreSessionStateContainingFormData)
+{
+ WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+ // FIXME: Once <rdar://problem/8708435> is fixed, we can move the creation of this
+ // PlatformWebView after the call to createSessionStaetContainingFormData. Until then, it must
+ // remain here to avoid a race condition between the UI and web processes.
+ PlatformWebView webView(context.get());
+ setPageLoaderClient(webView.page());
+
+ WKRetainPtr<WKDataRef> data = createSessionStateContainingFormData(context.get());
+ TEST_ASSERT(data);
+
+ WKPageRestoreFromSessionState(webView.page(), data.get());
+ Util::run(&didFinishLoad);
+
+ TEST_ASSERT(WKPageCanGoBack(webView.page()));
+}
+
+} // namespace TestWebKitAPI
--- /dev/null
+<!DOCTYPE html>
+<script>
+function submitForm()
+{
+ document.forms[0].submit();
+}
+</script>
+<form method=post>
+<input name=foo value="Some unimportant data">
+<input type=submit>
+</form>
RelativePath="..\Tests\WebKit2\PreventEmptyUserAgent.cpp"
>
</File>
+ <File
+ RelativePath="..\Tests\WebKit2\RestoreSessionStateContainingFormData.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Tests\WebKit2\simple-form.html"
+ >
+ </File>
<File
RelativePath="..\Tests\WebKit2\simple.html"
>
..\Tests\WebKit2\find.html
..\Tests\WebKit2\icon.png
..\Tests\WebKit2\simple.html
+ ..\Tests\WebKit2\simple-form.html
..\Tests\WebKit2\spacebar-scrolling.html
) do (
xcopy /y /d %%f "%ResourcesDirectory%"