<!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>[171665] branches/safari-600.1-branch</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/171665">171665</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2014-07-27 17:48:18 -0700 (Sun, 27 Jul 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/171661">r171661</a>. <rdar://problem/17315237></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6001branchLayoutTestsChangeLog">branches/safari-600.1-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6001branchSourceWebCoreChangeLog">branches/safari-600.1-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6001branchSourceWebCorepageDOMWindowcpp">branches/safari-600.1-branch/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#branchessafari6001branchSourceWebCorepagePagecpp">branches/safari-600.1-branch/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#branchessafari6001branchSourceWebCorepagePageh">branches/safari-600.1-branch/Source/WebCore/page/Page.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageaccessstorageafterwindowcloseexpectedtxt">branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close-expected.txt</a></li>
<li><a href="#branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageaccessstorageafterwindowclosehtml">branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close.html</a></li>
<li><a href="#branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageaccessstoragethensetvalueinstorageafterwindowcloseexpectedtxt">branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close-expected.txt</a></li>
<li><a href="#branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageaccessstoragethensetvalueinstorageafterwindowclosehtml">branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close.html</a></li>
<li><a href="#branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageresourcesaccessstorageclosewindowandsetvalueinstoragehtml">branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/access-storage-close-window-and-set-value-in-storage.html</a></li>
<li><a href="#branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageresourcesclosewindowandaccessstoragehtml">branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-access-storage.html</a></li>
<li><a href="#branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageresourcesclosewindowandsetvalueinstoragehtml">branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-set-value-in-storage.html</a></li>
<li><a href="#branchessafari6001branchLayoutTestsstoragedomstoragelocalstoragesetvalueinstorageafterwindowcloseexpectedtxt">branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close-expected.txt</a></li>
<li><a href="#branchessafari6001branchLayoutTestsstoragedomstoragelocalstoragesetvalueinstorageafterwindowclosehtml">branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6001branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/LayoutTests/ChangeLog (171664 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/ChangeLog        2014-07-28 00:45:01 UTC (rev 171664)
+++ branches/safari-600.1-branch/LayoutTests/ChangeLog        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -1,5 +1,33 @@
</span><span class="cx"> 2014-07-27 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r171661. <rdar://problem/17315237>
+
+ 2014-07-27 Daniel Bates <dabates@apple.com>
+
+ [WK2] Crash when accessing window.localStorage after calling window.close()
+ https://bugs.webkit.org/show_bug.cgi?id=135328
+ <rdar://problem/17315237>
+
+ Reviewed by Sam Weinig.
+
+ Added test by Andy Estes, LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close.html,
+ to ensure that we don't crash when accessing local storage for the first time after calling window.close().
+
+ Additionally added tests that ensure that updates to local storage are ignored after calling
+ window.close() regardless of whether local storage was accessed before the call to window.close().
+
+ * storage/domstorage/localstorage/access-storage-after-window-close-expected.txt: Added.
+ * storage/domstorage/localstorage/access-storage-after-window-close.html: Added.
+ * storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close-expected.txt: Added.
+ * storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close.html: Added.
+ * storage/domstorage/localstorage/resources/access-storage-close-window-and-set-value-in-storage.html: Added.
+ * storage/domstorage/localstorage/resources/close-window-and-access-storage.html: Added.
+ * storage/domstorage/localstorage/resources/close-window-and-set-value-in-storage.html: Added.
+ * storage/domstorage/localstorage/set-value-in-storage-after-window-close-expected.txt: Added.
+ * storage/domstorage/localstorage/set-value-in-storage-after-window-close.html: Added.
+
+2014-07-27 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r171640. <rdar://problem/17812921>
</span><span class="cx">
</span><span class="cx"> 2014-07-25 Zalan Bujtas <zalan@apple.com>
</span></span></pre></div>
<a id="branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageaccessstorageafterwindowcloseexpectedtxtfromrev171661trunkLayoutTestsstoragedomstoragelocalstorageaccessstorageafterwindowcloseexpectedtxt"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close-expected.txt (from rev 171661, trunk/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close-expected.txt) (0 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close-expected.txt         (rev 0)
+++ branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close-expected.txt        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+Test that WebKit does not crash when accessing localStorage after calling window.close().
+
</ins></span></pre></div>
<a id="branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageaccessstorageafterwindowclosehtmlfromrev171661trunkLayoutTestsstoragedomstoragelocalstorageaccessstorageafterwindowclosehtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close.html (from rev 171661, trunk/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close.html) (0 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close.html         (rev 0)
+++ branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-after-window-close.html        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+<html>
+<head>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.setCanOpenWindows();
+ testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body onload="window.open('resources/close-window-and-access-storage.html');">
+Test that WebKit does not crash when accessing localStorage after calling window.close().<br>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageaccessstoragethensetvalueinstorageafterwindowcloseexpectedtxtfromrev171661trunkLayoutTestsstoragedomstoragelocalstorageaccessstoragethensetvalueinstorageafterwindowcloseexpectedtxt"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close-expected.txt (from rev 171661, trunk/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close-expected.txt) (0 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close-expected.txt         (rev 0)
+++ branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close-expected.txt        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Tests that we can't store a value in local storage after calling window.close() even if we created the local storage before the call to window.close().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.localStorage is defined.
+PASS window.localStorage["test"] is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageaccessstoragethensetvalueinstorageafterwindowclosehtmlfromrev171661trunkLayoutTestsstoragedomstoragelocalstorageaccessstoragethensetvalueinstorageafterwindowclosehtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close.html (from rev 171661, trunk/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close.html) (0 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close.html         (rev 0)
+++ branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close.html        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<script>
+window.jsTestIsAsync = true;
+
+if (window.testRunner) {
+ testRunner.setCanOpenWindows();
+
+ // We explicitly call testRunner.waitUntilDone() because we call window.open() before
+ // js-test-post.js is processed.
+ testRunner.waitUntilDone();
+}
+
+function checkResultAndNotifyDone()
+{
+ shouldBeDefined('window.localStorage');
+ shouldBeUndefined('window.localStorage["test"]');
+ window.localStorage.clear();
+ finishJSTest();
+}
+</script>
+</head>
+<body>
+<script>
+description("Tests that we can't store a value in local storage after calling window.close() even if we created the local storage before the call to window.close().");
+window.open("resources/access-storage-close-window-and-set-value-in-storage.html");
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageresourcesaccessstorageclosewindowandsetvalueinstoragehtmlfromrev171661trunkLayoutTestsstoragedomstoragelocalstorageresourcesaccessstorageclosewindowandsetvalueinstoragehtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/access-storage-close-window-and-set-value-in-storage.html (from rev 171661, trunk/LayoutTests/storage/domstorage/localstorage/resources/access-storage-close-window-and-set-value-in-storage.html) (0 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/access-storage-close-window-and-set-value-in-storage.html         (rev 0)
+++ branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/access-storage-close-window-and-set-value-in-storage.html        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script>
+window.localStorage; // Creates local storage
+window.close();
+if (window.localStorage)
+ localStorage["test"] = "DidSetValueAfterCallingWindowClose";
+window.opener.checkResultAndNotifyDone();
+</script>
+</head>
+</html>
</ins></span></pre></div>
<a id="branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageresourcesclosewindowandaccessstoragehtmlfromrev171661trunkLayoutTestsstoragedomstoragelocalstorageresourcesclosewindowandaccessstoragehtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-access-storage.html (from rev 171661, trunk/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-access-storage.html) (0 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-access-storage.html         (rev 0)
+++ branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-access-storage.html        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<html>
+<head>
+<script>
+window.close();
+window.localStorage;
+if (window.testRunner)
+ testRunner.notifyDone();
+</script>
+</head>
+</html>
</ins></span></pre></div>
<a id="branchessafari6001branchLayoutTestsstoragedomstoragelocalstorageresourcesclosewindowandsetvalueinstoragehtmlfromrev171661trunkLayoutTestsstoragedomstoragelocalstorageresourcesclosewindowandsetvalueinstoragehtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-set-value-in-storage.html (from rev 171661, trunk/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-set-value-in-storage.html) (0 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-set-value-in-storage.html         (rev 0)
+++ branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/resources/close-window-and-set-value-in-storage.html        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script>
+window.close();
+if (window.localStorage)
+ localStorage["test"] = "DidSetValueAfterCallingWindowClose";
+window.opener.checkResultAndNotifyDone();
+</script>
+</head>
+</html>
</ins></span></pre></div>
<a id="branchessafari6001branchLayoutTestsstoragedomstoragelocalstoragesetvalueinstorageafterwindowcloseexpectedtxtfromrev171661trunkLayoutTestsstoragedomstoragelocalstoragesetvalueinstorageafterwindowcloseexpectedtxt"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close-expected.txt (from rev 171661, trunk/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close-expected.txt) (0 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close-expected.txt         (rev 0)
+++ branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close-expected.txt        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Tests that we can't store a value in local storage after calling window.close().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.localStorage is defined.
+PASS window.localStorage["test"] is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="branchessafari6001branchLayoutTestsstoragedomstoragelocalstoragesetvalueinstorageafterwindowclosehtmlfromrev171661trunkLayoutTestsstoragedomstoragelocalstoragesetvalueinstorageafterwindowclosehtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close.html (from rev 171661, trunk/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close.html) (0 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close.html         (rev 0)
+++ branches/safari-600.1-branch/LayoutTests/storage/domstorage/localstorage/set-value-in-storage-after-window-close.html        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<script>
+window.jsTestIsAsync = true;
+
+if (window.testRunner) {
+ testRunner.setCanOpenWindows();
+
+ // We explicitly call testRunner.waitUntilDone() because we call window.open() before
+ // js-test-post.js is processed.
+ testRunner.waitUntilDone();
+}
+
+function checkResultAndNotifyDone()
+{
+ shouldBeDefined('window.localStorage');
+ shouldBeUndefined('window.localStorage["test"]');
+ window.localStorage.clear();
+ finishJSTest();
+}
+</script>
+</head>
+<body>
+<script>
+description("Tests that we can't store a value in local storage after calling window.close().");
+window.open("resources/close-window-and-set-value-in-storage.html");
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari6001branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebCore/ChangeLog (171664 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebCore/ChangeLog        2014-07-28 00:45:01 UTC (rev 171664)
+++ branches/safari-600.1-branch/Source/WebCore/ChangeLog        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -1,5 +1,40 @@
</span><span class="cx"> 2014-07-27 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r171661. <rdar://problem/17315237>
+
+ 2014-07-27 Daniel Bates <dabates@apple.com>
+
+ [WK2] Crash when accessing window.localStorage after calling window.close()
+ https://bugs.webkit.org/show_bug.cgi?id=135328
+ <rdar://problem/17315237>
+
+ Reviewed by Sam Weinig.
+
+ Fixes an issue where accessing local storage for the first time after calling window.close()
+ causes a crash.
+
+ For now, we should disallow accessing local storage after calling window.close() regardless of
+ whether it's the first access to local storage as this seems like a bad idiom to support. Note,
+ this represents a change in behavior from WebKit1. If such usage of window.localStorage turns
+ out to be reasonable then we can visit this decision again in <https://bugs.webkit.org/show_bug.cgi?id=135330>.
+
+ Tests: storage/domstorage/localstorage/access-storage-after-window-close.html
+ storage/domstorage/localstorage/access-storage-then-set-value-in-storage-after-window-close.html
+ storage/domstorage/localstorage/set-value-in-storage-after-window-close.html
+
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::localStorage): Modified to only return the cached local storage or
+ create a new local storage so long as the page isn't being closed. Also, substitute nullptr
+ for 0.
+ (WebCore::DOMWindow::close): Call Page::setIsClosing() to mark that the page is closing.
+ * page/Page.cpp:
+ (WebCore::Page::Page): Initialize m_isClosing to false.
+ * page/Page.h:
+ (WebCore::Page::setIsClosing): Added.
+ (WebCore::Page::isClosing): Added.
+
+2014-07-27 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r171647. <rdar://problem/17315168>
</span><span class="cx">
</span><span class="cx"> 2014-07-26 Timothy Horton <timothy_horton@apple.com>
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebCore/page/DOMWindow.cpp (171664 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebCore/page/DOMWindow.cpp        2014-07-28 00:45:01 UTC (rev 171664)
+++ branches/safari-600.1-branch/Source/WebCore/page/DOMWindow.cpp        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -821,31 +821,38 @@
</span><span class="cx"> Storage* DOMWindow::localStorage(ExceptionCode& ec) const
</span><span class="cx"> {
</span><span class="cx"> if (!isCurrentlyDisplayedInFrame())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> Document* document = this->document();
</span><span class="cx"> if (!document)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> if (!document->securityOrigin()->canAccessLocalStorage(0)) {
</span><span class="cx"> ec = SECURITY_ERR;
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- if (m_localStorage) {
- if (!m_localStorage->area().canAccessStorage(m_frame)) {
- ec = SECURITY_ERR;
- return 0;
</del><ins>+ Page* page = document->page();
+ // FIXME: We should consider supporting access/modification to local storage
+ // after calling window.close(). See <https://bugs.webkit.org/show_bug.cgi?id=135330>.
+ if (!page || !page->isClosing()) {
+ if (m_localStorage) {
+ if (!m_localStorage->area().canAccessStorage(m_frame)) {
+ ec = SECURITY_ERR;
+ return nullptr;
+ }
+ return m_localStorage.get();
</ins><span class="cx"> }
</span><del>- return m_localStorage.get();
</del><span class="cx"> }
</span><span class="cx">
</span><del>- Page* page = document->page();
</del><span class="cx"> if (!page)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><ins>+ if (page->isClosing())
+ return nullptr;
+
</ins><span class="cx"> if (!page->settings().localStorageEnabled())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> RefPtr<StorageArea> storageArea;
</span><span class="cx"> if (!document->securityOrigin()->canAccessLocalStorage(document->topOrigin()))
</span><span class="lines">@@ -855,7 +862,7 @@
</span><span class="cx">
</span><span class="cx"> if (!storageArea->canAccessStorage(m_frame)) {
</span><span class="cx"> ec = SECURITY_ERR;
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> m_localStorage = Storage::create(m_frame, storageArea.release());
</span><span class="lines">@@ -1035,6 +1042,7 @@
</span><span class="cx"> if (!m_frame->loader().shouldClose())
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ page->setIsClosing();
</ins><span class="cx"> page->chrome().closeWindowSoon();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebCore/page/Page.cpp (171664 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebCore/page/Page.cpp        2014-07-28 00:45:01 UTC (rev 171664)
+++ branches/safari-600.1-branch/Source/WebCore/page/Page.cpp        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -201,6 +201,7 @@
</span><span class="cx"> , m_userContentController(WTF::move(pageClients.userContentController))
</span><span class="cx"> , m_visitedLinkStore(WTF::move(pageClients.visitedLinkStore))
</span><span class="cx"> , m_sessionID(SessionID::defaultSessionID())
</span><ins>+ , m_isClosing(false)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(m_editorClient);
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebCore/page/Page.h (171664 => 171665)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebCore/page/Page.h        2014-07-28 00:45:01 UTC (rev 171664)
+++ branches/safari-600.1-branch/Source/WebCore/page/Page.h        2014-07-28 00:48:18 UTC (rev 171665)
</span><span class="lines">@@ -320,6 +320,9 @@
</span><span class="cx"> void setIsInWindow(bool);
</span><span class="cx"> bool isInWindow() const { return m_viewState & ViewState::IsInWindow; }
</span><span class="cx">
</span><ins>+ void setIsClosing() { m_isClosing = true; }
+ bool isClosing() const { return m_isClosing; }
+
</ins><span class="cx"> void addViewStateChangeObserver(ViewStateChangeObserver&);
</span><span class="cx"> void removeViewStateChangeObserver(ViewStateChangeObserver&);
</span><span class="cx">
</span><span class="lines">@@ -585,6 +588,8 @@
</span><span class="cx"> HashSet<ViewStateChangeObserver*> m_viewStateChangeObservers;
</span><span class="cx">
</span><span class="cx"> SessionID m_sessionID;
</span><ins>+
+ bool m_isClosing;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> inline PageGroup& Page::group()
</span></span></pre>
</div>
</div>
</body>
</html>