<!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>[202761] 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/202761">202761</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-07-01 16:22:23 -0700 (Fri, 01 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Regression(<a href="http://trac.webkit.org/projects/webkit/changeset/199087">r199087</a>): window.focus() / window.close() can no longer be called by a Window's opener
https://bugs.webkit.org/show_bug.cgi?id=159364
&lt;rdar://problem/27117169&gt;

Reviewed by Gavin Barraclough.

Source/WebCore:

window.focus() / window.close() could no longer be called by a Window's opener
after <a href="http://trac.webkit.org/projects/webkit/changeset/199087">r199087</a>, which would break focusing of open iWork documents on icloud.com.

Before <a href="http://trac.webkit.org/projects/webkit/changeset/199087">r199087</a>, we would construct a new function in the caller's context every
time window.focus and window.close was accessed. <a href="http://trac.webkit.org/projects/webkit/changeset/199087">r199087</a> fixed the issue so that
we always call the same function. However, those functions are using
[CallWith=Document] and they are were no longer passed the *caller*'s document
as a result. This broke focus / close permission checking as the code needed the
caller's document to do the check.

This patch introduces [CallWith=CallerDocument] and [CallWith=CallerWindow] so
that the implementation can now pass the caller's Document / Window to the
implementation. The bindings rely on JSDOMWindow's callerDOMWindow() to get the
caller DOMWindow / document. This new functionality is now used for window.close
and window.focus to unbreak their permission checking.

Test: fast/dom/Window/child-window-focus.html

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallWith):
* bindings/scripts/IDLAttributes.txt:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::focus):
* page/DOMWindow.h:
* page/DOMWindow.idl:

LayoutTests:

Add layout test coverage.

