<!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>[208509] 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/208509">208509</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2016-11-09 16:58:35 -0800 (Wed, 09 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Local HTML should be blocked from localStorage access unless &quot;Disable Local File Restrictions&quot; is checked
https://bugs.webkit.org/show_bug.cgi?id=155185
&lt;rdar://problem/11101440&gt;

Reviewed by Brady Eidson.

Source/WebCore:

Add a new quirk for localStorage that defaults to 'on'. When active, this quirk says that
localStorage access should be granted, without needing to grant universal file access.

If the quirk is turned off, then localStorage is blocked unless the WebKit client explicitly
grants universal file access.

Tests: storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk.html
       storage/domstorage/localstorage/blocked-file-access.html

* dom/Document.cpp:
(WebCore::Document::initSecurityContext): Set localStorage quirk mode based on settings.
* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::SecurityOrigin): Use more C++11 initializers.
(WebCore::SecurityOrigin::canAccessStorage): If the origin is a local file, and we are NOT in
localStorage quirks mode, and we have not been granted universal file access, prevent access
to DOM localStorage.
(WebCore::SecurityOrigin::setNeedsLocalStorageQuirk): Added.
* page/SecurityOrigin.h:
(WebCore::SecurityOrigin::needsLocalStorageQuirk): Added.
* page/Settings.in:
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::WorkerGlobalScope): Make sure Workers know what the
localStorage quirks mode is set to.

Source/WebKit/mac:

Provide SPI to access the new quirk for localStorage. The quirk defaults to 'on'. When active, this
quirk says that localStorage access should be granted, without needing to grant universal file access.

If the quirk is turned off, then localStorage is blocked unless the WebKit client explicitly
grants universal file access.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(-[WebPreferences needsLocalStorageQuirk]): Added.
(-[WebPreferences setNeedsLocalStorageQuirk:]): Added.
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]): Honor the new localStorage quirk.

Source/WebKit2:

Provide SPI to access the new quirk for localStorage. The quirk defaults to 'on'. When active, this
quirk says that localStorage access should be granted, without needing to grant universal file access.

If the quirk is turned off, then localStorage is blocked unless the WebKit client explicitly
grants universal file access.
        
Tested by existing TestWebKitAPI tests and WebKit2.LocalStorageQuirkTest

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetNeedsLocalStorageQuirk): Added.
(WKPreferencesGetNeedsLocalStorageQuirk): Added.
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]): Honor the new localStorage quirk.
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]): Honor the new localStorage quirk flag.
(-[WKWebViewConfiguration copyWithZone:]): Ditto.
(-[WKWebViewConfiguration _needsLocalStorageQuirk]): Added.
(-[WKWebViewConfiguration _setNeedsLocalStorageQuirk:]): Added.
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleSetNeedsLocalStorageQuirk): Added.
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::setNeedsLocalStorageQuirk): Added.
* WebProcess/InjectedBundle/InjectedBundle.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences): Honor the new localStorage quirk flag.

Tools:

* DumpRenderTree/TestRunner.cpp:
(setNeedsLocalStorageQuirkCallback): Added.
(TestRunner::staticFunctions):
* DumpRenderTree/TestRunner.h:
* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues): Update for new quirk setting.
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setNeedsLocalStorageQuirk):
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp:
* TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm:
* TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageNullEntries.mm:
* TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkEnabled.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkTest.mm: Added.
(-[LocalStorageQuirkMessageHandler userContentController:didReceiveScriptMessage:]):
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting): Update for new quirk setting.
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setNeedsLocalStorageQuirk): Added.
* WebKitTestRunner/InjectedBundle/TestRunner.h:

LayoutTests:

