<!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>[197150] 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/197150">197150</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-02-25 17:22:33 -0800 (Thu, 25 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Restrict information passed with navigation action which is triggered by untrusted event
https://bugs.webkit.org/show_bug.cgi?id=154571
&lt;rdar://problem/15967937&gt;

Reviewed by Andy Estes.

Source/WebKit/mac:

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::actionDictionary):

Source/WebKit2:

When navigation action is triggered by an untrusted event, we should be more restricted of
what information should be passed to the clients to lower the risk that clients could
be fooled by the untrusted event.

In this patch, we drop the modifiers for key state events and set the mouse button to NoButton
for mouse events.

* WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
(WebKit::InjectedBundleNavigationAction::modifiersForNavigationAction):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm: Added.
(-[WKNavigationActionDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
(TestWebKitAPI::TEST):
(-[NavigationActionDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]):
* TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleInjectedBundleNavigationActioncpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp</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="#trunkToolsTestWebKitAPITestsmacIsNavigationActionTrustedhtml">trunk/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsmacIsNavigationActionTrustedmm">trunk/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (197149 => 197150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-02-26 01:00:24 UTC (rev 197149)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-02-26 01:22:33 UTC (rev 197150)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-02-25  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Restrict information passed with navigation action which is triggered by untrusted event
+        https://bugs.webkit.org/show_bug.cgi?id=154571
+        &lt;rdar://problem/15967937&gt;
+
+        Reviewed by Andy Estes.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::actionDictionary):
+
</ins><span class="cx"> 2016-02-25  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [MediaStream] MediaDeviceInfo deviceId and groupId must be unique to the page's origin
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (197149 => 197150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2016-02-26 01:00:24 UTC (rev 197149)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2016-02-26 01:22:33 UTC (rev 197150)
</span><span class="lines">@@ -1561,7 +1561,8 @@
</span><span class="cx">     unsigned modifierFlags = 0;
</span><span class="cx">     const Event* event = action.event();
</span><span class="cx"> #if !PLATFORM(IOS)
</span><del>-    if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast&lt;Event*&gt;(event))) {
</del><ins>+    const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast&lt;Event*&gt;(event));
+    if (keyStateEvent &amp;&amp; keyStateEvent-&gt;isTrusted()) {
</ins><span class="cx">         if (keyStateEvent-&gt;ctrlKey())
</span><span class="cx">             modifierFlags |= NSControlKeyMask;
</span><span class="cx">         if (keyStateEvent-&gt;altKey())
</span><span class="lines">@@ -1590,7 +1591,10 @@
</span><span class="cx">         [result setObject:element forKey:WebActionElementKey];
</span><span class="cx">         [element release];
</span><span class="cx"> 
</span><del>-        [result setObject:[NSNumber numberWithInt:mouseEvent-&gt;button()] forKey:WebActionButtonKey];
</del><ins>+        if (mouseEvent-&gt;isTrusted())
+            [result setObject:[NSNumber numberWithInt:mouseEvent-&gt;button()] forKey:WebActionButtonKey];
+        else
+            [result setObject:[NSNumber numberWithInt:WebCore::NoButton] forKey:WebActionButtonKey];
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (formState) {
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (197149 => 197150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-02-26 01:00:24 UTC (rev 197149)
+++ trunk/Source/WebKit2/ChangeLog        2016-02-26 01:22:33 UTC (rev 197150)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-02-25  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Restrict information passed with navigation action which is triggered by untrusted event
+        https://bugs.webkit.org/show_bug.cgi?id=154571
+        &lt;rdar://problem/15967937&gt;
+
+        Reviewed by Andy Estes.
+
+        When navigation action is triggered by an untrusted event, we should be more restricted of
+        what information should be passed to the clients to lower the risk that clients could
+        be fooled by the untrusted event.
+
+        In this patch, we drop the modifiers for key state events and set the mouse button to NoButton
+        for mouse events.
+
+        * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
+        (WebKit::InjectedBundleNavigationAction::modifiersForNavigationAction):
+
</ins><span class="cx"> 2016-02-25  Ada Chan  &lt;adachan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Hook up fullscreenMayReturnToInline() in WKPageUIClient
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleInjectedBundleNavigationActioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp (197149 => 197150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp        2016-02-26 01:00:24 UTC (rev 197149)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp        2016-02-26 01:22:33 UTC (rev 197150)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">     if (!mouseEvent)
</span><span class="cx">         return WebMouseEvent::NoButton;
</span><span class="cx"> 
</span><del>-    if (!mouseEvent-&gt;buttonDown())
</del><ins>+    if (!mouseEvent-&gt;buttonDown() || !mouseEvent-&gt;isTrusted())
</ins><span class="cx">         return WebMouseEvent::NoButton;
</span><span class="cx"> 
</span><span class="cx">     return static_cast&lt;WebMouseEvent::Button&gt;(mouseEvent-&gt;button());
</span><span class="lines">@@ -61,7 +61,8 @@
</span><span class="cx"> WebEvent::Modifiers InjectedBundleNavigationAction::modifiersForNavigationAction(const NavigationAction&amp; navigationAction)
</span><span class="cx"> {
</span><span class="cx">     uint32_t modifiers = 0;
</span><del>-    if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast&lt;Event*&gt;(navigationAction.event()))) {
</del><ins>+    const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast&lt;Event*&gt;(navigationAction.event()));
+    if (keyStateEvent &amp;&amp; keyStateEvent-&gt;isTrusted()) {
</ins><span class="cx">         if (keyStateEvent-&gt;shiftKey())
</span><span class="cx">             modifiers |= WebEvent::ShiftKey;
</span><span class="cx">         if (keyStateEvent-&gt;ctrlKey())
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (197149 => 197150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-02-26 01:00:24 UTC (rev 197149)
+++ trunk/Tools/ChangeLog        2016-02-26 01:22:33 UTC (rev 197150)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-02-25  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Restrict information passed with navigation action which is triggered by untrusted event
+        https://bugs.webkit.org/show_bug.cgi?id=154571
+        &lt;rdar://problem/15967937&gt;
+
+        Reviewed by Andy Estes.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm: Added.
+        (-[WKNavigationActionDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
+        (TestWebKitAPI::TEST):
+        (-[NavigationActionDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]):
+        * TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.html: Added.
+
</ins><span class="cx"> 2016-02-25  Gavin Barraclough  &lt;barraclough@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Should template RefCounter instead of RefCounter::Token
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (197149 => 197150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-02-26 01:00:24 UTC (rev 197149)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-02-26 01:22:33 UTC (rev 197150)
</span><span class="lines">@@ -75,6 +75,8 @@
</span><span class="cx">                 52B8CF9815868D9100281053 /* SetDocumentURI.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 52B8CF9415868CF000281053 /* SetDocumentURI.html */; };
</span><span class="cx">                 52D673EE1AFB127300FA19FE /* WKPageCopySessionStateWithFiltering.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52D673EC1AFB126800FA19FE /* WKPageCopySessionStateWithFiltering.cpp */; };
</span><span class="cx">                 52E5CE4914D21EAB003B2BD8 /* ParentFrame_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52E5CE4814D21EAB003B2BD8 /* ParentFrame_Bundle.cpp */; };
</span><ins>+                57F10D931C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */; };
+                57F56A5C1C7F8CC100F31D7E /* IsNavigationActionTrusted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */; };
</ins><span class="cx">                 764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */; };
</span><span class="cx">                 7673499D1930C5BB00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7673499A1930182E00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp */; };
</span><span class="cx">                 76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */; };
</span><span class="lines">@@ -386,6 +388,7 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                57F56A5C1C7F8CC100F31D7E /* IsNavigationActionTrusted.html in Copy Resources */,
</ins><span class="cx">                                 A16F66BA1C40EB4F00BD4D24 /* ContentFiltering.html in Copy Resources */,
</span><span class="cx">                                 CDC8E4941BC6F10800594FEC /* video-with-audio.html in Copy Resources */,
</span><span class="cx">                                 CDC8E4951BC6F10800594FEC /* video-with-audio.mp4 in Copy Resources */,
</span><span class="lines">@@ -604,6 +607,8 @@
</span><span class="cx">                 52D673EC1AFB126800FA19FE /* WKPageCopySessionStateWithFiltering.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPageCopySessionStateWithFiltering.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 52E5CE4514D21E9D003B2BD8 /* ParentFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParentFrame.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 52E5CE4814D21EAB003B2BD8 /* ParentFrame_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParentFrame_Bundle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IsNavigationActionTrusted.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = IsNavigationActionTrusted.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheAddImageToCacheIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 75F3133F18C171B70041CAEC /* EphemeralSessionPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EphemeralSessionPushStateNoHistoryCallback.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WordBoundaryTypingAttributes.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1272,8 +1277,6 @@
</span><span class="cx">                 BC90977B125571AE00083756 /* Resources */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><del>-                                7AE9E5081AE5AE8B00CF874B /* test.pdf */,
-                                7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */,
</del><span class="cx">                                 C045F9461385C2F800C0F3CD /* 18-characters.html */,
</span><span class="cx">                                 93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */,
</span><span class="cx">                                 F6B7BE9617469B7E008A3445 /* associate-form-controls.html */,
</span><span class="lines">@@ -1300,6 +1303,7 @@
</span><span class="cx">                                 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */,
</span><span class="cx">                                 930AD401150698B30067970F /* lots-of-text.html */,
</span><span class="cx">                                 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */,
</span><ins>+                                7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */,
</ins><span class="cx">                                 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */,
</span><span class="cx">                                 CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */,
</span><span class="cx">                                 F6FDDDD514241C48004F1729 /* push-state.html */,
</span><span class="lines">@@ -1312,6 +1316,7 @@
</span><span class="cx">                                 51E780371919AFF8001829A2 /* simple3.html */,
</span><span class="cx">                                 CEBABD481B71687C0051210A /* should-open-external-schemes.html */,
</span><span class="cx">                                 C02B7882126615410026BF0F /* spacebar-scrolling.html */,
</span><ins>+                                7AE9E5081AE5AE8B00CF874B /* test.pdf */,
</ins><span class="cx">                                 CD59F53319E910BC00CF1835 /* test-mse.mp4 */,
</span><span class="cx">                                 524BBCA019E30C63002F1AF1 /* test.mp4 */,
</span><span class="cx">                         );
</span><span class="lines">@@ -1377,6 +1382,7 @@
</span><span class="cx">                                 9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */,
</span><span class="cx">                                 9B26FC6B159D061000CC3765 /* HTMLFormCollectionNamedItem.mm */,
</span><span class="cx">                                 C507E8A614C6545B005D6B3B /* InspectorBar.mm */,
</span><ins>+                                57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */,
</ins><span class="cx">                                 4BB4160116815B2600824238 /* JSWrapperForNodeInWebFrame.mm */,
</span><span class="cx">                                 E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */,
</span><span class="cx">                                 517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */,
</span><span class="lines">@@ -1424,6 +1430,7 @@
</span><span class="cx">                                 CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */,
</span><span class="cx">                                 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */,
</span><span class="cx">                                 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */,
</span><ins>+                                57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */,
</ins><span class="cx">                                 C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */,
</span><span class="cx">                                 C2CF975916CEC69E0054E99D /* JSContextBackForwardCache2.html */,
</span><span class="cx">                                 E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */,
</span><span class="lines">@@ -1859,6 +1866,7 @@
</span><span class="cx">                                 2D8104CC1BEC13E70020DA46 /* FindInPage.mm in Sources */,
</span><span class="cx">                                 CD225C081C45A69200140761 /* ParsedContentRange.cpp in Sources */,
</span><span class="cx">                                 41973B5D1AF22875006C7B36 /* SharedBuffer.cpp in Sources */,
</span><ins>+                                57F10D931C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm in Sources */,
</ins><span class="cx">                                 2DD355361BD08378005DF4A7 /* AutoLayoutIntegration.mm in Sources */,
</span><span class="cx">                                 7AA6A1521AAC0B31002B2ED3 /* WorkQueue.cpp in Sources */,
</span><span class="cx">                                 2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacIsNavigationActionTrustedhtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.html (0 => 197150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.html        2016-02-26 01:22:33 UTC (rev 197150)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+function add(a) {
+    try{
+        var c = document.createElement(&quot;a&quot;);
+        c.setAttribute(&quot;href&quot;, a);
+        c.setAttribute(&quot;style&quot;, &quot;display:none;&quot;);
+        var b = document.createEvent(&quot;MouseEvents&quot;);
+        b.initMouseEvent(&quot;click&quot;, false, false, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null);
+        c.dispatchEvent(b);
+        return true;
+    }catch(q){
+        return false;
+    }
+}
+
+add('http://www.example.com/');
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacIsNavigationActionTrustedmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm (0 => 197150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm        2016-02-26 01:22:33 UTC (rev 197150)
</span><span class="lines">@@ -0,0 +1,115 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 &quot;config.h&quot;
+
+#import &quot;PlatformUtilities.h&quot;
+#import &lt;WebKit/WebKitLegacy.h&gt;
+#import &lt;WebKit/WKWebView.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+static bool didFinishTest;
+const static NSURL *targetUrl = [[NSURL alloc] initWithString:@&quot;http://www.example.com/&quot;];
+const static unsigned expectedModifierFlags = 0;
+const static int expectedButtonNumber = -1;
+const static int expectedWKButtonNumber = 0; // unlike DOM spec, 0 is the value for no button in Cocoa.
+
+#if WK_API_ENABLED
+
+@interface NavigationActionDelegate : NSObject &lt;WKNavigationDelegate&gt;
+@end
+
+@implementation NavigationActionDelegate
+
+- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
+{
+    if ([navigationAction.request.URL isEqual:targetUrl]) {
+        EXPECT_EQ(navigationAction.modifierFlags, expectedModifierFlags);
+        EXPECT_EQ(navigationAction.buttonNumber, expectedWKButtonNumber);
+        didFinishTest = true;
+    }
+
+    decisionHandler(WKNavigationActionPolicyAllow);
+}
+
+@end
+
+#endif
+
+@interface WebPolicyActionDelegate : NSObject &lt;WebPolicyDelegate&gt;
+@end
+
+@implementation WebPolicyActionDelegate
+
+- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id&lt;WebPolicyDecisionListener&gt;)listener
+{
+    if ([request.URL isEqual:targetUrl]) {
+        EXPECT_EQ([actionInformation[WebActionModifierFlagsKey] unsignedIntValue], expectedModifierFlags);
+        EXPECT_EQ([actionInformation[WebActionButtonKey] intValue], expectedButtonNumber);
+        didFinishTest = true;
+    }
+
+    [listener use];
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+#if WK_API_ENABLED
+
+TEST(WebKit2, IsNavigationActionTrusted)
+{
+    @autoreleasepool {
+        RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+        RetainPtr&lt;NavigationActionDelegate&gt; delegate = adoptNS([[NavigationActionDelegate alloc] init]);
+        [webView setNavigationDelegate:delegate.get()];
+
+        NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;IsNavigationActionTrusted&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+        [webView loadRequest:request];
+
+        didFinishTest = false;
+        Util::run(&amp;didFinishTest);
+    }
+}
+
+#endif
+
+TEST(WebKit1, IsNavigationActionTrusted)
+{
+    @autoreleasepool {
+        RetainPtr&lt;WebView&gt; webView = adoptNS([[WebView alloc] init]);
+
+        RetainPtr&lt;WebPolicyActionDelegate&gt; delegate = adoptNS([[WebPolicyActionDelegate alloc] init]);
+        [webView setPolicyDelegate:delegate.get()];
+        [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;IsNavigationActionTrusted&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]]];
+
+        didFinishTest = false;
+        Util::run(&amp;didFinishTest);
+    }
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>

</body>
</html>