<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[244405] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/244405">244405</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2019-04-17 15:47:07 -0700 (Wed, 17 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Link clicks in PDFs shouldn't send referrer headers.
<rdar://problem/21142581> and https://bugs.webkit.org/show_bug.cgi?id=196980

Reviewed by Tim Horton.

Source/WebKit:

* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::clickedLink):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::navigateToPDFLinkWithSimulatedClick):

Source/WebKitLegacy/ios:

* WebView/WebPDFViewPlaceholder.mm:
(-[WebPDFViewPlaceholder simulateClickOnLinkToURL:]):

Source/WebKitLegacy/mac:

* WebView/WebPDFView.mm:
(-[WebPDFView PDFViewWillClickOnLink:withURL:]):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm: Added.
(putPDFBytesCallback):
(emptyReleaseInfoCallback):
(createPDFWithLinkToURL):
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebProcessPluginsPDFPDFPluginmm">trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitLegacyiosChangeLog">trunk/Source/WebKitLegacy/ios/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacyiosWebViewWebPDFViewPlaceholdermm">trunk/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacChangeLog">trunk/Source/WebKitLegacy/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebViewWebPDFViewmm">trunk/Source/WebKitLegacy/mac/WebView/WebPDFView.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaPDFLinkReferrermm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (244404 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-04-17 22:41:08 UTC (rev 244404)
+++ trunk/Source/WebKit/ChangeLog       2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2019-04-17  Brady Eidson  <beidson@apple.com>
+
+        Link clicks in PDFs shouldn't send referrer headers.
+        <rdar://problem/21142581> and https://bugs.webkit.org/show_bug.cgi?id=196980
+
+        Reviewed by Tim Horton.
+
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::clickedLink):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::navigateToPDFLinkWithSimulatedClick):
+
</ins><span class="cx"> 2019-04-17  Andy Estes  <aestes@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] Support multiple file selection in UIDocumentPickerViewController
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessPluginsPDFPDFPluginmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm (244404 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm  2019-04-17 22:41:08 UTC (rev 244404)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm     2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -1732,7 +1732,7 @@
</span><span class="cx">     if (m_lastMouseEvent.type() != WebEvent::NoType)
</span><span class="cx">         coreEvent = MouseEvent::create(eventNames().clickEvent, &frame->windowProxy(), platform(m_lastMouseEvent), 0, 0);
</span><span class="cx"> 
</span><del>-    frame->loader().urlSelected(coreURL, emptyString(), coreEvent.get(), LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, ShouldOpenExternalURLsPolicy::ShouldAllow);
</del><ins>+    frame->loader().urlSelected(coreURL, emptyString(), coreEvent.get(), LockHistory::No, LockBackForwardList::No, NeverSendReferrer, ShouldOpenExternalURLsPolicy::ShouldAllow);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PDFPlugin::setActiveAnnotation(PDFAnnotation *annotation)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (244404 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2019-04-17 22:41:08 UTC (rev 244404)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -1540,7 +1540,7 @@
</span><span class="cx">     auto mouseEvent = MouseEvent::create(eventNames().clickEvent, Event::CanBubble::Yes, Event::IsCancelable::Yes, Event::IsComposed::Yes,
</span><span class="cx">         MonotonicTime::now(), nullptr, singleClick, screenPoint, documentPoint, { }, { }, 0, 0, nullptr, 0, WebCore::NoTap, nullptr);
</span><span class="cx"> 
</span><del>-    mainFrame->loader().urlSelected(mainFrameDocument->completeURL(url), emptyString(), mouseEvent.ptr(), LockHistory::No, LockBackForwardList::No, ShouldSendReferrer::MaybeSendReferrer, ShouldOpenExternalURLsPolicy::ShouldNotAllow);
</del><ins>+    mainFrame->loader().urlSelected(mainFrameDocument->completeURL(url), emptyString(), mouseEvent.ptr(), LockHistory::No, LockBackForwardList::No, ShouldSendReferrer::NeverSendReferrer, ShouldOpenExternalURLsPolicy::ShouldNotAllow);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::stopLoadingFrame(uint64_t frameID)
</span></span></pre></div>
<a id="trunkSourceWebKitLegacyiosChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/ios/ChangeLog (244404 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/ios/ChangeLog  2019-04-17 22:41:08 UTC (rev 244404)
+++ trunk/Source/WebKitLegacy/ios/ChangeLog     2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2019-04-17  Brady Eidson  <beidson@apple.com>
+
+        Link clicks in PDFs shouldn't send referrer headers.
+        <rdar://problem/21142581> and https://bugs.webkit.org/show_bug.cgi?id=196980
+
+        Reviewed by Tim Horton.
+
+        * WebView/WebPDFViewPlaceholder.mm:
+        (-[WebPDFViewPlaceholder simulateClickOnLinkToURL:]):
+
</ins><span class="cx"> 2019-04-10  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: save sheet should be anchored underneath the tab bar when detached
</span></span></pre></div>
<a id="trunkSourceWebKitLegacyiosWebViewWebPDFViewPlaceholdermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm (244404 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm   2019-04-17 22:41:08 UTC (rev 244404)
+++ trunk/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm      2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -470,7 +470,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Call to the frame loader because this is where our security checks are made.
</span><span class="cx">     Frame* frame = core([_dataSource webFrame]);
</span><del>-    FrameLoadRequest frameLoadRequest { *frame->document(), frame->document()->securityOrigin(), { URL }, { }, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Allow, ShouldOpenExternalURLsPolicy::ShouldNotAllow,  InitiatedByMainFrame::Unknown };
</del><ins>+    FrameLoadRequest frameLoadRequest { *frame->document(), frame->document()->securityOrigin(), { URL }, { }, LockHistory::No, LockBackForwardList::No, NeverSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Allow, ShouldOpenExternalURLsPolicy::ShouldNotAllow,  InitiatedByMainFrame::Unknown };
</ins><span class="cx">     frame->loader().loadFrameRequest(WTFMove(frameLoadRequest), event.ptr(), nullptr);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (244404 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/ChangeLog  2019-04-17 22:41:08 UTC (rev 244404)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog     2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2019-04-17  Brady Eidson  <beidson@apple.com>
+
+        Link clicks in PDFs shouldn't send referrer headers.
+        <rdar://problem/21142581> and https://bugs.webkit.org/show_bug.cgi?id=196980
+
+        Reviewed by Tim Horton.
+
+        * WebView/WebPDFView.mm:
+        (-[WebPDFView PDFViewWillClickOnLink:withURL:]):
+
</ins><span class="cx"> 2019-04-10  Said Abou-Hallawa  <sabouhallawa@apple.com>
</span><span class="cx"> 
</span><span class="cx">         requestAnimationFrame should execute before the next frame
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebViewWebPDFViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPDFView.mm (244404 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebView/WebPDFView.mm      2019-04-17 22:41:08 UTC (rev 244404)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPDFView.mm 2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -991,7 +991,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Call to the frame loader because this is where our security checks are made.
</span><span class="cx">     Frame* frame = core([dataSource webFrame]);
</span><del>-    FrameLoadRequest frameLoadRequest { *frame->document(), frame->document()->securityOrigin(), { URL }, { }, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Allow, ShouldOpenExternalURLsPolicy::ShouldNotAllow, InitiatedByMainFrame::Unknown };
</del><ins>+    FrameLoadRequest frameLoadRequest { *frame->document(), frame->document()->securityOrigin(), { URL }, { }, LockHistory::No, LockBackForwardList::No, NeverSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Allow, ShouldOpenExternalURLsPolicy::ShouldNotAllow, InitiatedByMainFrame::Unknown };
</ins><span class="cx">     frame->loader().loadFrameRequest(WTFMove(frameLoadRequest), event.get(), nullptr);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (244404 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-04-17 22:41:08 UTC (rev 244404)
+++ trunk/Tools/ChangeLog       2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2019-04-17  Brady Eidson  <beidson@apple.com>
+
+        Link clicks in PDFs shouldn't send referrer headers.
+        <rdar://problem/21142581> and https://bugs.webkit.org/show_bug.cgi?id=196980
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm: Added.
+        (putPDFBytesCallback):
+        (emptyReleaseInfoCallback):
+        (createPDFWithLinkToURL):
+        (TEST):
+
</ins><span class="cx"> 2019-04-17  Tim Horton  <timothy_horton@apple.com>
</span><span class="cx"> 
</span><span class="cx">         UI↔Web deadlock when printing with a JavaScript alert visible
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (244404 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2019-04-17 22:41:08 UTC (rev 244404)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -245,6 +245,7 @@
</span><span class="cx">          51CD1C721B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */; };
</span><span class="cx">          51D124981E763B02002B2820 /* WKHTTPCookieStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D124971E763AF8002B2820 /* WKHTTPCookieStore.mm */; };
</span><span class="cx">          51D1249B1E785425002B2820 /* CookieManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */; };
</span><ins>+               51D8C1902267B26D00797E40 /* PDFLinkReferrer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D8C18F2267B26700797E40 /* PDFLinkReferrer.mm */; };
</ins><span class="cx">           51DB16CE1F085137001FA4C5 /* WebViewIconLoading.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51DB16CD1F085047001FA4C5 /* WebViewIconLoading.mm */; };
</span><span class="cx">          51E5C7021919C3B200D8B3E1 /* simple2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780361919AFF8001829A2 /* simple2.html */; };
</span><span class="cx">          51E5C7031919C3B200D8B3E1 /* simple3.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780371919AFF8001829A2 /* simple3.html */; };
</span><span class="lines">@@ -1647,6 +1648,7 @@
</span><span class="cx">          51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModalAlerts.mm; sourceTree = "<group>"; };
</span><span class="cx">          51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "modal-alerts-in-new-about-blank-window.html"; sourceTree = "<group>"; };
</span><span class="cx">          51D124971E763AF8002B2820 /* WKHTTPCookieStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKHTTPCookieStore.mm; sourceTree = "<group>"; };
</span><ins>+               51D8C18F2267B26700797E40 /* PDFLinkReferrer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PDFLinkReferrer.mm; sourceTree = "<group>"; };
</ins><span class="cx">           51DB16CD1F085047001FA4C5 /* WebViewIconLoading.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewIconLoading.mm; sourceTree = "<group>"; };
</span><span class="cx">          51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldKeepCurrentBackForwardListItemInList.cpp; sourceTree = "<group>"; };
</span><span class="cx">          51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageClear.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -2625,6 +2627,7 @@
</span><span class="cx">                          F457A9B6202D5CDC00F7E9D5 /* PasteMixedContent.mm */,
</span><span class="cx">                          9BDD95561F83683600D20C60 /* PasteRTFD.mm */,
</span><span class="cx">                          9B2346411F943A2400DB1D23 /* PasteWebArchive.mm */,
</span><ins>+                               51D8C18F2267B26700797E40 /* PDFLinkReferrer.mm */,
</ins><span class="cx">                           3FCC4FE41EC4E8520076E37C /* PictureInPictureDelegate.mm */,
</span><span class="cx">                          83BAEE8C1EF4625500DDE894 /* PluginLoadClientPolicies.mm */,
</span><span class="cx">                          C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
</span><span class="lines">@@ -4255,6 +4258,7 @@
</span><span class="cx">                          F457A9B8202D5CDC00F7E9D5 /* PasteMixedContent.mm in Sources */,
</span><span class="cx">                          9BDD95581F83683600D20C60 /* PasteRTFD.mm in Sources */,
</span><span class="cx">                          9B2346421F943E2700DB1D23 /* PasteWebArchive.mm in Sources */,
</span><ins>+                               51D8C1902267B26D00797E40 /* PDFLinkReferrer.mm in Sources */,
</ins><span class="cx">                           7C83E0531D0A643A00FEBCF3 /* PendingAPIRequestURL.cpp in Sources */,
</span><span class="cx">                          3FCC4FE51EC4E8520076E37C /* PictureInPictureDelegate.mm in Sources */,
</span><span class="cx">                          7CCE7EAF1A411A3800447C4C /* PlatformUtilities.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaPDFLinkReferrermm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm (0 => 244405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm                           (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm      2019-04-17 22:47:07 UTC (rev 244405)
</span><span class="lines">@@ -0,0 +1,118 @@
</span><ins>+/*
+ * 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.
+ */
+
+#import "config.h"
+
+#if PLATFORM(MAC)
+
+#import "TCPServer.h"
+#import "Test.h"
+#import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import "Utilities.h"
+#import <WebKit/WKFoundation.h>
+
+static size_t putPDFBytesCallback(void* info, void* buffer, size_t count)
+{
+    [(NSMutableData *)info appendBytes:buffer length:count];
+    return count;
+}
+
+static void emptyReleaseInfoCallback(void* __nullable)
+{
+}
+
+static RetainPtr<NSData> createPDFWithLinkToURL(NSURL *url)
+{
+    auto pdfData = adoptNS([[NSMutableData alloc] init]);
+    
+    CGDataConsumerCallbacks callbacks;
+    callbacks.putBytes = (CGDataConsumerPutBytesCallback)putPDFBytesCallback;
+    callbacks.releaseConsumer = (CGDataConsumerReleaseInfoCallback)emptyReleaseInfoCallback;
+    auto consumer = adoptCF(CGDataConsumerCreate(pdfData.get(), &callbacks));
+    auto contextDictionary = adoptCF(CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+    CGRect rectangle = CGRectMake(0, 0, 1000, 1000);
+    auto pdfContext = adoptCF(CGPDFContextCreate(consumer.get(), &rectangle, contextDictionary.get()));
+
+    auto pageDictionary = adoptCF(CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+    auto boxData = adoptCF(CFDataCreate(NULL, (const UInt8 *)&rectangle, sizeof(CGRect)));
+    CFDictionarySetValue(pageDictionary.get(), kCGPDFContextMediaBox, boxData.get());
+    CGPDFContextBeginPage(pdfContext.get(), pageDictionary.get());
+    
+    CGContextSetRGBFillColor(pdfContext.get(), 1.0, 0.0, 0.0, 1.0);
+    CGContextSetRGBStrokeColor(pdfContext.get(), 1.0, 0.0, 0.0, 1.0);
+    CGContextFillRect(pdfContext.get(), rectangle);
+    CGPDFContextSetURLForRect(pdfContext.get(), (CFURLRef)url, rectangle);
+    CGPDFContextEndPage(pdfContext.get());
+
+    return pdfData;
+}
+
+TEST(WebKit, PDFLinkReferrer)
+{
+    TestWebKitAPI::TCPServer server([] (auto socket) {
+        char readBuffer[1000];
+        memset(readBuffer, 0, 1000);
+
+        // This assumes all the data from the HTTP request is available to be read at once,
+        // which is probably an okay assumption.
+        ::read(socket, readBuffer, 999);
+
+        // Look for a referer header.
+        char* currentLine = readBuffer;
+        while (currentLine) {
+            EXPECT_NE(strncasecmp(currentLine, "referer:", 8), 0);
+            char* nextLine = strchr(currentLine, '\n');
+            currentLine = nextLine ? nextLine + 1 : 0;
+        }
+
+        const char* responseHeader =
+        "HTTP/1.1 200 OK\r\n"
+        "Content-Length: 0\r\n\r\n";
+        ::write(socket, responseHeader, strlen(responseHeader));
+    });
+
+    RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]);
+    webView.get().navigationDelegate = navigationDelegate.get();
+
+    auto *linkURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%hu", server.port()]];
+    auto pdfData = createPDFWithLinkToURL(linkURL);
+
+    [webView loadData:pdfData.get() MIMEType:@"application/pdf" characterEncodingName:@"" baseURL:linkURL];
+    [navigationDelegate waitForDidFinishNavigation];
+
+    navigationDelegate.get().decidePolicyForNavigationAction = ^(WKNavigationAction *action, void (^decisionHandler)(WKNavigationActionPolicy)) {
+        EXPECT_NULL([action.request valueForHTTPHeaderField:@"Referer"]);
+        decisionHandler(WKNavigationActionPolicyAllow);
+    };
+    
+    [webView sendClicksAtPoint:NSMakePoint(75, 75) numberOfClicks:1];
+    [navigationDelegate waitForDidFinishNavigation];
+
+}
+
+#endif // PLATFORM(MAC)
</ins></span></pre>
</div>
</div>

</body>
</html>