* fast/dom/Window/child-window-focus-expected.txt: Added.
* fast/dom/Window/child-window-focus.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorTestExpectations">trunk/LayoutTests/platform/ios-simulator/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwinTestExpectations">trunk/LayoutTests/platform/win/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsIDLAttributestxt">trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjh">trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestObjCDOMTestObjh">trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestObjCDOMTestObjmm">trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestObjidl">trunk/Source/WebCore/bindings/scripts/test/TestObj.idl</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowcpp">trunk/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowh">trunk/Source/WebCore/page/DOMWindow.h</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowidl">trunk/Source/WebCore/page/DOMWindow.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomWindowchildwindowfocusexpectedtxt">trunk/LayoutTests/fast/dom/Window/child-window-focus-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomWindowchildwindowfocushtml">trunk/LayoutTests/fast/dom/Window/child-window-focus.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/LayoutTests/ChangeLog        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-07-01  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Regression(r199087): window.focus() / window.close() can no longer be called by a Window's opener
+        https://bugs.webkit.org/show_bug.cgi?id=159364
+        &lt;rdar://problem/27117169&gt;
+
+        Reviewed by Gavin Barraclough.
+
+        Add layout test coverage.
+
+        * fast/dom/Window/child-window-focus-expected.txt: Added.
+        * fast/dom/Window/child-window-focus.html: Added.
+
</ins><span class="cx"> 2016-07-01  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Test gardening for Sierra WK1
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomWindowchildwindowfocusexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Window/child-window-focus-expected.txt (0 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Window/child-window-focus-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/child-window-focus-expected.txt        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Test that a Window can be focused / closed by its opener
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+* Opening new window
+PASS newWindow.opener is window
+newWindow.focus()
+PASS New Window focused
+PASS newWindow.closed is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomWindowchildwindowfocushtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Window/child-window-focus.html (0 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Window/child-window-focus.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/child-window-focus.html        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+description(&quot;Test that a Window can be focused / closed by its opener&quot;);
+
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setCanOpenWindows(true);
+
+debug(&quot;* Opening new window&quot;);
+newWindow = window.open('about:blank', '_blank');
+newWindow.onfocus = function() {
+    testPassed(&quot;New Window focused&quot;);
+    newWindow.close();
+    setTimeout(function() {
+        shouldBeTrue(&quot;newWindow.closed&quot;);
+        finishJSTest();
+    }, 0);
+}
+shouldBe(&quot;newWindow.opener&quot;, &quot;window&quot;);
+evalAndLog(&quot;newWindow.focus()&quot;);
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -2976,6 +2976,7 @@
</span><span class="cx"> fast/images/image-map-outline-in-positioned-container.html [ Pass ImageOnlyFailure ]
</span><span class="cx"> fast/images/image-map-outline-with-paint-root-offset.html [ Pass ImageOnlyFailure ]
</span><span class="cx"> fast/images/image-map-outline-with-scale-transform.html [ Pass ImageOnlyFailure ]
</span><ins>+fast/dom/Window/child-window-focus.html
</ins><span class="cx"> 
</span><span class="cx"> # iOS does not allow you to scroll by dragging the scrollbar thumb.
</span><span class="cx"> webkit.org/b/157201 fast/scrolling/rtl-drag-vertical-scroller.html [ Failure ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -144,6 +144,7 @@
</span><span class="cx"> 
</span><span class="cx"> # This test is WebKit2-only
</span><span class="cx"> http/tests/contentfiltering/load-substitute-data-from-appcache.html
</span><ins>+fast/dom/Window/child-window-focus.html
</ins><span class="cx"> 
</span><span class="cx"> # Testing the system language declaratively only makes sense in WK2, because it's implemented in WebKitTestRunner by launching a new WebContent process.
</span><span class="cx"> fast/text/international/system-language [ Pass Failure ImageOnlyFailure ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformwinTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/win/TestExpectations (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/win/TestExpectations        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/LayoutTests/platform/win/TestExpectations        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -3327,6 +3327,9 @@
</span><span class="cx"> webkit.org/b/137204 svg/text/text-hkern.svg [ Failure ]
</span><span class="cx"> webkit.org/b/137204 svg/text/text-vkern.svg [ Failure ]
</span><span class="cx"> 
</span><ins>+# This test is WebKit2 only.
+fast/dom/Window/child-window-focus.html
+
</ins><span class="cx"> # SVG Fonts don't draw multibyte characters.
</span><span class="cx"> webkit.org/b/154690 svg/W3C-SVG-1.1/text-align-08-b.svg [ Failure ]
</span><span class="cx"> webkit.org/b/154690 svg/W3C-SVG-1.1/text-intro-01-t.svg [ Failure ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/ChangeLog        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -1,5 +1,39 @@
</span><span class="cx"> 2016-07-01  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Regression(r199087): window.focus() / window.close() can no longer be called by a Window's opener
+        https://bugs.webkit.org/show_bug.cgi?id=159364
+        &lt;rdar://problem/27117169&gt;
+
+        Reviewed by Gavin Barraclough.
+
+        window.focus() / window.close() could no longer be called by a Window's opener
+        after r199087, which would break focusing of open iWork documents on icloud.com.
+
+        Before r199087, we would construct a new function in the caller's context every
+        time window.focus and window.close was accessed. r199087 fixed the issue so that
+        we always call the same function. However, those functions are using
+        [CallWith=Document] and they are were no longer passed the *caller*'s document
+        as a result. This broke focus / close permission checking as the code needed the
+        caller's document to do the check.
+
+        This patch introduces [CallWith=CallerDocument] and [CallWith=CallerWindow] so
+        that the implementation can now pass the caller's Document / Window to the
+        implementation. The bindings rely on JSDOMWindow's callerDOMWindow() to get the
+        caller DOMWindow / document. This new functionality is now used for window.close
+        and window.focus to unbreak their permission checking.
+
+        Test: fast/dom/Window/child-window-focus.html
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallWith):
+        * bindings/scripts/IDLAttributes.txt:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::focus):
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+
+2016-07-01  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         [iOS] Possible null Range dereference under computeAutocorrectionContext()
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=159328
</span><span class="cx">         &lt;rdar://problem/26766720&gt;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -3521,6 +3521,13 @@
</span><span class="cx">         push(@$outputArray, &quot;    auto&amp; document = downcast&lt;Document&gt;(*context);\n&quot;);
</span><span class="cx">         push(@callWithArgs, &quot;document&quot;);
</span><span class="cx">     }
</span><ins>+    if ($codeGenerator-&gt;ExtendedAttributeContains($callWith, &quot;CallerDocument&quot;)) {
+        $implIncludes{&quot;Document.h&quot;} = 1;
+        push(@$outputArray, &quot;    auto* document = callerDOMWindow(state).document();\n&quot;);
+        push(@$outputArray, &quot;    if (!document)\n&quot;);
+        push(@$outputArray, &quot;        return&quot; . ($returnValue ? &quot; &quot; . $returnValue : &quot;&quot;) . &quot;;\n&quot;);
+        push(@callWithArgs, &quot;*document&quot;);
+    }
</ins><span class="cx">     if ($function and $codeGenerator-&gt;ExtendedAttributeContains($callWith, &quot;ScriptArguments&quot;)) {
</span><span class="cx">         push(@$outputArray, &quot;    RefPtr&lt;Inspector::ScriptArguments&gt; scriptArguments(Inspector::createScriptArguments(state, &quot; . @{$function-&gt;parameters} . &quot;));\n&quot;);
</span><span class="cx">         $implIncludes{&quot;&lt;inspector/ScriptArguments.h&gt;&quot;} = 1;
</span><span class="lines">@@ -3529,6 +3536,7 @@
</span><span class="cx">     }
</span><span class="cx">     push(@callWithArgs, &quot;activeDOMWindow(state)&quot;) if $codeGenerator-&gt;ExtendedAttributeContains($callWith, &quot;ActiveWindow&quot;);
</span><span class="cx">     push(@callWithArgs, &quot;firstDOMWindow(state)&quot;) if $codeGenerator-&gt;ExtendedAttributeContains($callWith, &quot;FirstWindow&quot;);
</span><ins>+    push(@callWithArgs, &quot;callerDOMWindow(state)&quot;) if $codeGenerator-&gt;ExtendedAttributeContains($callWith, &quot;CallerWindow&quot;);
</ins><span class="cx"> 
</span><span class="cx">     return @callWithArgs;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsIDLAttributestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx"> CachedAttribute
</span><span class="cx"> CallbackNeedsOperatorEqual
</span><span class="cx"> Callback=FunctionOnly
</span><del>-CallWith=Document|ScriptExecutionContext|ScriptState|ScriptArguments|CallStack|ActiveWindow|FirstWindow
</del><ins>+CallWith=Document|ScriptExecutionContext|ScriptState|ScriptArguments|CallStack|ActiveWindow|FirstWindow|CallerDocument|CallerWindow
</ins><span class="cx"> CheckSecurity
</span><span class="cx"> CheckSecurityForNode
</span><span class="cx"> Clamp
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -1600,6 +1600,22 @@
</span><span class="cx">     item-&gt;withDocumentArgument();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void webkit_dom_test_obj_with_caller_document_argument(WebKitDOMTestObj* self)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item-&gt;withCallerDocumentArgument();
+}
+
+void webkit_dom_test_obj_with_caller_window_argument(WebKitDOMTestObj* self)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item-&gt;withCallerWindowArgument();
+}
+
</ins><span class="cx"> void webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt)
</span><span class="cx"> {
</span><span class="cx">     WebCore::JSMainThreadNullState state;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -498,6 +498,24 @@
</span><span class="cx"> webkit_dom_test_obj_with_document_argument(WebKitDOMTestObj* self);
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * webkit_dom_test_obj_with_caller_document_argument:
+ * @self: A #WebKitDOMTestObj
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_with_caller_document_argument(WebKitDOMTestObj* self);
+
+/**
+ * webkit_dom_test_obj_with_caller_window_argument:
+ * @self: A #WebKitDOMTestObj
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_with_caller_window_argument(WebKitDOMTestObj* self);
+
+/**
</ins><span class="cx">  * webkit_dom_test_obj_method_with_optional_arg:
</span><span class="cx">  * @self: A #WebKitDOMTestObj
</span><span class="cx">  * @opt: A #glong
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -620,6 +620,8 @@
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateWithSpaces(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptArgumentsAndCallStack(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDocumentArgument(JSC::ExecState*);
</span><ins>+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithCallerDocumentArgument(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithCallerWindowArgument(JSC::ExecState*);
</ins><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*);
</span><span class="lines">@@ -1200,6 +1202,8 @@
</span><span class="cx">     { &quot;withScriptExecutionContextAndScriptStateWithSpaces&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateWithSpaces), (intptr_t) (0) } },
</span><span class="cx">     { &quot;withScriptArgumentsAndCallStack&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionWithScriptArgumentsAndCallStack), (intptr_t) (0) } },
</span><span class="cx">     { &quot;withDocumentArgument&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionWithDocumentArgument), (intptr_t) (0) } },
</span><ins>+    { &quot;withCallerDocumentArgument&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionWithCallerDocumentArgument), (intptr_t) (0) } },
+    { &quot;withCallerWindowArgument&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionWithCallerWindowArgument), (intptr_t) (0) } },
</ins><span class="cx">     { &quot;methodWithOptionalArg&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t) (0) } },
</span><span class="cx">     { &quot;methodWithOptionalArgAndDefaultValue&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue), (intptr_t) (0) } },
</span><span class="cx">     { &quot;methodWithNonOptionalArgAndOptionalArg&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t) (1) } },
</span><span class="lines">@@ -4627,6 +4631,33 @@
</span><span class="cx">     return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithCallerDocumentArgument(ExecState* state)
+{
+    JSValue thisValue = state-&gt;thisValue();
+    auto castedThis = jsDynamicCast&lt;JSTestObj*&gt;(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, &quot;TestObj&quot;, &quot;withCallerDocumentArgument&quot;);
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto&amp; impl = castedThis-&gt;wrapped();
+    auto* document = callerDOMWindow(state).document();
+    if (!document)
+        return JSValue::encode(jsUndefined());
+    impl.withCallerDocumentArgument(*document);
+    return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithCallerWindowArgument(ExecState* state)
+{
+    JSValue thisValue = state-&gt;thisValue();
+    auto castedThis = jsDynamicCast&lt;JSTestObj*&gt;(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, &quot;TestObj&quot;, &quot;withCallerWindowArgument&quot;);
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto&amp; impl = castedThis-&gt;wrapped();
+    impl.withCallerWindowArgument(callerDOMWindow(state));
+    return JSValue::encode(jsUndefined());
+}
+
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(ExecState* state)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = state-&gt;thisValue();
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestObjCDOMTestObjh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -176,6 +176,8 @@
</span><span class="cx"> - (DOMTestObj *)withScriptExecutionContextAndScriptStateWithSpaces;
</span><span class="cx"> - (void)withScriptArgumentsAndCallStack;
</span><span class="cx"> - (void)withDocumentArgument;
</span><ins>+- (void)withCallerDocumentArgument;
+- (void)withCallerWindowArgument;
</ins><span class="cx"> - (void)methodWithOptionalArg:(int)opt;
</span><span class="cx"> - (void)methodWithOptionalArgAndDefaultValue:(int)opt;
</span><span class="cx"> - (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestObjCDOMTestObjmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -1330,6 +1330,18 @@
</span><span class="cx">     IMPL-&gt;withDocumentArgument();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)withCallerDocumentArgument
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL-&gt;withCallerDocumentArgument();
+}
+
+- (void)withCallerWindowArgument
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL-&gt;withCallerWindowArgument();
+}
+
</ins><span class="cx"> - (void)methodWithOptionalArg:(int)opt
</span><span class="cx"> {
</span><span class="cx">     WebCore::JSMainThreadNullState state;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestObjidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -169,6 +169,8 @@
</span><span class="cx">     [CallWith=  ScriptExecutionContext  &amp;  ScriptState  ] TestObj withScriptExecutionContextAndScriptStateWithSpaces();
</span><span class="cx">     [CallWith=ScriptArguments&amp;CallStack] void withScriptArgumentsAndCallStack();
</span><span class="cx">     [CallWith=Document] void withDocumentArgument();
</span><ins>+    [CallWith=CallerDocument] void withCallerDocumentArgument();
+    [CallWith=CallerWindow] void withCallerWindowArgument();
</ins><span class="cx"> 
</span><span class="cx">     [CallWith=ScriptState] attribute long withScriptStateAttribute;
</span><span class="cx">     [CallWith=ScriptState, SetterCallWith=ActiveWindow&amp;FirstWindow] attribute long withCallWithAndSetterCallWithAttribute;
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.cpp (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.cpp        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/page/DOMWindow.cpp        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -972,9 +972,9 @@
</span><span class="cx">     return m_frame-&gt;ownerElement();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DOMWindow::focus(Document&amp; document)
</del><ins>+void DOMWindow::focus(DOMWindow&amp; callerWindow)
</ins><span class="cx"> {
</span><del>-    focus(opener() &amp;&amp; opener() != this &amp;&amp; document.domWindow() == opener());
</del><ins>+    focus(opener() &amp;&amp; opener() != this &amp;&amp; &amp;callerWindow == opener());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DOMWindow::focus(bool allowFocus)
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.h (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.h        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/page/DOMWindow.h        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -163,7 +163,7 @@
</span><span class="cx">         Element* frameElement() const;
</span><span class="cx"> 
</span><span class="cx">         WEBCORE_EXPORT void focus(bool allowFocus = false);
</span><del>-        void focus(Document&amp;);
</del><ins>+        void focus(DOMWindow&amp; callerWindow);
</ins><span class="cx">         void blur();
</span><span class="cx">         WEBCORE_EXPORT void close();
</span><span class="cx">         void close(Document&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.idl (202760 => 202761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.idl        2016-07-01 23:15:48 UTC (rev 202760)
+++ trunk/Source/WebCore/page/DOMWindow.idl        2016-07-01 23:22:23 UTC (rev 202761)
</span><span class="lines">@@ -58,9 +58,9 @@
</span><span class="cx"> 
</span><span class="cx">     [CheckSecurityForNode] readonly attribute Element frameElement;
</span><span class="cx"> 
</span><del>-    [DoNotCheckSecurity, CallWith=Document, ForwardDeclareInHeader] void focus();
</del><ins>+    [DoNotCheckSecurity, CallWith=CallerWindow, ForwardDeclareInHeader] void focus();
</ins><span class="cx">     [DoNotCheckSecurity, ForwardDeclareInHeader] void blur();
</span><del>-    [DoNotCheckSecurity, CallWith=Document, ForwardDeclareInHeader] void close();
</del><ins>+    [DoNotCheckSecurity, CallWith=CallerDocument, ForwardDeclareInHeader] void close();
</ins><span class="cx"> 
</span><span class="cx">     void print();
</span><span class="cx">     void stop();
</span></span></pre>
</div>
</div>

</body>
</html>