Diff
Modified: trunk/Source/WebCore/ChangeLog (217866 => 217867)
--- trunk/Source/WebCore/ChangeLog 2017-06-06 23:06:12 UTC (rev 217866)
+++ trunk/Source/WebCore/ChangeLog 2017-06-06 23:31:25 UTC (rev 217867)
@@ -1,3 +1,26 @@
+2017-06-06 Chris Dumez <[email protected]>
+
+ RELEASE_ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)) hit in convertEnumerationToJS<WebCore::History::ScrollRestoration>()
+ https://bugs.webkit.org/show_bug.cgi?id=173033
+ <rdar://problem/32591099>
+
+ Reviewed by Simon Fraser.
+
+ History::scrollRestoration() was returning a bad value because HistoryItem::m_shouldRestoreScrollPosition
+ was initialized from FrameState::shouldRestoreScrollPosition member, which was not initialized when
+ restored from the legacy session restore API.
+
+ Tests: WebKit2.RestoreSessionStateContainingScrollRestoration* API tests.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateEnumerationImplementationContent):
+ Drop the RELEASE_ASSERT that was added to debug this and use the regular debug ASSERT.
+
+ * history/HistoryItem.cpp:
+ (WebCore::HistoryItem::setShouldRestoreScrollPosition):
+ Make sure we notify that the HistoryItem has changed when setShouldRestoreScrollPosition()
+ is called.
+
2017-06-06 Darin Adler <[email protected]>
Update to slightly stricter rules for custom element names from more recent standard draft
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (217866 => 217867)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2017-06-06 23:06:12 UTC (rev 217866)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2017-06-06 23:31:25 UTC (rev 217867)
@@ -1727,12 +1727,7 @@
$result .= " static_assert(static_cast<size_t>(${className}::$enumerationValueName) == $index, \"${className}::$enumerationValueName is not $index as expected\");\n";
$index++;
}
- # FIXME: This is a debugging aid for <rdar://problem/31193201>. Please revert when no longer needed.
- if ($className eq "History::ScrollRestoration") {
- $result .= " RELEASE_ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));\n";
- } else {
- $result .= " ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));\n";
- }
+ $result .= " ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));\n";
$result .= " return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);\n";
$result .= "}\n\n";
Modified: trunk/Source/WebCore/history/HistoryItem.cpp (217866 => 217867)
--- trunk/Source/WebCore/history/HistoryItem.cpp 2017-06-06 23:06:12 UTC (rev 217866)
+++ trunk/Source/WebCore/history/HistoryItem.cpp 2017-06-06 23:31:25 UTC (rev 217867)
@@ -271,6 +271,7 @@
void HistoryItem::setShouldRestoreScrollPosition(bool shouldRestore)
{
m_shouldRestoreScrollPosition = shouldRestore;
+ notifyHistoryItemChanged(this);
}
float HistoryItem::pageScaleFactor() const
Modified: trunk/Source/WebKit2/ChangeLog (217866 => 217867)
--- trunk/Source/WebKit2/ChangeLog 2017-06-06 23:06:12 UTC (rev 217866)
+++ trunk/Source/WebKit2/ChangeLog 2017-06-06 23:31:25 UTC (rev 217867)
@@ -1,3 +1,20 @@
+2017-06-06 Chris Dumez <[email protected]>
+
+ RELEASE_ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)) hit in convertEnumerationToJS<WebCore::History::ScrollRestoration>()
+ https://bugs.webkit.org/show_bug.cgi?id=173033
+ <rdar://problem/32591099>
+
+ Reviewed by Simon Fraser.
+
+ * Shared/SessionState.h:
+ Make sure FrameState::shouldRestoreScrollPosition and other struct members are always
+ intialized.
+
+ * UIProcess/mac/LegacySessionStateCoding.cpp:
+ (WebKit::encodeFrameStateNode):
+ (WebKit::decodeBackForwardTreeNode):
+ Make sure FrameState::shouldRestoreScrollPosition is properly encoded / decoded.
+
2017-06-06 Andy Estes <[email protected]>
REGRESSION (r199558): WKWebView upload file which name contains Chinese character results in garbled code
Modified: trunk/Source/WebKit2/Shared/SessionState.h (217866 => 217867)
--- trunk/Source/WebKit2/Shared/SessionState.h 2017-06-06 23:06:12 UTC (rev 217866)
+++ trunk/Source/WebKit2/Shared/SessionState.h 2017-06-06 23:31:25 UTC (rev 217867)
@@ -92,12 +92,12 @@
Vector<String> documentState;
std::optional<Vector<uint8_t>> stateObjectData;
- int64_t documentSequenceNumber;
- int64_t itemSequenceNumber;
+ int64_t documentSequenceNumber { 0 };
+ int64_t itemSequenceNumber { 0 };
WebCore::IntPoint scrollPosition;
- bool shouldRestoreScrollPosition;
- float pageScaleFactor;
+ bool shouldRestoreScrollPosition { true };
+ float pageScaleFactor { 0 };
std::optional<HTTPBody> httpBody;
@@ -107,7 +107,7 @@
WebCore::IntRect unobscuredContentRect;
WebCore::FloatSize minimumLayoutSizeInScrollViewCoordinates;
WebCore::IntSize contentSize;
- bool scaleIsInitial = false;
+ bool scaleIsInitial { false };
#endif
Vector<FrameState> children;
Modified: trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp (217866 => 217867)
--- trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp 2017-06-06 23:06:12 UTC (rev 217866)
+++ trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp 2017-06-06 23:31:25 UTC (rev 217867)
@@ -346,6 +346,7 @@
encoder << frameState.scrollPosition.x();
encoder << frameState.scrollPosition.y();
+ encoder << frameState.shouldRestoreScrollPosition;
encoder << frameState.pageScaleFactor;
encoder << !!frameState.stateObjectData;
@@ -928,6 +929,7 @@
frameState.scrollPosition = WebCore::IntPoint(scrollPositionX, scrollPositionY);
+ decoder >> frameState.shouldRestoreScrollPosition;
decoder >> frameState.pageScaleFactor;
bool hasStateObject;
Modified: trunk/Tools/ChangeLog (217866 => 217867)
--- trunk/Tools/ChangeLog 2017-06-06 23:06:12 UTC (rev 217866)
+++ trunk/Tools/ChangeLog 2017-06-06 23:31:25 UTC (rev 217867)
@@ -1,3 +1,21 @@
+2017-06-06 Chris Dumez <[email protected]>
+
+ RELEASE_ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)) hit in convertEnumerationToJS<WebCore::History::ScrollRestoration>()
+ https://bugs.webkit.org/show_bug.cgi?id=173033
+ <rdar://problem/32591099>
+
+ Reviewed by Simon Fraser.
+
+ Add API test coverage to make sure History's scrollRestoration is properly saved / restored via the
+ WKPageCopySessionState() / WKPageRestoreFromSessionState() C API.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2/RestoreSessionState.cpp: Added.
+ (TestWebKitAPI::didFinishLoadForFrame):
+ (TestWebKitAPI::setPageLoaderClient):
+ (TestWebKitAPI::createSessionStateDataContainingScrollRestoration):
+ (TestWebKitAPI::TEST):
+
2017-06-06 Andy Estes <[email protected]>
REGRESSION (r199558): WKWebView upload file which name contains Chinese character results in garbled code
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (217866 => 217867)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-06-06 23:06:12 UTC (rev 217866)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-06-06 23:31:25 UTC (rev 217867)
@@ -481,6 +481,7 @@
835CF9671D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */; };
8361F1781E610B4E00759B25 /* link-with-download-attribute-with-slashes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 8361F1771E610B2100759B25 /* link-with-download-attribute-with-slashes.html */; };
837A35F11D9A1E7D00663C57 /* DownloadRequestBlobURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */; };
+ 83B6DE6F1EE75221001E792F /* RestoreSessionState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B6DE6E1EE7520F001E792F /* RestoreSessionState.cpp */; };
8E4A85371E1D1AB200F53B0F /* GridPosition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8E4A85361E1D1AA100F53B0F /* GridPosition.cpp */; };
930AD402150698D00067970F /* lots-of-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 930AD401150698B30067970F /* lots-of-text.html */; };
9329AA291DE3F81E003ABD07 /* TextBreakIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9329AA281DE3F81E003ABD07 /* TextBreakIterator.cpp */; };
@@ -1283,6 +1284,7 @@
835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreSessionStateWithoutNavigation.cpp; sourceTree = "<group>"; };
8361F1771E610B2100759B25 /* link-with-download-attribute-with-slashes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "link-with-download-attribute-with-slashes.html"; sourceTree = "<group>"; };
837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestBlobURL.html; sourceTree = "<group>"; };
+ 83B6DE6E1EE7520F001E792F /* RestoreSessionState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreSessionState.cpp; sourceTree = "<group>"; };
83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLParserIdioms.cpp; sourceTree = "<group>"; };
86BD19971A2DB05B006DCF0A /* RefCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefCounter.cpp; sourceTree = "<group>"; };
8A2C750D16CED9550024F352 /* ResizeWindowAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeWindowAfterCrash.cpp; sourceTree = "<group>"; };
@@ -2176,6 +2178,7 @@
8A2C750D16CED9550024F352 /* ResizeWindowAfterCrash.cpp */,
C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */,
C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */,
+ 83B6DE6E1EE7520F001E792F /* RestoreSessionState.cpp */,
C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */,
835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */,
2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */,
@@ -3154,6 +3157,7 @@
F4FA91811E61849B007B8C1D /* WKWebViewSelectionTests.mm in Sources */,
0799C3491EBA2D7B003B7532 /* UserMediaDisabled.mm in Sources */,
93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */,
+ 83B6DE6F1EE75221001E792F /* RestoreSessionState.cpp in Sources */,
9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */,
9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionState.cpp (0 => 217867)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionState.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionState.cpp 2017-06-06 23:31:25 UTC (rev 217867)
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2017 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 "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "_javascript_Test.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <WebKit/WKSessionStateRef.h>
+
+namespace TestWebKitAPI {
+
+static bool didFinishLoad;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+ didFinishLoad = true;
+}
+
+static void setPageLoaderClient(WKPageRef page)
+{
+ WKPageLoaderClientV0 loaderClient;
+ memset(&loaderClient, 0, sizeof(loaderClient));
+
+ loaderClient.base.version = 0;
+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+
+ WKPageSetPageLoaderClient(page, &loaderClient.base);
+}
+
+static WKRetainPtr<WKDataRef> createSessionStateDataContainingScrollRestoration(WKContextRef context, std::function<void(WKPageRef)> apply)
+{
+ PlatformWebView webView(context);
+ setPageLoaderClient(webView.page());
+
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple-form", "html")).get());
+ Util::run(&didFinishLoad);
+ didFinishLoad = false;
+
+ apply(webView.page());
+
+ auto sessionState = adoptWK(static_cast<WKSessionStateRef>(WKPageCopySessionState(webView.page(), reinterpret_cast<void*>(1), nullptr)));
+ return adoptWK(WKSessionStateCopyData(sessionState.get()));
+}
+
+TEST(WebKit2, RestoreSessionStateContainingScrollRestorationManual)
+{
+ WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+ PlatformWebView webView(context.get());
+ setPageLoaderClient(webView.page());
+
+ WKRetainPtr<WKDataRef> data = "" [](WKPageRef page) {
+ EXPECT_JS_EQ(page, "history.scrollRestoration = 'manual'", "manual");
+ });
+ EXPECT_NOT_NULL(data);
+
+ auto sessionState = adoptWK(WKSessionStateCreateFromData(data.get()));
+ WKPageRestoreFromSessionState(webView.page(), sessionState.get());
+
+ Util::run(&didFinishLoad);
+
+ EXPECT_JS_EQ(webView.page(), "history.scrollRestoration", "manual");
+}
+
+TEST(WebKit2, RestoreSessionStateContainingScrollRestorationAuto)
+{
+ WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+ PlatformWebView webView(context.get());
+ setPageLoaderClient(webView.page());
+
+ WKRetainPtr<WKDataRef> data = "" [](WKPageRef page) {
+ EXPECT_JS_EQ(page, "history.scrollRestoration = 'auto'", "auto");
+ });
+ EXPECT_NOT_NULL(data);
+
+ auto sessionState = adoptWK(WKSessionStateCreateFromData(data.get()));
+ WKPageRestoreFromSessionState(webView.page(), sessionState.get());
+
+ Util::run(&didFinishLoad);
+
+ EXPECT_JS_EQ(webView.page(), "history.scrollRestoration", "auto");
+}
+
+TEST(WebKit2, RestoreSessionStateContainingScrollRestorationDefault)
+{
+ WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+ PlatformWebView webView(context.get());
+ setPageLoaderClient(webView.page());
+
+ WKRetainPtr<WKDataRef> data = "" [](WKPageRef) {
+ });
+ EXPECT_NOT_NULL(data);
+
+ auto sessionState = adoptWK(WKSessionStateCreateFromData(data.get()));
+ WKPageRestoreFromSessionState(webView.page(), sessionState.get());
+
+ Util::run(&didFinishLoad);
+
+ EXPECT_JS_EQ(webView.page(), "history.scrollRestoration", "auto");
+}
+
+} // namespace TestWebKitAPI
+
+#endif