Diff
Modified: trunk/Source/WebKit/ChangeLog (252458 => 252459)
--- trunk/Source/WebKit/ChangeLog 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/ChangeLog 2019-11-14 18:09:30 UTC (rev 252459)
@@ -1,5 +1,38 @@
2019-11-14 Brady Eidson <[email protected]>
+ Summary: WKWebView is missing an equivalent to WebKit 1's API to set the media style.
+ <rdar://problem/49862107> and https://bugs.webkit.org/show_bug.cgi?id=203974
+
+ Reviewed by Alex Christensen.
+
+ Covered by new API test.
+
+ This is basically:
+ - Expose a read/write property on WKWebView.
+ - Pipe the new media type to the WebProcess.
+ - Force a style recalc.
+
+ * UIProcess/API/Cocoa/WKWebView.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView setMediaType:]):
+ (-[WKWebView mediaType]):
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::setOverriddenMediaType):
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::overriddenMediaType const):
+
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::overrideMediaType const):
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::setOverriddenMediaType):
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::overriddenMediaType const):
+ * WebProcess/WebPage/WebPage.messages.in:
+
+2019-11-14 Brady Eidson <[email protected]>
+
pageZoom/setPageZoom: should not be in a Mac-only part of WKWebView.mm
https://bugs.webkit.org/show_bug.cgi?id=204128
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (252458 => 252459)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2019-11-14 18:09:30 UTC (rev 252459)
@@ -129,6 +129,7 @@
#endif
encoder << backgroundColor;
encoder << oldPageID;
+ encoder << overriddenMediaType;
}
Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decoder& decoder)
@@ -393,6 +394,9 @@
return WTF::nullopt;
parameters.oldPageID = WTFMove(*oldPageID);
+ if (!decoder.decode(parameters.overriddenMediaType))
+ return WTF::nullopt;
+
return parameters;
}
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (252458 => 252459)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2019-11-14 18:09:30 UTC (rev 252459)
@@ -200,6 +200,8 @@
Optional<WebCore::Color> backgroundColor;
Optional<WebCore::PageIdentifier> oldPageID;
+
+ String overriddenMediaType;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h (252458 => 252459)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h 2019-11-14 18:09:30 UTC (rev 252459)
@@ -320,6 +320,14 @@
*/
+ (BOOL)handlesURLScheme:(NSString *)urlScheme WK_API_AVAILABLE(macos(10.13), ios(11.0));
+
+/* @abstract The media type for the WKWebView
+@discussion The value of mediaType will override the normal value of the CSS media property.
+ Setting the value to nil will restore the normal value.
+ The default value is nil.
+*/
+@property (nonatomic, null_resettable, copy) NSString *mediaType;
+
#if !TARGET_OS_IPHONE
/* @abstract Returns an NSPrintOperation object configured to print the contents of this WKWebView
@param printInfo The print info object used to configure the resulting print operation.
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (252458 => 252459)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-11-14 18:09:30 UTC (rev 252459)
@@ -4776,6 +4776,16 @@
});
}
+- (void)setMediaType:(NSString *)mediaStyle
+{
+ _page->setOverriddenMediaType(mediaStyle);
+}
+
+- (NSString *)mediaType
+{
+ return _page->overriddenMediaType().isNull() ? nil : (NSString *)_page->overriddenMediaType();
+}
+
@end
@implementation WKWebView (WKPrivate)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (252458 => 252459)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-11-14 18:09:30 UTC (rev 252459)
@@ -7418,6 +7418,8 @@
parameters.needsFontAttributes = m_needsFontAttributes;
parameters.backgroundColor = m_backgroundColor;
+ parameters.overriddenMediaType = m_overriddenMediaType;
+
process.addWebUserContentControllerProxy(m_userContentController, parameters);
return parameters;
@@ -9498,6 +9500,12 @@
m_process->connection()->sendWithAsyncReply(Messages::WebPage::CompleteTextManipulation(itemID, tokens), WTFMove(completionHandler), m_webPageID);
}
+void WebPageProxy::setOverriddenMediaType(const String& mediaType)
+{
+ m_overriddenMediaType = mediaType;
+ m_process->send(Messages::WebPage::SetOverriddenMediaType(mediaType), m_webPageID);
+}
+
} // namespace WebKit
#undef MERGE_WHEEL_EVENTS
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (252458 => 252459)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-11-14 18:09:30 UTC (rev 252459)
@@ -1621,6 +1621,9 @@
void completeTextManipulation(WebCore::TextManipulationController::ItemIdentifier, const Vector<WebCore::TextManipulationController::ManipulationToken>&,
WTF::Function<void (WebCore::TextManipulationController::ManipulationResult)>&&);
+ const String& overriddenMediaType() const { return m_overriddenMediaType; }
+ void setOverriddenMediaType(const String&);
+
private:
WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&);
void platformInitialize();
@@ -2617,6 +2620,8 @@
COMPtr<ID3D11Device1> m_device;
#endif
bool m_isQuotaIncreaseDenied { false };
+
+ String m_overriddenMediaType;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (252458 => 252459)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2019-11-14 18:09:30 UTC (rev 252459)
@@ -1720,7 +1720,11 @@
String WebFrameLoaderClient::overrideMediaType() const
{
- notImplemented();
+ if (m_frame) {
+ if (auto* page = m_frame->page())
+ return page->overriddenMediaType();
+ }
+
return String();
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (252458 => 252459)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-11-14 18:09:30 UTC (rev 252459)
@@ -432,6 +432,7 @@
#if ENABLE(TEXT_AUTOSIZING)
, m_textAutoSizingAdjustmentTimer(*this, &WebPage::textAutoSizingAdjustmentTimerFired)
#endif
+ , m_overriddenMediaType(parameters.overriddenMediaType)
{
ASSERT(m_identifier);
@@ -6825,6 +6826,15 @@
}
#endif
+void WebPage::setOverriddenMediaType(const String& mediaType)
+{
+ if (mediaType == m_overriddenMediaType)
+ return;
+
+ m_overriddenMediaType = mediaType;
+ m_page->setNeedsRecalcStyleInAllFrames();
+}
+
} // namespace WebKit
#undef RELEASE_LOG_IF_ALLOWED
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (252458 => 252459)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-11-14 18:09:30 UTC (rev 252459)
@@ -1240,6 +1240,9 @@
void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&);
#endif
+ const String& overriddenMediaType() const { return m_overriddenMediaType; }
+ void setOverriddenMediaType(const String&);
+
private:
WebPage(WebCore::PageIdentifier, WebPageCreationParameters&&);
@@ -1998,6 +2001,8 @@
#if ENABLE(TEXT_AUTOSIZING)
WebCore::Timer m_textAutoSizingAdjustmentTimer;
#endif
+
+ String m_overriddenMediaType;
};
#if !PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (252458 => 252459)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2019-11-14 18:09:30 UTC (rev 252459)
@@ -581,4 +581,6 @@
StartTextManipulations(Vector<WebCore::TextManipulationController::ExclusionRule> exclusionRules) -> () Async
CompleteTextManipulation(WebCore::TextManipulationController::ItemIdentifier itemID, Vector<WebCore::TextManipulationController::ManipulationToken> tokens) -> (enum:uint8_t WebCore::TextManipulationController::ManipulationResult result) Async
+
+ SetOverriddenMediaType(String mediaType)
}
Modified: trunk/Tools/ChangeLog (252458 => 252459)
--- trunk/Tools/ChangeLog 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Tools/ChangeLog 2019-11-14 18:09:30 UTC (rev 252459)
@@ -1,5 +1,17 @@
2019-11-14 Brady Eidson <[email protected]>
+ Summary: WKWebView is missing an equivalent to WebKit 1's API to set the media style.
+ <rdar://problem/49862107> and https://bugs.webkit.org/show_bug.cgi?id=203974
+
+ Reviewed by Alex Christensen.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/MediaType.mm: Added.
+ (TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
+2019-11-14 Brady Eidson <[email protected]>
+
pageZoom/setPageZoom: should not be in a Mac-only part of WKWebView.mm
https://bugs.webkit.org/show_bug.cgi?id=204128
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (252458 => 252459)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-11-14 18:09:30 UTC (rev 252459)
@@ -290,6 +290,7 @@
51B1EE971C80FAEF0064FB98 /* IndexedDBPersistence-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51B1EE951C80FADD0064FB98 /* IndexedDBPersistence-2.html */; };
51BCEE4E1C84F53B0042C82E /* IndexedDBMultiProcess-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51BCEE4C1C84F52C0042C82E /* IndexedDBMultiProcess-1.html */; };
51BCEE4F1C84F53B0042C82E /* IndexedDBMultiProcess-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51BCEE4D1C84F52C0042C82E /* IndexedDBMultiProcess-2.html */; };
+ 51BE9E662376089F00B4E117 /* MediaType.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51BE9E652376089500B4E117 /* MediaType.mm */; };
51C683DE1EA134E800650183 /* WKURLSchemeHandler-1.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51C683DD1EA134DB00650183 /* WKURLSchemeHandler-1.mm */; };
51C8E1A51F26AF4C00BF731B /* ResourceLoadStatistics.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51C8E1A41F26AC5400BF731B /* ResourceLoadStatistics.mm */; };
51C8E1A91F27F49600BF731B /* EmptyGrandfatheredResourceLoadStatistics.plist in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51C8E1A81F27F47300BF731B /* EmptyGrandfatheredResourceLoadStatistics.plist */; };
@@ -1836,6 +1837,7 @@
51BCEE491C84F4AF0042C82E /* IndexedDBMultiProcess.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBMultiProcess.mm; sourceTree = "<group>"; };
51BCEE4C1C84F52C0042C82E /* IndexedDBMultiProcess-1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBMultiProcess-1.html"; sourceTree = "<group>"; };
51BCEE4D1C84F52C0042C82E /* IndexedDBMultiProcess-2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBMultiProcess-2.html"; sourceTree = "<group>"; };
+ 51BE9E652376089500B4E117 /* MediaType.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaType.mm; sourceTree = "<group>"; };
51C683DD1EA134DB00650183 /* WKURLSchemeHandler-1.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "WKURLSchemeHandler-1.mm"; sourceTree = "<group>"; };
51C8E1A41F26AC5400BF731B /* ResourceLoadStatistics.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceLoadStatistics.mm; sourceTree = "<group>"; };
51C8E1A81F27F47300BF731B /* EmptyGrandfatheredResourceLoadStatistics.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = EmptyGrandfatheredResourceLoadStatistics.plist; sourceTree = "<group>"; };
@@ -2907,6 +2909,7 @@
8C10AF96206467770018FD90 /* LocalStoragePersistence.mm */,
7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */,
07CC7DFD2266330800E39181 /* MediaBufferingPolicy.mm */,
+ 51BE9E652376089500B4E117 /* MediaType.mm */,
5165FE03201EE617009F7EC3 /* MessagePortProviders.mm */,
51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */,
1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
@@ -4722,6 +4725,7 @@
07CC7DFE2266330900E39181 /* MediaBufferingPolicy.mm in Sources */,
CDA315981ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm in Sources */,
CDC9442E1EF1FC080059C3C4 /* MediaStreamTrackDetached.mm in Sources */,
+ 51BE9E662376089F00B4E117 /* MediaType.mm in Sources */,
7CCE7EC51A411A7E00447C4C /* MemoryCacheDisableWithinResourceLoadDelegate.mm in Sources */,
7CCE7EC61A411A7E00447C4C /* MemoryCachePruneWithinResourceLoadDelegate.mm in Sources */,
5C0BF88D1DD5964D00B00328 /* MemoryPressureHandler.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/MediaType.mm (0 => 252459)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/MediaType.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/MediaType.mm 2019-11-14 18:09:30 UTC (rev 252459)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2019 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"
+
+#import "PlatformUtilities.h"
+#import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKFindConfiguration.h>
+#import <WebKit/WKFindResult.h>
+#import <WebKit/WKWebView.h>
+#import <wtf/RetainPtr.h>
+
+NSString *testPage = @"<style>\n"
+"@media screen {\n"
+".ShowForPrinting{\n"
+" visibility: hidden;\n"
+"}\n"
+".ShowForLavaLamp{\n"
+" visibility: hidden;\n"
+"}\n"
+"}\n"
+"@media print {\n"
+".ShowForScreen{\n"
+" visibility: hidden;\n"
+"}\n"
+".ShowForLavaLamp{\n"
+" visibility: hidden;\n"
+"}\n"
+"}\n"
+"@media lavalamp {\n"
+".ShowForScreen {\n"
+" visibility: hidden;\n"
+"}\n"
+".ShowForPrinting{\n"
+" visibility: hidden;\n"
+"}\n"
+"}\n"
+"</style>\n"
+"<div class='ShowForScreen'>Screen</div>\n"
+"<div class='ShowForPrinting'>Print</div>\n"
+"<div class='ShowForLavaLamp'>LavaLamp</div>\n";
+
+TEST(WKWebView, MediaType)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView synchronouslyLoadHTMLString:testPage baseURL:nil];
+
+ EXPECT_TRUE(webView.get().mediaType == nil);
+ EXPECT_TRUE([[[webView stringByEvaluatingJavaScript:@"document.body.innerText"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] isEqualToString:@"Screen"]);
+
+ webView.get().mediaType = @"screen";
+ EXPECT_TRUE([[[webView stringByEvaluatingJavaScript:@"document.body.innerText"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] isEqualToString:@"Screen"]);
+
+ webView.get().mediaType = @"print";
+ EXPECT_TRUE([[[webView stringByEvaluatingJavaScript:@"document.body.innerText"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] isEqualToString:@"Print"]);
+
+ webView.get().mediaType = @"lavalamp";
+ EXPECT_TRUE([[[webView stringByEvaluatingJavaScript:@"document.body.innerText"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] isEqualToString:@"LavaLamp"]);
+}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (252458 => 252459)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2019-11-14 18:07:21 UTC (rev 252458)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2019-11-14 18:09:30 UTC (rev 252459)
@@ -3008,6 +3008,75 @@
#endif // PLATFORM(MAC)
+static const char* mediaTypeBytes = R"PSONRESOURCE(
+<style>
+@media screen {
+.print{
+ visibility: hidden;
+}
+}
+
+@media print {
+.screen{
+ visibility: hidden;
+}
+}
+</style>
+<body>
+<div class="screen">Screen</div>
+<div class="print">Print</div>
+</body>
+)PSONRESOURCE";
+
+TEST(ProcessSwap, MediaTypeAfterSwap)
+{
+ auto processPoolConfiguration = psonProcessPoolConfiguration();
+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setProcessPool:processPool.get()];
+ auto handler = adoptNS([[PSONScheme alloc] init]);
+ [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:mediaTypeBytes];
+ [handler addMappingFromURLString:@"pson://www.apple.com/main.html" toData:mediaTypeBytes];
+ [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
+
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:delegate.get()];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ NSString *innerText = [[webView stringByEvaluatingJavaScript:@"document.body.innerText"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ EXPECT_TRUE([innerText isEqualToString:@"Screen"]);
+
+ webView.get().mediaType = @"print";
+
+ innerText = [[webView stringByEvaluatingJavaScript:@"document.body.innerText"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ EXPECT_TRUE([innerText isEqualToString:@"Print"]);
+
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ innerText = [[webView stringByEvaluatingJavaScript:@"document.body.innerText"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ EXPECT_TRUE([innerText isEqualToString:@"Print"]);
+
+ // Kill the WebProcess, the page should reload automatically and the media type should be maintained.
+ kill([webView _webProcessIdentifier], 9);
+
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ innerText = [[webView stringByEvaluatingJavaScript:@"document.body.innerText"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ EXPECT_TRUE([innerText isEqualToString:@"Print"]);
+}
+
static const char* navigateBeforePageLoadEndBytes = R"PSONRESOURCE(
<body>
<a id="testLink" href=""