<!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>[199437] releases/WebKitGTK/webkit-2.12</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/199437">199437</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-04-13 02:11:57 -0700 (Wed, 13 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/198575">r198575</a> - showModalDialog code runs with “first window” set to wrong window
https://bugs.webkit.org/show_bug.cgi?id=155710

Source/WebCore:

Reviewed by Brent Fulgham.

Test: http/tests/security/cross-origin-modal-dialog-base.html

* page/Chrome.cpp:
(WebCore::Chrome::runModal): Null out entryScope so that the &quot;first window&quot;
checks inside the modal dialog won't run in the context of the original window
that presented the dialog.

LayoutTests:

Test by John Wilander.

Reviewed by Brent Fulgham.

* http/tests/security/cross-origin-modal-dialog-base-expected.txt: Added.
* http/tests/security/cross-origin-modal-dialog-base.html: Added.
* http/tests/security/resources/cross-origin-modal-dialog-base-1.html: Added.
* http/tests/security/resources/cross-origin-modal-dialog-base-2.html: Added.
* platform/wk2/TestExpectations: Skip test until we get better showModalDialog support.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit212LayoutTestsChangeLog">releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit212LayoutTestsplatformwk2TestExpectations">releases/WebKitGTK/webkit-2.12/LayoutTests/platform/wk2/TestExpectations</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCorepageChromecpp">releases/WebKitGTK/webkit-2.12/Source/WebCore/page/Chrome.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit212LayoutTestshttptestssecuritycrossoriginmodaldialogbaseexpectedtxt">releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/cross-origin-modal-dialog-base-expected.txt</a></li>
<li><a href="#releasesWebKitGTKwebkit212LayoutTestshttptestssecuritycrossoriginmodaldialogbasehtml">releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/cross-origin-modal-dialog-base.html</a></li>
<li><a href="#releasesWebKitGTKwebkit212LayoutTestshttptestssecurityresourcescrossoriginmodaldialogbase1html">releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/resources/cross-origin-modal-dialog-base-1.html</a></li>
<li><a href="#releasesWebKitGTKwebkit212LayoutTestshttptestssecurityresourcescrossoriginmodaldialogbase2html">releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/resources/cross-origin-modal-dialog-base-2.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit212LayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog (199436 => 199437)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog        2016-04-13 09:09:25 UTC (rev 199436)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog        2016-04-13 09:11:57 UTC (rev 199437)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-03-22  Darin Adler  &lt;darin@apple.com&gt;
+
+        showModalDialog code runs with “first window” set to wrong window
+        https://bugs.webkit.org/show_bug.cgi?id=155710
+
+        Test by John Wilander.
+
+        Reviewed by Brent Fulgham.
+
+        * http/tests/security/cross-origin-modal-dialog-base-expected.txt: Added.
+        * http/tests/security/cross-origin-modal-dialog-base.html: Added.
+        * http/tests/security/resources/cross-origin-modal-dialog-base-1.html: Added.
+        * http/tests/security/resources/cross-origin-modal-dialog-base-2.html: Added.
+        * platform/wk2/TestExpectations: Skip test until we get better showModalDialog support.
+
</ins><span class="cx"> 2016-03-22  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         userSpaceOnUse patterns are not stroked for empty object bounding box elements
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212LayoutTestshttptestssecuritycrossoriginmodaldialogbaseexpectedtxt"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/cross-origin-modal-dialog-base-expected.txt (0 => 199437)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/cross-origin-modal-dialog-base-expected.txt                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/cross-origin-modal-dialog-base-expected.txt        2016-04-13 09:11:57 UTC (rev 199437)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+CONSOLE MESSAGE: line 9: document.location.origin before setting location to a relative path: http://localhost:8000
+CONSOLE MESSAGE: line 18: document.location.origin after setting location to a relative path: http://localhost:8000
+Tests that a modal dialog doesn't fall back to its openers origin when document.location is set to a relative path.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Showing modal dialog.
+Returned from modal dialog.
+If test passed, console messages above should both show the same document.location.origin, .
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit212LayoutTestshttptestssecuritycrossoriginmodaldialogbasehtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/cross-origin-modal-dialog-base.html (0 => 199437)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/cross-origin-modal-dialog-base.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/cross-origin-modal-dialog-base.html        2016-04-13 09:11:57 UTC (rev 199437)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html lang=&quot;en&quot;&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;body&gt;
+&lt;script&gt;
+    if (window.testRunner)
+        testRunner.setCanOpenWindows();
+
+    description(&quot;Tests that a modal dialog doesn't fall back to its openers origin when document.location is set to a relative path.&quot;);
+
+    var triggeredCaptureListener = false;
+    var triggeredBubbleListener = false;
+
+    onload = function () {
+        debug('Showing modal dialog.');
+        showModalDialog('http://localhost:8000/security/resources/cross-origin-modal-dialog-base-1.html');
+        debug('Returned from modal dialog.');
+        debug('If test passed, console messages above should both show the same document.location.origin, &lt;http://localhost:8000&gt;.');
+        finishJSTest();
+    };
+
+    var jsTestIsAsync = true;
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit212LayoutTestshttptestssecurityresourcescrossoriginmodaldialogbase1html"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/resources/cross-origin-modal-dialog-base-1.html (0 => 199437)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/resources/cross-origin-modal-dialog-base-1.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/resources/cross-origin-modal-dialog-base-1.html        2016-04-13 09:11:57 UTC (rev 199437)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html lang=&quot;en&quot;&gt;
+&lt;head&gt;
+    &lt;meta charset=&quot;UTF-8&quot;&gt;
+    &lt;title&gt;Dialog Content, Step 1&lt;/title&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+    console.log(&quot;document.location.origin before setting location to a relative path: &quot; + document.location.origin);
+    document.location = &quot;/security/resources/cross-origin-modal-dialog-base-2.html&quot;;
+&lt;/script&gt;
+This is a modal dialog.
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit212LayoutTestshttptestssecurityresourcescrossoriginmodaldialogbase2html"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/resources/cross-origin-modal-dialog-base-2.html (0 => 199437)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/resources/cross-origin-modal-dialog-base-2.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/http/tests/security/resources/cross-origin-modal-dialog-base-2.html        2016-04-13 09:11:57 UTC (rev 199437)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html lang=&quot;en&quot;&gt;
+&lt;head&gt;
+    &lt;meta charset=&quot;UTF-8&quot;&gt;
+    &lt;title&gt;Dialog Content, Step 2&lt;/title&gt;
+    &lt;script&gt;
+        function closeWindow()
+        {
+            if (window.testRunner) {
+                testRunner.abortModal();
+            }
+            close();
+        }
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;closeWindow()&quot;&gt;
+&lt;script&gt;
+    console.log(&quot;document.location.origin after setting location to a relative path: &quot; + document.location.origin);
+&lt;/script&gt;
+This is a modal dialog.
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit212LayoutTestsplatformwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/platform/wk2/TestExpectations (199436 => 199437)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/LayoutTests/platform/wk2/TestExpectations        2016-04-13 09:09:25 UTC (rev 199436)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/platform/wk2/TestExpectations        2016-04-13 09:11:57 UTC (rev 199437)
</span><span class="lines">@@ -289,6 +289,7 @@
</span><span class="cx"> # WebKit2 needs showModalDialog
</span><span class="cx"> fast/events/scroll-event-during-modal-dialog.html
</span><span class="cx"> fast/harness/show-modal-dialog.html
</span><ins>+http/tests/security/cross-origin-modal-dialog-base.html [ Skip ]
</ins><span class="cx"> 
</span><span class="cx"> # WebKit2 needs to support synchronous creation of about:blank/data:url frames
</span><span class="cx"> fast/dom/HTMLDocument/hasFocus.html
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (199436 => 199437)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog        2016-04-13 09:09:25 UTC (rev 199436)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog        2016-04-13 09:11:57 UTC (rev 199437)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-03-22  Darin Adler  &lt;darin@apple.com&gt;
+
+        showModalDialog code runs with “first window” set to wrong window
+        https://bugs.webkit.org/show_bug.cgi?id=155710
+
+        Reviewed by Brent Fulgham.
+
+        Test: http/tests/security/cross-origin-modal-dialog-base.html
+
+        * page/Chrome.cpp:
+        (WebCore::Chrome::runModal): Null out entryScope so that the &quot;first window&quot;
+        checks inside the modal dialog won't run in the context of the original window
+        that presented the dialog.
+
</ins><span class="cx"> 2016-03-22  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         userSpaceOnUse patterns are not stroked for empty object bounding box elements
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCorepageChromecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/page/Chrome.cpp (199436 => 199437)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/page/Chrome.cpp        2016-04-13 09:09:25 UTC (rev 199436)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/page/Chrome.cpp        2016-04-13 09:11:57 UTC (rev 199437)
</span><span class="lines">@@ -48,8 +48,10 @@
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;StorageNamespace.h&quot;
</span><span class="cx"> #include &quot;WindowFeatures.h&quot;
</span><ins>+#include &lt;runtime/VM.h&gt;
</ins><span class="cx"> #include &lt;wtf/PassRefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><ins>+#include &lt;wtf/TemporaryChange.h&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -219,6 +221,10 @@
</span><span class="cx">     // in a way that could interact with this view.
</span><span class="cx">     PageGroupLoadDeferrer deferrer(m_page, false);
</span><span class="cx"> 
</span><ins>+    // JavaScript that runs within the nested event loop must not be run in the context of the
+    // script that called showModalDialog. Null out entryScope to break the connection.
+    TemporaryChange&lt;JSC::VMEntryScope*&gt; entryScopeNullifier { m_page.mainFrame().document()-&gt;vm().entryScope, nullptr };
+
</ins><span class="cx">     TimerBase::fireTimersInNestedEventLoop();
</span><span class="cx">     m_client.runModal();
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>