* storage/domstorage/localstorage/blocked-file-access-expected.txt: Added.
* storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk-expected.txt: Added.
* storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk.html: Added.
* storage/domstorage/localstorage/blocked-file-access.html: Added.
* storage/domstorage/localstorage/resources/allowed-example.html: Added.
* storage/domstorage/localstorage/resources/blocked-example.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsstoragedomstoragelocalstoragefilecanaccesshtml">trunk/LayoutTests/storage/domstorage/localstorage/file-can-access.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSecurityOrigincpp">trunk/Source/WebCore/page/SecurityOrigin.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSecurityOriginh">trunk/Source/WebCore/page/SecurityOrigin.h</a></li>
<li><a href="#trunkSourceWebCorepageSettingsin">trunk/Source/WebCore/page/Settings.in</a></li>
<li><a href="#trunkSourceWebCoreworkersWorkerGlobalScopecpp">trunk/Source/WebCore/workers/WorkerGlobalScope.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferenceKeysPrivateh">trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferencesmm">trunk/Source/WebKit/mac/WebView/WebPreferences.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferencesPrivateh">trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPreferencesDefinitionsh">trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPreferencescpp">trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPreferencesRefPrivateh">trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundlecpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundlePrivateh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleInjectedBundlecpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleInjectedBundleh">trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreeTestRunnercpp">trunk/Tools/DumpRenderTree/TestRunner.cpp</a></li>
<li><a href="#trunkToolsDumpRenderTreeTestRunnerh">trunk/Tools/DumpRenderTree/TestRunner.h</a></li>
<li><a href="#trunkToolsDumpRenderTreemacDumpRenderTreemm">trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm</a></li>
<li><a href="#trunkToolsDumpRenderTreemacTestRunnerMacmm">trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CloseFromWithinCreatePagecpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaLocalStorageClearmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaLocalStorageNullEntriesmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageNullEntries.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl">trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlecpp">trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsstoragedomstoragelocalstorageblockedfileaccessexpectedtxt">trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstoragedomstoragelocalstorageblockedfileaccesspermittedbyquirkexpectedtxt">trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstoragedomstoragelocalstorageblockedfileaccesspermittedbyquirkhtml">trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk.html</a></li>
<li><a href="#trunkLayoutTestsstoragedomstoragelocalstorageblockedfileaccesshtml">trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access.html</a></li>
<li><a href="#trunkLayoutTestsstoragedomstoragelocalstorageresourcesallowedexamplehtml">trunk/LayoutTests/storage/domstorage/localstorage/resources/allowed-example.html</a></li>
<li><a href="#trunkLayoutTestsstoragedomstoragelocalstorageresourcesblockedexamplehtml">trunk/LayoutTests/storage/domstorage/localstorage/resources/blocked-example.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaLocalStorageQuirkEnabledhtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkEnabled.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaLocalStorageQuirkTestmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkTest.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/LayoutTests/ChangeLog        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-11-04  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        Local HTML should be blocked from localStorage access unless &quot;Disable Local File Restrictions&quot; is checked
+        https://bugs.webkit.org/show_bug.cgi?id=155185
+        &lt;rdar://problem/11101440&gt;
+
+        Reviewed by Brady Eidson.
+
+        * storage/domstorage/localstorage/blocked-file-access-expected.txt: Added.
+        * storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk-expected.txt: Added.
+        * storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk.html: Added.
+        * storage/domstorage/localstorage/blocked-file-access.html: Added.
+        * storage/domstorage/localstorage/resources/allowed-example.html: Added.
+        * storage/domstorage/localstorage/resources/blocked-example.html: Added.
+
</ins><span class="cx"> 2016-11-09  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         URLParser should not consider path of URLs with no host to start at the first slash after the colon
</span></span></pre></div>
<a id="trunkLayoutTestsstoragedomstoragelocalstorageblockedfileaccessexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-expected.txt (0 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-expected.txt                                (rev 0)
+++ trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-expected.txt        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+CONSOLE MESSAGE: line 11: PASS: window.localStorage is NOT accessible
+CONSOLE MESSAGE: line 12: Exception: The operation is insecure.
+
+Test that we cannot access localStorage from a file URL if unversal access is turned off.
</ins></span></pre></div>
<a id="trunkLayoutTestsstoragedomstoragelocalstorageblockedfileaccesspermittedbyquirkexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk-expected.txt (0 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk-expected.txt                                (rev 0)
+++ trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk-expected.txt        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+CONSOLE MESSAGE: line 8: PASS: window.localStorage WAS accessible
+
+Test that the local storage quirk allows us to access localStorage from a file URL, even if unversal access is turned off.
</ins></span></pre></div>
<a id="trunkLayoutTestsstoragedomstoragelocalstorageblockedfileaccesspermittedbyquirkhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk.html (0 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk.html                                (rev 0)
+++ trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk.html        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    // 'NeedsLocalStorageQuirk' is the default state, but I set it explicitly in case this ever changes.
+    testRunner.setNeedsStorageAccessFromFileURLsQuirk(true);
+    testRunner.setAllowUniversalAccessFromFileURLs(false);
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;iframe src=&quot;resources/allowed-example.html&quot;&gt;&lt;/iframe&gt;
+&lt;div id=&quot;results&quot;&gt;&lt;/div&gt;
+Test that the local storage quirk allows us to access localStorage from a file URL, even if unversal access is turned off.
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsstoragedomstoragelocalstorageblockedfileaccesshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access.html (0 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access.html                                (rev 0)
+++ trunk/LayoutTests/storage/domstorage/localstorage/blocked-file-access.html        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.setNeedsStorageAccessFromFileURLsQuirk(false);
+    testRunner.setAllowUniversalAccessFromFileURLs(false);
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;iframe src=&quot;resources/blocked-example.html&quot;&gt;&lt;/iframe&gt;
+&lt;div id=&quot;results&quot;&gt;&lt;/div&gt;
+Test that we cannot access localStorage from a file URL if unversal access is turned off.
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsstoragedomstoragelocalstoragefilecanaccesshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/storage/domstorage/localstorage/file-can-access.html (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/domstorage/localstorage/file-can-access.html        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/LayoutTests/storage/domstorage/localstorage/file-can-access.html        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -2,6 +2,7 @@
</span><span class="cx"> &lt;head&gt;
</span><span class="cx"> &lt;script&gt;
</span><span class="cx"> if (window.testRunner) {
</span><ins>+    testRunner.setNeedsStorageAccessFromFileURLsQuirk(true);
</ins><span class="cx">     testRunner.setAllowUniversalAccessFromFileURLs(false);
</span><span class="cx">     testRunner.dumpAsText();
</span><span class="cx">     testRunner.waitUntilDone();
</span></span></pre></div>
<a id="trunkLayoutTestsstoragedomstoragelocalstorageresourcesallowedexamplehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/domstorage/localstorage/resources/allowed-example.html (0 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/domstorage/localstorage/resources/allowed-example.html                                (rev 0)
+++ trunk/LayoutTests/storage/domstorage/localstorage/resources/allowed-example.html        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+function runTest()
+{
+    try {
+        if (window.localStorage) {
+            console.log(&quot;PASS: window.localStorage WAS accessible&quot;);
+        }
+    } catch(e) {
+        console.log(&quot;FAIL: window.localStorage is NOT accessible&quot;);
+        console.log(&quot;Exception: &quot; + e.message);
+    }
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsstoragedomstoragelocalstorageresourcesblockedexamplehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/domstorage/localstorage/resources/blocked-example.html (0 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/domstorage/localstorage/resources/blocked-example.html                                (rev 0)
+++ trunk/LayoutTests/storage/domstorage/localstorage/resources/blocked-example.html        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+function runTest()
+{
+    try {
+        if (window.localStorage) {
+            console.log(&quot;FAIL: window.localStorage WAS accessible&quot;);
+        }
+    } catch(e) {
+        console.log(&quot;PASS: window.localStorage is NOT accessible&quot;);
+        console.log(&quot;Exception: &quot; + e.message);
+    }
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebCore/ChangeLog        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2016-11-04  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        Local HTML should be blocked from localStorage access unless &quot;Disable Local File Restrictions&quot; is checked
+        https://bugs.webkit.org/show_bug.cgi?id=155185
+        &lt;rdar://problem/11101440&gt;
+
+        Reviewed by Brady Eidson.
+
+        Add a new quirk for localStorage that defaults to 'on'. When active, this quirk says that
+        localStorage access should be granted, without needing to grant universal file access.
+
+        If the quirk is turned off, then localStorage is blocked unless the WebKit client explicitly
+        grants universal file access.
+
+        Tests: storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk.html
+               storage/domstorage/localstorage/blocked-file-access.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::initSecurityContext): Set localStorage quirk mode based on settings.
+        * page/SecurityOrigin.cpp:
+        (WebCore::SecurityOrigin::SecurityOrigin): Use more C++11 initializers.
+        (WebCore::SecurityOrigin::canAccessStorage): If the origin is a local file, and we are NOT in
+        localStorage quirks mode, and we have not been granted universal file access, prevent access
+        to DOM localStorage.
+        (WebCore::SecurityOrigin::setNeedsLocalStorageQuirk): Added.
+        * page/SecurityOrigin.h:
+        (WebCore::SecurityOrigin::needsLocalStorageQuirk): Added.
+        * page/Settings.in:
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::WorkerGlobalScope): Make sure Workers know what the
+        localStorage quirks mode is set to.
+
</ins><span class="cx"> 2016-11-09  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         URLParser should not consider path of URLs with no host to start at the first slash after the colon
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -5123,6 +5123,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (Settings* settings = this-&gt;settings()) {
</span><ins>+        if (settings-&gt;needsStorageAccessFromFileURLsQuirk())
+            securityOrigin()-&gt;grantStorageAccessFromFileURLsQuirk();
</ins><span class="cx">         if (!settings-&gt;webSecurityEnabled()) {
</span><span class="cx">             // Web security is turned off. We should let this document access every other document. This is used primary by testing
</span><span class="cx">             // harnesses for web sites.
</span></span></pre></div>
<a id="trunkSourceWebCorepageSecurityOrigincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/SecurityOrigin.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/SecurityOrigin.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebCore/page/SecurityOrigin.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -105,11 +105,6 @@
</span><span class="cx">     : m_protocol(url.protocol().isNull() ? emptyString() : url.protocol().toString().convertToASCIILowercase())
</span><span class="cx">     , m_host(url.host().isNull() ? emptyString() : url.host().convertToASCIILowercase())
</span><span class="cx">     , m_port(url.port())
</span><del>-    , m_isUnique(false)
-    , m_universalAccess(false)
-    , m_domainWasSetInDOM(false)
-    , m_storageBlockingPolicy(AllowAllStorage)
-    , m_enforceFilePathSeparation(false)
</del><span class="cx"> {
</span><span class="cx">     // document.domain starts as m_host, but can be set by the DOM.
</span><span class="cx">     m_domain = m_host;
</span><span class="lines">@@ -129,11 +124,6 @@
</span><span class="cx">     , m_host(emptyString())
</span><span class="cx">     , m_domain(emptyString())
</span><span class="cx">     , m_isUnique(true)
</span><del>-    , m_universalAccess(false)
-    , m_domainWasSetInDOM(false)
-    , m_canLoadLocalResources(false)
-    , m_storageBlockingPolicy(AllowAllStorage)
-    , m_enforceFilePathSeparation(false)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -149,6 +139,7 @@
</span><span class="cx">     , m_canLoadLocalResources(other-&gt;m_canLoadLocalResources)
</span><span class="cx">     , m_storageBlockingPolicy(other-&gt;m_storageBlockingPolicy)
</span><span class="cx">     , m_enforceFilePathSeparation(other-&gt;m_enforceFilePathSeparation)
</span><ins>+    , m_needsStorageAccessFromFileURLsQuirk(other-&gt;m_needsStorageAccessFromFileURLsQuirk)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -337,6 +328,9 @@
</span><span class="cx">     if (isUnique())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (isLocal() &amp;&amp; !needsStorageAccessFromFileURLsQuirk() &amp;&amp; !m_universalAccess)
+        return false;
+    
</ins><span class="cx">     if (m_storageBlockingPolicy == BlockAllStorage)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="lines">@@ -393,6 +387,11 @@
</span><span class="cx">     m_universalAccess = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SecurityOrigin::grantStorageAccessFromFileURLsQuirk()
+{
+    m_needsStorageAccessFromFileURLsQuirk = true;
+}
+
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> String SecurityOrigin::domainForCachePartition() const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorepageSecurityOriginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/SecurityOrigin.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/SecurityOrigin.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebCore/page/SecurityOrigin.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -141,6 +141,9 @@
</span><span class="cx"> 
</span><span class="cx">     void setStorageBlockingPolicy(StorageBlockingPolicy policy) { m_storageBlockingPolicy = policy; }
</span><span class="cx"> 
</span><ins>+    void grantStorageAccessFromFileURLsQuirk();
+    bool needsStorageAccessFromFileURLsQuirk() const { return m_needsStorageAccessFromFileURLsQuirk; }
+
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx">     WEBCORE_EXPORT String domainForCachePartition() const;
</span><span class="cx"> #endif
</span><span class="lines">@@ -226,12 +229,13 @@
</span><span class="cx">     String m_domain;
</span><span class="cx">     String m_filePath;
</span><span class="cx">     Optional&lt;uint16_t&gt; m_port;
</span><del>-    bool m_isUnique;
-    bool m_universalAccess;
-    bool m_domainWasSetInDOM;
-    bool m_canLoadLocalResources;
-    StorageBlockingPolicy m_storageBlockingPolicy;
-    bool m_enforceFilePathSeparation;
</del><ins>+    bool m_isUnique { false };
+    bool m_universalAccess { false };
+    bool m_domainWasSetInDOM { false };
+    bool m_canLoadLocalResources { false };
+    StorageBlockingPolicy m_storageBlockingPolicy { AllowAllStorage };
+    bool m_enforceFilePathSeparation { false };
+    bool m_needsStorageAccessFromFileURLsQuirk { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> // Returns true if the Origin header values serialized from these two origins would be the same.
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.in (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.in        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebCore/page/Settings.in        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx"> localStorageEnabled initial=false
</span><span class="cx"> allowUniversalAccessFromFileURLs initial=true
</span><span class="cx"> allowFileAccessFromFileURLs initial=true
</span><ins>+needsStorageAccessFromFileURLsQuirk initial=true
</ins><span class="cx"> javaScriptCanOpenWindowsAutomatically initial=false
</span><span class="cx"> javaScriptCanAccessClipboard initial=false
</span><span class="cx"> shouldPrintBackgrounds initial=false
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersWorkerGlobalScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -78,6 +78,8 @@
</span><span class="cx">     auto origin = SecurityOrigin::create(url);
</span><span class="cx">     if (m_topOrigin-&gt;hasUniversalAccess())
</span><span class="cx">         origin-&gt;grantUniversalAccess();
</span><ins>+    if (m_topOrigin-&gt;needsStorageAccessFromFileURLsQuirk())
+        origin-&gt;grantStorageAccessFromFileURLsQuirk();
</ins><span class="cx"> 
</span><span class="cx">     setSecurityOriginPolicy(SecurityOriginPolicy::create(WTFMove(origin)));
</span><span class="cx">     setContentSecurityPolicy(std::make_unique&lt;ContentSecurityPolicy&gt;(*this));
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-11-04  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        Local HTML should be blocked from localStorage access unless &quot;Disable Local File Restrictions&quot; is checked
+        https://bugs.webkit.org/show_bug.cgi?id=155185
+        &lt;rdar://problem/11101440&gt;
+
+        Reviewed by Brady Eidson.
+
+        Provide SPI to access the new quirk for localStorage. The quirk defaults to 'on'. When active, this
+        quirk says that localStorage access should be granted, without needing to grant universal file access.
+
+        If the quirk is turned off, then localStorage is blocked unless the WebKit client explicitly
+        grants universal file access.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (-[WebPreferences needsLocalStorageQuirk]): Added.
+        (-[WebPreferences setNeedsLocalStorageQuirk:]): Added.
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]): Honor the new localStorage quirk.
+
</ins><span class="cx"> 2016-11-09  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Clean up Storage code
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferenceKeysPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> #define WebKitWebSecurityEnabledPreferenceKey @&quot;WebKitWebSecurityEnabled&quot;
</span><span class="cx"> #define WebKitAllowUniversalAccessFromFileURLsPreferenceKey @&quot;WebKitAllowUniversalAccessFromFileURLs&quot;
</span><span class="cx"> #define WebKitAllowFileAccessFromFileURLsPreferenceKey @&quot;WebKitAllowFileAccessFromFileURLs&quot;
</span><ins>+#define WebKitNeedsStorageAccessFromFileURLsQuirkKey @&quot;WebKitNeedsStorageAccessFromFileURLsQuirk&quot;
</ins><span class="cx"> #define WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey @&quot;WebKitJavaScriptCanOpenWindowsAutomatically&quot;
</span><span class="cx"> #define WebKitPluginsEnabledPreferenceKey @&quot;WebKitPluginsEnabled&quot;
</span><span class="cx"> #define WebKitDatabasesEnabledPreferenceKey @&quot;WebKitDatabasesEnabledPreferenceKey&quot;
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferencesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferences.mm (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferences.mm        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit/mac/WebView/WebPreferences.mm        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -627,6 +627,7 @@
</span><span class="cx">         [NSNumber numberWithBool:NO], WebKitWebAnimationsEnabledPreferenceKey,
</span><span class="cx"> #endif
</span><span class="cx">         [NSNumber numberWithBool:NO], WebKitVisualViewportEnabledPreferenceKey,
</span><ins>+        [NSNumber numberWithBool:YES], WebKitNeedsStorageAccessFromFileURLsQuirkKey,
</ins><span class="cx">         nil];
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="lines">@@ -1445,6 +1446,16 @@
</span><span class="cx">     [self _setBoolValue: flag forKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)needsStorageAccessFromFileURLsQuirk
+{
+    return [self _boolValueForKey: WebKitNeedsStorageAccessFromFileURLsQuirkKey];
+}
+
+-(void)setNeedsStorageAccessFromFileURLsQuirk:(BOOL)flag
+{
+    [self _setBoolValue: flag forKey: WebKitNeedsStorageAccessFromFileURLsQuirkKey];
+}
+
</ins><span class="cx"> - (NSTimeInterval)_backForwardCacheExpirationInterval
</span><span class="cx"> {
</span><span class="cx">     return (NSTimeInterval)[self _floatValueForKey:WebKitBackForwardCacheExpirationIntervalKey];
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferencesPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -139,6 +139,9 @@
</span><span class="cx"> - (BOOL)allowFileAccessFromFileURLs;
</span><span class="cx"> - (void)setAllowFileAccessFromFileURLs:(BOOL)flag;
</span><span class="cx"> 
</span><ins>+- (BOOL)needsStorageAccessFromFileURLsQuirk;
+- (void)setNeedsStorageAccessFromFileURLsQuirk:(BOOL)flag;
+
</ins><span class="cx"> - (BOOL)zoomsTextOnly;
</span><span class="cx"> - (void)setZoomsTextOnly:(BOOL)zoomsTextOnly;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -2605,6 +2605,7 @@
</span><span class="cx">     settings.setWebSecurityEnabled([preferences isWebSecurityEnabled]);
</span><span class="cx">     settings.setAllowUniversalAccessFromFileURLs([preferences allowUniversalAccessFromFileURLs]);
</span><span class="cx">     settings.setAllowFileAccessFromFileURLs([preferences allowFileAccessFromFileURLs]);
</span><ins>+    settings.setNeedsStorageAccessFromFileURLsQuirk([preferences needsStorageAccessFromFileURLsQuirk]);
</ins><span class="cx">     settings.setJavaScriptCanOpenWindowsAutomatically([preferences javaScriptCanOpenWindowsAutomatically]);
</span><span class="cx">     settings.setMinimumFontSize([preferences minimumFontSize]);
</span><span class="cx">     settings.setMinimumLogicalFontSize([preferences minimumLogicalFontSize]);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/ChangeLog        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2016-11-04  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        Local HTML should be blocked from localStorage access unless &quot;Disable Local File Restrictions&quot; is checked
+        https://bugs.webkit.org/show_bug.cgi?id=155185
+        &lt;rdar://problem/11101440&gt;
+
+        Reviewed by Brady Eidson.
+
+        Provide SPI to access the new quirk for localStorage. The quirk defaults to 'on'. When active, this
+        quirk says that localStorage access should be granted, without needing to grant universal file access.
+
+        If the quirk is turned off, then localStorage is blocked unless the WebKit client explicitly
+        grants universal file access.
+        
+        Tested by existing TestWebKitAPI tests and WebKit2.LocalStorageQuirkTest
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetNeedsLocalStorageQuirk): Added.
+        (WKPreferencesGetNeedsLocalStorageQuirk): Added.
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]): Honor the new localStorage quirk.
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]): Honor the new localStorage quirk flag.
+        (-[WKWebViewConfiguration copyWithZone:]): Ditto.
+        (-[WKWebViewConfiguration _needsLocalStorageQuirk]): Added.
+        (-[WKWebViewConfiguration _setNeedsLocalStorageQuirk:]): Added.
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleSetNeedsLocalStorageQuirk): Added.
+        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::setNeedsLocalStorageQuirk): Added.
+        * WebProcess/InjectedBundle/InjectedBundle.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences): Honor the new localStorage quirk flag.
+
</ins><span class="cx"> 2016-11-09  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement visual-viewport based position:fixed handling for Mac async scrolling
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPreferencesDefinitionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -233,6 +233,7 @@
</span><span class="cx">     macro(ApplePayEnabled, applePayEnabled, Bool, bool, false, &quot;&quot;, &quot;&quot;) \
</span><span class="cx">     macro(ApplePayCapabilityDisclosureAllowed, applePayCapabilityDisclosureAllowed, Bool, bool, true, &quot;&quot;, &quot;&quot;) \
</span><span class="cx">     macro(VisualViewportEnabled, visualViewportEnabled, Bool, bool, false, &quot;&quot;, &quot;&quot;) \
</span><ins>+    macro(NeedsStorageAccessFromFileURLsQuirk, needsStorageAccessFromFileURLsQuirk, Bool, bool, true, &quot;&quot;, &quot;&quot;) \
</ins><span class="cx">     macro(AsyncImageDecodingEnabled, asyncImageDecodingEnabled, Bool, bool, true, &quot;&quot;, &quot;&quot;) \
</span><span class="cx">     macro(CustomElementsEnabled, customElementsEnabled, Bool, bool, true, &quot;&quot;, &quot;&quot;) \
</span><span class="cx">     \
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPreferencescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -733,6 +733,16 @@
</span><span class="cx">     return toImpl(preferencesRef)-&gt;allowFileAccessFromFileURLs();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WKPreferencesSetNeedsStorageAccessFromFileURLsQuirk(WKPreferencesRef preferencesRef, bool needsQuirk)
+{
+    toImpl(preferencesRef)-&gt;setNeedsStorageAccessFromFileURLsQuirk(needsQuirk);
+}
+
+bool WKPreferencesGetNeedsStorageAccessFromFileURLsQuirk(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)-&gt;needsStorageAccessFromFileURLsQuirk();
+}
+
</ins><span class="cx"> void WKPreferencesSetHixie76WebSocketProtocolEnabled(WKPreferencesRef, bool /*enabled*/)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPreferencesRefPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -168,6 +168,10 @@
</span><span class="cx"> WK_EXPORT void WKPreferencesSetFileAccessFromFileURLsAllowed(WKPreferencesRef preferences, bool allowed);
</span><span class="cx"> WK_EXPORT bool WKPreferencesGetFileAccessFromFileURLsAllowed(WKPreferencesRef preferences);
</span><span class="cx"> 
</span><ins>+// Defaults to true
+WK_EXPORT void WKPreferencesSetNeedsStorageAccessFromFileURLsQuirk(WKPreferencesRef preferences, bool needsQuirk);
+WK_EXPORT bool WKPreferencesGetNeedsStorageAccessFromFileURLsQuirk(WKPreferencesRef preferences);
+
</ins><span class="cx"> // Defaults to true.
</span><span class="cx"> WK_EXPORT void WKPreferencesSetHixie76WebSocketProtocolEnabled(WKPreferencesRef preferencesRef, bool enabled);
</span><span class="cx"> WK_EXPORT bool WKPreferencesGetHixie76WebSocketProtocolEnabled(WKPreferencesRef preferencesRef);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -498,6 +498,8 @@
</span><span class="cx">     pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::applePayEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _applePayEnabled]));
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::needsStorageAccessFromFileURLsQuirkKey(), WebKit::WebPreferencesStore::Value(!![_configuration _needsStorageAccessFromFileURLsQuirk]));
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     CGRect bounds = self.bounds;
</span><span class="cx">     _scrollView = adoptNS([[WKScrollView alloc] initWithFrame:bounds]);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -128,6 +128,7 @@
</span><span class="cx"> #if ENABLE(APPLE_PAY)
</span><span class="cx">     BOOL _applePayEnabled;
</span><span class="cx"> #endif
</span><ins>+    BOOL _needsStorageAccessFromFileURLsQuirk;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)init
</span><span class="lines">@@ -187,6 +188,7 @@
</span><span class="cx">     _allowsMetaRefresh = YES;
</span><span class="cx">     _allowUniversalAccessFromFileURLs = NO;
</span><span class="cx">     _treatsSHA1SignedCertificatesAsInsecure = YES;
</span><ins>+    _needsStorageAccessFromFileURLsQuirk = YES;
</ins><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -313,6 +315,7 @@
</span><span class="cx"> #if ENABLE(APPLE_PAY)
</span><span class="cx">     configuration-&gt;_applePayEnabled = self-&gt;_applePayEnabled;
</span><span class="cx"> #endif
</span><ins>+    configuration-&gt;_needsStorageAccessFromFileURLsQuirk = self-&gt;_needsStorageAccessFromFileURLsQuirk;
</ins><span class="cx"> 
</span><span class="cx">     return configuration;
</span><span class="cx"> }
</span><span class="lines">@@ -727,6 +730,16 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)_needsStorageAccessFromFileURLsQuirk
+{
+    return _needsStorageAccessFromFileURLsQuirk;
+}
+
+- (void)_setNeedsStorageAccessFromFileURLsQuirk:(BOOL)needsLocalStorageQuirk
+{
+    _needsStorageAccessFromFileURLsQuirk = needsLocalStorageQuirk;
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WKWebViewConfiguration (WKDeprecated)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> @property (nonatomic, setter=_setConvertsPositionStyleOnCopy:) BOOL _convertsPositionStyleOnCopy WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span><span class="cx"> @property (nonatomic, setter=_setAllowsMetaRefresh:) BOOL _allowsMetaRefresh WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span><span class="cx"> @property (nonatomic, setter=_setAllowUniversalAccessFromFileURLs:) BOOL _allowUniversalAccessFromFileURLs WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span><ins>+@property (nonatomic, setter=_setNeedsStorageAccessFromFileURLsQuirk:) BOOL _needsStorageAccessFromFileURLsQuirk WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</ins><span class="cx"> @property (nonatomic, setter=_setMainContentUserGestureOverrideEnabled:) BOOL _mainContentUserGestureOverrideEnabled WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span><span class="cx"> @property (nonatomic, setter=_setInvisibleAutoplayNotPermitted:) BOOL _invisibleAutoplayNotPermitted WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span><span class="cx"> @property (nonatomic, setter=_setMediaDataLoadsAutomatically:) BOOL _mediaDataLoadsAutomatically WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -135,6 +135,11 @@
</span><span class="cx">     toImpl(bundleRef)-&gt;setAllowFileAccessFromFileURLs(toImpl(pageGroupRef), enabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WKBundleSetAllowStorageAccessFromFileURLS(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool needsQuirk)
+{
+    toImpl(bundleRef)-&gt;setNeedsStorageAccessFromFileURLsQuirk(toImpl(pageGroupRef), needsQuirk);
+}
+
</ins><span class="cx"> void WKBundleSetMinimumLogicalFontSize(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, int size)
</span><span class="cx"> {
</span><span class="cx">     toImpl(bundleRef)-&gt;setMinimumLogicalFontSize(toImpl(pageGroupRef), size);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundlePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> WK_EXPORT void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef preference, bool enabled);
</span><span class="cx"> WK_EXPORT void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
</span><span class="cx"> WK_EXPORT void WKBundleSetAllowFileAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
</span><ins>+WK_EXPORT void WKBundleSetAllowStorageAccessFromFileURLS(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool needsQuirk);
</ins><span class="cx"> WK_EXPORT void WKBundleSetMinimumLogicalFontSize(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, int size);
</span><span class="cx"> WK_EXPORT void WKBundleSetFrameFlatteningEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
</span><span class="cx"> WK_EXPORT void WKBundleSetPluginsEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleInjectedBundlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -281,6 +281,13 @@
</span><span class="cx">         (*iter)-&gt;settings().setAllowFileAccessFromFileURLs(enabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void InjectedBundle::setNeedsStorageAccessFromFileURLsQuirk(WebPageGroupProxy* pageGroup, bool needsQuirk)
+{
+    const HashSet&lt;Page*&gt;&amp; pages = PageGroup::pageGroup(pageGroup-&gt;identifier())-&gt;pages();
+    for (auto page : pages)
+        page-&gt;settings().setNeedsStorageAccessFromFileURLsQuirk(needsQuirk);
+}
+
</ins><span class="cx"> void InjectedBundle::setMinimumLogicalFontSize(WebPageGroupProxy* pageGroup, int size)
</span><span class="cx"> {
</span><span class="cx">     const HashSet&lt;Page*&gt;&amp; pages = PageGroup::pageGroup(pageGroup-&gt;identifier())-&gt;pages();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleInjectedBundleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -102,6 +102,7 @@
</span><span class="cx">     void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled);
</span><span class="cx">     void setAllowUniversalAccessFromFileURLs(WebPageGroupProxy*, bool);
</span><span class="cx">     void setAllowFileAccessFromFileURLs(WebPageGroupProxy*, bool);
</span><ins>+    void setNeedsStorageAccessFromFileURLsQuirk(WebPageGroupProxy*, bool);
</ins><span class="cx">     void setMinimumLogicalFontSize(WebPageGroupProxy*, int size);
</span><span class="cx">     void setFrameFlatteningEnabled(WebPageGroupProxy*, bool);
</span><span class="cx">     void setPluginsEnabled(WebPageGroupProxy*, bool);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -2980,6 +2980,7 @@
</span><span class="cx">     settings.setWebSecurityEnabled(store.getBoolValueForKey(WebPreferencesKey::webSecurityEnabledKey()));
</span><span class="cx">     settings.setAllowUniversalAccessFromFileURLs(store.getBoolValueForKey(WebPreferencesKey::allowUniversalAccessFromFileURLsKey()));
</span><span class="cx">     settings.setAllowFileAccessFromFileURLs(store.getBoolValueForKey(WebPreferencesKey::allowFileAccessFromFileURLsKey()));
</span><ins>+    settings.setNeedsStorageAccessFromFileURLsQuirk(store.getBoolValueForKey(WebPreferencesKey::needsStorageAccessFromFileURLsQuirkKey()));
</ins><span class="cx"> 
</span><span class="cx">     settings.setMinimumFontSize(store.getDoubleValueForKey(WebPreferencesKey::minimumFontSizeKey()));
</span><span class="cx">     settings.setMinimumLogicalFontSize(store.getDoubleValueForKey(WebPreferencesKey::minimumLogicalFontSizeKey()));
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/ChangeLog        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-11-04  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        Local HTML should be blocked from localStorage access unless &quot;Disable Local File Restrictions&quot; is checked
+        https://bugs.webkit.org/show_bug.cgi?id=155185
+        &lt;rdar://problem/11101440&gt;
+
+        Reviewed by Brady Eidson.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (setNeedsLocalStorageQuirkCallback): Added.
+        (TestRunner::staticFunctions):
+        * DumpRenderTree/TestRunner.h:
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebPreferencesToConsistentValues): Update for new quirk setting.
+        * DumpRenderTree/mac/TestRunnerMac.mm:
+        (TestRunner::setNeedsLocalStorageQuirk):
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageNullEntries.mm:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkEnabled.html: Added.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkTest.mm: Added.
+        (-[LocalStorageQuirkMessageHandler userContentController:didReceiveScriptMessage:]):
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::beginTesting): Update for new quirk setting.
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setNeedsLocalStorageQuirk): Added.
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+
</ins><span class="cx"> 2016-11-09  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         URLParser should not consider path of URLs with no host to start at the first slash after the colon
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreeTestRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/TestRunner.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/TestRunner.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/DumpRenderTree/TestRunner.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1218,6 +1218,18 @@
</span><span class="cx">     return JSValueMakeUndefined(context);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static JSValueRef setNeedsStorageAccessFromFileURLsQuirkCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac &amp; windows implementation
+    if (argumentCount &lt; 1)
+        return JSValueMakeUndefined(context);
+    
+    TestRunner* controller = static_cast&lt;TestRunner*&gt;(JSObjectGetPrivate(thisObject));
+    controller-&gt;setNeedsStorageAccessFromFileURLsQuirk(JSValueToBoolean(context, arguments[0]));
+    
+    return JSValueMakeUndefined(context);
+}
+
</ins><span class="cx"> static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
</span><span class="cx"> {
</span><span class="cx">     // Has mac &amp; windows implementation
</span><span class="lines">@@ -2125,6 +2137,7 @@
</span><span class="cx">         { &quot;setAcceptsEditing&quot;, setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
</span><span class="cx">         { &quot;setAllowUniversalAccessFromFileURLs&quot;, setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
</span><span class="cx">         { &quot;setAllowFileAccessFromFileURLs&quot;, setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
</span><ins>+        { &quot;setNeedsStorageAccessFromFileURLsQuirk&quot;, setNeedsStorageAccessFromFileURLsQuirkCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
</ins><span class="cx">         { &quot;setAllowsAnySSLCertificate&quot;, setAllowsAnySSLCertificateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
</span><span class="cx">         { &quot;setAlwaysAcceptCookies&quot;, setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
</span><span class="cx">         { &quot;setAppCacheMaximumSize&quot;, setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreeTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/TestRunner.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/TestRunner.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/DumpRenderTree/TestRunner.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -94,6 +94,7 @@
</span><span class="cx">     void setFetchAPIEnabled(bool);
</span><span class="cx">     void setAllowUniversalAccessFromFileURLs(bool);
</span><span class="cx">     void setAllowFileAccessFromFileURLs(bool);
</span><ins>+    void setNeedsStorageAccessFromFileURLsQuirk(bool);
</ins><span class="cx">     void setAppCacheMaximumSize(unsigned long long quota);
</span><span class="cx">     void setAuthorAndUserStylesEnabled(bool);
</span><span class="cx">     void setCacheModel(int);
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacDumpRenderTreemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -899,6 +899,7 @@
</span><span class="cx"> {
</span><span class="cx">     WebPreferences *preferences = [WebPreferences standardPreferences];
</span><span class="cx"> 
</span><ins>+    [preferences setNeedsStorageAccessFromFileURLsQuirk: NO];
</ins><span class="cx">     [preferences setAllowUniversalAccessFromFileURLs:YES];
</span><span class="cx">     [preferences setAllowFileAccessFromFileURLs:YES];
</span><span class="cx">     [preferences setStandardFontFamily:@&quot;Times&quot;];
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacTestRunnerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -503,6 +503,11 @@
</span><span class="cx">     [[[mainFrame webView] preferences] setAllowFileAccessFromFileURLs:enabled];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TestRunner::setNeedsStorageAccessFromFileURLsQuirk(bool needsQuirk)
+{
+    [[[mainFrame webView] preferences] setNeedsStorageAccessFromFileURLsQuirk:needsQuirk];
+}
+
</ins><span class="cx"> void TestRunner::setPopupBlockingEnabled(bool popupBlockingEnabled)
</span><span class="cx"> {
</span><span class="cx">     [[[mainFrame webView] preferences] setJavaScriptCanOpenWindowsAutomatically:!popupBlockingEnabled];
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -169,6 +169,8 @@
</span><span class="cx">                 7A010BCB1D877C0500EDE72A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A010BCA1D877C0500EDE72A /* CoreGraphics.framework */; };
</span><span class="cx">                 7A010BCD1D877C0D00EDE72A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A010BCC1D877C0D00EDE72A /* QuartzCore.framework */; };
</span><span class="cx">                 7A1458FC1AD5C07000E06772 /* mouse-button-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */; };
</span><ins>+                7A6A2C701DCCFA8C00C0D085 /* LocalStorageQuirkTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */; };
+                7A6A2C721DCCFB5200C0D085 /* LocalStorageQuirkEnabled.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7A6A2C711DCCFB0200C0D085 /* LocalStorageQuirkEnabled.html */; };
</ins><span class="cx">                 7A909A7D1D877480007E10F8 /* AffineTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A909A6F1D877475007E10F8 /* AffineTransform.cpp */; };
</span><span class="cx">                 7A909A7E1D877480007E10F8 /* FloatPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A909A701D877475007E10F8 /* FloatPoint.cpp */; };
</span><span class="cx">                 7A909A7F1D877480007E10F8 /* FloatRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A909A711D877475007E10F8 /* FloatRect.cpp */; };
</span><span class="lines">@@ -666,6 +668,7 @@
</span><span class="cx">                                 46C519E61D3563FD00DAA51A /* LocalStorageNullEntries.html in Copy Resources */,
</span><span class="cx">                                 46C519E71D3563FD00DAA51A /* LocalStorageNullEntries.localstorage in Copy Resources */,
</span><span class="cx">                                 46C519E81D3563FD00DAA51A /* LocalStorageNullEntries.localstorage-shm in Copy Resources */,
</span><ins>+                                7A6A2C721DCCFB5200C0D085 /* LocalStorageQuirkEnabled.html in Copy Resources */,
</ins><span class="cx">                                 9361002914DC95A70061379D /* lots-of-iframes.html in Copy Resources */,
</span><span class="cx">                                 93AF4ED11506F130007FD57E /* lots-of-images.html in Copy Resources */,
</span><span class="cx">                                 2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */,
</span><span class="lines">@@ -969,6 +972,8 @@
</span><span class="cx">                 7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;mouse-button-listener.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashCountedSet.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7A5623101AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MenuTypesForMouseEvents.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageQuirkTest.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                7A6A2C711DCCFB0200C0D085 /* LocalStorageQuirkEnabled.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LocalStorageQuirkEnabled.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7A909A6F1D877475007E10F8 /* AffineTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AffineTransform.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7A909A701D877475007E10F8 /* FloatPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatPoint.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7A909A711D877475007E10F8 /* FloatRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatRect.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1415,6 +1420,7 @@
</span><span class="cx">                                 57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */,
</span><span class="cx">                                 51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */,
</span><span class="cx">                                 46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */,
</span><ins>+                                7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */,
</ins><span class="cx">                                 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */,
</span><span class="cx">                                 1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
</span><span class="cx">                                 2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */,
</span><span class="lines">@@ -1588,6 +1594,7 @@
</span><span class="cx">                                 2E1DFDEC1D42A41C00714A00 /* large-videos-with-audio.html */,
</span><span class="cx">                                 51E6A8951D2F1C7700C004B6 /* LocalStorageClear.html */,
</span><span class="cx">                                 46C519E21D35629600DAA51A /* LocalStorageNullEntries.html */,
</span><ins>+                                7A6A2C711DCCFB0200C0D085 /* LocalStorageQuirkEnabled.html */,
</ins><span class="cx">                                 46C519E31D35629600DAA51A /* LocalStorageNullEntries.localstorage */,
</span><span class="cx">                                 46C519E41D35629600DAA51A /* LocalStorageNullEntries.localstorage-shm */,
</span><span class="cx">                                 7CCB99221D3B44E7003922F6 /* open-multiple-external-url.html */,
</span><span class="lines">@@ -2539,6 +2546,7 @@
</span><span class="cx">                                 7CCE7ED31A411A7E00447C4C /* TypingStyleCrash.mm in Sources */,
</span><span class="cx">                                 7CCE7EDE1A411A9200447C4C /* URL.cpp in Sources */,
</span><span class="cx">                                 7CCE7EB01A411A4400447C4C /* URLExtras.mm in Sources */,
</span><ins>+                                7A6A2C701DCCFA8C00C0D085 /* LocalStorageQuirkTest.mm in Sources */,
</ins><span class="cx">                                 2DFF7B6D1DA487AF00814614 /* SnapshotStore.mm in Sources */,
</span><span class="cx">                                 5C6E65441D5CEFD400F7862E /* URLParser.cpp in Sources */,
</span><span class="cx">                                 7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CloseFromWithinCreatePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaLocalStorageClearmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx">     RetainPtr&lt;WKWebViewConfiguration&gt; configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><span class="cx">     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@&quot;testHandler&quot;];
</span><span class="cx"> 
</span><ins>+    [configuration _setNeedsStorageAccessFromFileURLsQuirk:NO];
</ins><span class="cx">     [configuration _setAllowUniversalAccessFromFileURLs:YES];
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaLocalStorageNullEntriesmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageNullEntries.mm (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageNullEntries.mm        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageNullEntries.mm        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx">     RetainPtr&lt;WKWebViewConfiguration&gt; configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><span class="cx">     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@&quot;testHandler&quot;];
</span><span class="cx"> 
</span><ins>+    [configuration _setNeedsStorageAccessFromFileURLsQuirk:NO];
</ins><span class="cx">     [configuration _setAllowUniversalAccessFromFileURLs:YES];
</span><span class="cx"> 
</span><span class="cx">     // Copy the inconsistent database files to the LocalStorage directory
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaLocalStorageQuirkEnabledhtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkEnabled.html (0 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkEnabled.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkEnabled.html        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+&lt;script&gt;
+
+try {
+    if (window.localStorage)
+        window.webkit.messageHandlers.testHandler.postMessage('PASS');
+} catch(e) {
+    window.webkit.messageHandlers.testHandler.postMessage('FAIL');
+}
+
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaLocalStorageQuirkTestmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkTest.mm (0 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkTest.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageQuirkTest.mm        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -0,0 +1,125 @@
</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.
+ */
+
+#import &quot;config.h&quot;
+
+#import &quot;PlatformUtilities.h&quot;
+#import &quot;Test.h&quot;
+#import &lt;WebKit/WKProcessPoolPrivate.h&gt;
+#import &lt;WebKit/WKUserContentControllerPrivate.h&gt;
+#import &lt;WebKit/WKWebViewConfigurationPrivate.h&gt;
+#import &lt;WebKit/WebKit.h&gt;
+#import &lt;WebKit/_WKProcessPoolConfiguration.h&gt;
+#import &lt;WebKit/_WKUserStyleSheet.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+#if WK_API_ENABLED
+
+static bool readyToContinue;
+static RetainPtr&lt;WKScriptMessage&gt; lastScriptMessage;
+
+@interface LocalStorageQuirkMessageHandler : NSObject &lt;WKScriptMessageHandler&gt;
+@end
+
+@implementation LocalStorageQuirkMessageHandler
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+    lastScriptMessage = message;
+    readyToContinue = true;
+}
+
+@end
+
+TEST(WKWebView, LocalStorageQuirkEnabled)
+{
+    RetainPtr&lt;LocalStorageQuirkMessageHandler&gt; handler = adoptNS([[LocalStorageQuirkMessageHandler alloc] init]);
+    RetainPtr&lt;WKWebViewConfiguration&gt; configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:handler.get() name:@&quot;testHandler&quot;];
+
+    // Test that the quirk permits us to access the local storage, even though local file access is disabled.
+    [configuration _setNeedsStorageAccessFromFileURLsQuirk:YES];
+    [configuration _setAllowUniversalAccessFromFileURLs:NO];
+
+    RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;LocalStorageQuirkEnabled&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+    [webView loadRequest:request];
+
+    readyToContinue = false;
+    TestWebKitAPI::Util::run(&amp;readyToContinue);
+
+    webView = nil;
+
+    EXPECT_STREQ([(NSString *)[lastScriptMessage body] UTF8String], &quot;PASS&quot;);
+}
+
+TEST(WKWebView, LocalStorageQuirkDisabledAccessPermitted)
+{
+    RetainPtr&lt;LocalStorageQuirkMessageHandler&gt; handler = adoptNS([[LocalStorageQuirkMessageHandler alloc] init]);
+    RetainPtr&lt;WKWebViewConfiguration&gt; configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:handler.get() name:@&quot;testHandler&quot;];
+    
+    // Test that the quirk permits us to access the local storage, even though local file access is disabled.
+    [configuration _setNeedsStorageAccessFromFileURLsQuirk:NO];
+    [configuration _setAllowUniversalAccessFromFileURLs:YES];
+    
+    RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+    
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;LocalStorageQuirkEnabled&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+    [webView loadRequest:request];
+    
+    readyToContinue = false;
+    TestWebKitAPI::Util::run(&amp;readyToContinue);
+    
+    webView = nil;
+    
+    EXPECT_STREQ([(NSString *)[lastScriptMessage body] UTF8String], &quot;PASS&quot;);
+}
+
+TEST(WKWebView, LocalStorageQuirkDisabledAccessDenied)
+{
+    RetainPtr&lt;LocalStorageQuirkMessageHandler&gt; handler = adoptNS([[LocalStorageQuirkMessageHandler alloc] init]);
+    RetainPtr&lt;WKWebViewConfiguration&gt; configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:handler.get() name:@&quot;testHandler&quot;];
+    
+    // Test that the quirk permits us to access the local storage, even though local file access is disabled.
+    [configuration _setNeedsStorageAccessFromFileURLsQuirk:NO];
+    [configuration _setAllowUniversalAccessFromFileURLs:NO];
+    
+    RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+    
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;LocalStorageQuirkEnabled&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+    [webView loadRequest:request];
+    
+    readyToContinue = false;
+    TestWebKitAPI::Util::run(&amp;readyToContinue);
+    
+    webView = nil;
+    
+    EXPECT_STREQ([(NSString *)[lastScriptMessage body] UTF8String], &quot;FAIL&quot;);
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx">     void setXSSAuditorEnabled(boolean value);
</span><span class="cx">     void setAllowUniversalAccessFromFileURLs(boolean value);
</span><span class="cx">     void setAllowFileAccessFromFileURLs(boolean value);
</span><ins>+    void setNeedsStorageAccessFromFileURLsQuirk(boolean value);
</ins><span class="cx">     void setPluginsEnabled(boolean value);
</span><span class="cx">     void setJavaScriptCanAccessClipboard(boolean value);
</span><span class="cx">     void setPrivateBrowsingEnabled(boolean value);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -305,6 +305,7 @@
</span><span class="cx">     WKBundleSetAllowFileAccessFromFileURLs(m_bundle, m_pageGroup, true);
</span><span class="cx">     WKBundleSetPluginsEnabled(m_bundle, m_pageGroup, true);
</span><span class="cx">     WKBundleSetPopupBlockingEnabled(m_bundle, m_pageGroup, false);
</span><ins>+    WKBundleSetAllowStorageAccessFromFileURLS(m_bundle, m_pageGroup, false);
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     WKBundlePageSetUseTestingViewportConfiguration(page()-&gt;page(), !booleanForKey(settings, &quot;UseFlexibleViewport&quot;));
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -406,6 +406,12 @@
</span><span class="cx">     WKBundleSetAllowFileAccessFromFileURLs(injectedBundle.bundle(), injectedBundle.pageGroup(), enabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TestRunner::setNeedsStorageAccessFromFileURLsQuirk(bool needsQuirk)
+{
+    auto&amp; injectedBundle = InjectedBundle::singleton();
+    WKBundleSetAllowStorageAccessFromFileURLS(injectedBundle.bundle(), injectedBundle.pageGroup(), needsQuirk);
+}
+    
</ins><span class="cx"> void TestRunner::setPluginsEnabled(bool enabled)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; injectedBundle = InjectedBundle::singleton();
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (208508 => 208509)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h        2016-11-10 00:30:31 UTC (rev 208508)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h        2016-11-10 00:58:35 UTC (rev 208509)
</span><span class="lines">@@ -107,6 +107,7 @@
</span><span class="cx">     void setFetchAPIEnabled(bool);
</span><span class="cx">     void setAllowUniversalAccessFromFileURLs(bool);
</span><span class="cx">     void setAllowFileAccessFromFileURLs(bool);
</span><ins>+    void setNeedsStorageAccessFromFileURLsQuirk(bool);
</ins><span class="cx">     void setPluginsEnabled(bool);
</span><span class="cx">     void setJavaScriptCanAccessClipboard(bool);
</span><span class="cx">     void setPrivateBrowsingEnabled(bool);
</span></span></pre>
</div>
</div>

</body>
</html>